OVH Cloud OVH Cloud

Favoris réseaux

3 réponses
Avatar
Fabrice
Bonjour,

Comment visualiser les PC dans le même groupe de travail pour ensuite copier
les fichiers d'un répertoire partagé sur le pc en local ?

Merci

3 réponses

Avatar
ng
Salut,

Il faudrer détailler un peu.
Peut être NetServerEnum() ou un BrowseForFolder() (utilisé avec
ShowNetworkFolder() ci dessous) ?

Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
strDisplayName As String
strTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Const CSIDL_NETWORK = &H12
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_BROWSEFORCOMPUTER = &H1000
Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib "shell32" (lpBI As
BROWSEINFO) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As
Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As
Long, ByVal lpBuffer As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal
hwndOwner As Long, ByVal Folder As Long

Public Function ShowNetworkFolder(FormhWnd As Long, sTitre As String) As
String
Dim sChe As String
Call BrowseForFolder(CSIDL_NETWORK, BIF_BROWSEFORCOMPUTER, sChe, sTitre,
FormhWnd)
ShowNetworkFolder = sChe
End Function

Private Function BrowseForFolder(ByVal lngCSIdl As Long, ByVal lngBifFlags
As Long, ByRef strFolder As String, Optional ByVal strTitle As String =
"Select Folder", Optional ByVal hWnd As Long = 0) As Long
Dim bi As BROWSEINFO
Dim lngReturn As Long
Dim lngIDL As Long
If SHGetSpecialFolderLocation(hWnd, lngCSIdl, lngIDL) = 0 Then
With bi
.hwndOwner = hWnd
.pidlRoot = lngIDL
.strDisplayName = Space$(MAX_PATH)
.strTitle = strTitle
.ulFlags = lngBifFlags
End With
lngIDL = SHBrowseForFolder(bi)
If lngIDL <> 0 Then
strFolder = Space$(MAX_PATH)
If CBool(SHGetPathFromIDList(lngIDL, strFolder)) Then
strFolder = TrimNull(strFolder)
lngReturn = 0&
Else
strFolder = TrimNull(bi.strDisplayName)
lngReturn = 0&
End If
Else
lngReturn = 1208&
End If
Call GlobalFree(lngIDL)
Else
lngReturn = 1208&
End If
BrowseForFolder = lngReturn
End Function

Private Function TrimNull(ByVal strValue As String) As String
Dim intPos As Integer
intPos = InStr(strValue, vbNullChar)
Select Case intPos
Case Is > 1
TrimNull = left$(strValue, intPos - 1)
Case 0
TrimNull = strValue
Case 1
TrimNull = ""
End Select
End Function

Exemple :

Dim sChe As String
sChe = ShowNetworkFolder(Me.hWnd, "Choisissez un emplacement réseau :")

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Fabrice wrote:
Bonjour,

Comment visualiser les PC dans le même groupe de travail pour ensuite
copier les fichiers d'un répertoire partagé sur le pc en local ?

Merci


Avatar
Fabrice
En fait, voilà ma demande plus précise :

1- Retrouver un PC via les favoris réseaux
2- Se connecter à un partage sur ce PC
3- Copier les fichiers du partage pour les coller dans le même chemin sur le
PC en local

Merci pour ta contribution

"ng" a écrit dans le message de news:

Salut,

Il faudrer détailler un peu.
Peut être NetServerEnum() ou un BrowseForFolder() (utilisé avec
ShowNetworkFolder() ci dessous) ?

Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
strDisplayName As String
strTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Const CSIDL_NETWORK = &H12
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_BROWSEFORCOMPUTER = &H1000
Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib "shell32" (lpBI As
BROWSEINFO) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As
Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList
As Long, ByVal lpBuffer As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll"
(ByVal hwndOwner As Long, ByVal Folder As Long

Public Function ShowNetworkFolder(FormhWnd As Long, sTitre As String) As
String
Dim sChe As String
Call BrowseForFolder(CSIDL_NETWORK, BIF_BROWSEFORCOMPUTER, sChe,
sTitre, FormhWnd)
ShowNetworkFolder = sChe
End Function

Private Function BrowseForFolder(ByVal lngCSIdl As Long, ByVal lngBifFlags
As Long, ByRef strFolder As String, Optional ByVal strTitle As String =
"Select Folder", Optional ByVal hWnd As Long = 0) As Long
Dim bi As BROWSEINFO
Dim lngReturn As Long
Dim lngIDL As Long
If SHGetSpecialFolderLocation(hWnd, lngCSIdl, lngIDL) = 0 Then
With bi
.hwndOwner = hWnd
.pidlRoot = lngIDL
.strDisplayName = Space$(MAX_PATH)
.strTitle = strTitle
.ulFlags = lngBifFlags
End With
lngIDL = SHBrowseForFolder(bi)
If lngIDL <> 0 Then
strFolder = Space$(MAX_PATH)
If CBool(SHGetPathFromIDList(lngIDL, strFolder)) Then
strFolder = TrimNull(strFolder)
lngReturn = 0&
Else
strFolder = TrimNull(bi.strDisplayName)
lngReturn = 0&
End If
Else
lngReturn = 1208&
End If
Call GlobalFree(lngIDL)
Else
lngReturn = 1208&
End If
BrowseForFolder = lngReturn
End Function

Private Function TrimNull(ByVal strValue As String) As String
Dim intPos As Integer
intPos = InStr(strValue, vbNullChar)
Select Case intPos
Case Is > 1
TrimNull = left$(strValue, intPos - 1)
Case 0
TrimNull = strValue
Case 1
TrimNull = ""
End Select
End Function

Exemple :

Dim sChe As String
sChe = ShowNetworkFolder(Me.hWnd, "Choisissez un emplacement réseau :")

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Fabrice wrote:
Bonjour,

Comment visualiser les PC dans le même groupe de travail pour ensuite
copier les fichiers d'un répertoire partagé sur le pc en local ?

Merci






Avatar
ng
Salut,

Qu'entends tu par retrouver un pc ? Demander à l'utilisateur de choisir un
PC ? retrouver en fonction de l'ip ? Lister les PC du réseau ?

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Fabrice wrote:
En fait, voilà ma demande plus précise :

1- Retrouver un PC via les favoris réseaux
2- Se connecter à un partage sur ce PC
3- Copier les fichiers du partage pour les coller dans le même chemin
sur le PC en local

Merci pour ta contribution

"ng" a écrit dans le message de news:

Salut,

Il faudrer détailler un peu.
Peut être NetServerEnum() ou un BrowseForFolder() (utilisé avec
ShowNetworkFolder() ci dessous) ?

Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
strDisplayName As String
strTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Const CSIDL_NETWORK = &H12
Const BIF_RETURNONLYFSDIRS = 1
Const BIF_BROWSEFORCOMPUTER = &H1000
Const MAX_PATH = 260

Private Declare Function SHBrowseForFolder Lib "shell32" (lpBI As
BROWSEINFO) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As
Long) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal
pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll"
(ByVal hwndOwner As Long, ByVal Folder As Long

Public Function ShowNetworkFolder(FormhWnd As Long, sTitre As
String) As String
Dim sChe As String
Call BrowseForFolder(CSIDL_NETWORK, BIF_BROWSEFORCOMPUTER, sChe,
sTitre, FormhWnd)
ShowNetworkFolder = sChe
End Function

Private Function BrowseForFolder(ByVal lngCSIdl As Long, ByVal
lngBifFlags As Long, ByRef strFolder As String, Optional ByVal
strTitle As String = "Select Folder", Optional ByVal hWnd As Long >> 0) As Long Dim bi As BROWSEINFO
Dim lngReturn As Long
Dim lngIDL As Long
If SHGetSpecialFolderLocation(hWnd, lngCSIdl, lngIDL) = 0 Then
With bi
.hwndOwner = hWnd
.pidlRoot = lngIDL
.strDisplayName = Space$(MAX_PATH)
.strTitle = strTitle
.ulFlags = lngBifFlags
End With
lngIDL = SHBrowseForFolder(bi)
If lngIDL <> 0 Then
strFolder = Space$(MAX_PATH)
If CBool(SHGetPathFromIDList(lngIDL, strFolder)) Then
strFolder = TrimNull(strFolder)
lngReturn = 0&
Else
strFolder = TrimNull(bi.strDisplayName)
lngReturn = 0&
End If
Else
lngReturn = 1208&
End If
Call GlobalFree(lngIDL)
Else
lngReturn = 1208&
End If
BrowseForFolder = lngReturn
End Function

Private Function TrimNull(ByVal strValue As String) As String
Dim intPos As Integer
intPos = InStr(strValue, vbNullChar)
Select Case intPos
Case Is > 1
TrimNull = left$(strValue, intPos - 1)
Case 0
TrimNull = strValue
Case 1
TrimNull = ""
End Select
End Function

Exemple :

Dim sChe As String
sChe = ShowNetworkFolder(Me.hWnd, "Choisissez un emplacement
réseau :") --
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Fabrice wrote:
Bonjour,

Comment visualiser les PC dans le même groupe de travail pour
ensuite copier les fichiers d'un répertoire partagé sur le pc en
local ? Merci