J'aimerais utiliser une boite de dialogue Windows pour sélectionner un
répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin
entier, dans le style "\\Serveur1\Compagnie1\Paie".
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Guy DETIENNE
Salut,
Voici ici :
Using the Browse For Folders Dialog to Obtain Network Machines or Shares http://vbnet.mvps.org/index.html?code/browse/browsenetwork.htm
Guy
"Patrick Fredin" a écrit dans le message de news: uTaAo2K%
Bonjour,
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin entier, dans le style "Serveur1Compagnie1Paie".
Je vous remercie pour votre aide.
-- Patrick
Salut,
Voici ici :
Using the Browse For Folders Dialog to Obtain Network Machines or Shares
http://vbnet.mvps.org/index.html?code/browse/browsenetwork.htm
Guy
"Patrick Fredin" <nospams_patrick.fredin@iquebec.com> a écrit dans le
message de news: uTaAo2K%23EHA.1124@TK2MSFTNGP10.phx.gbl...
Bonjour,
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un
répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin
entier, dans le style "\Serveur1Compagnie1Paie".
Using the Browse For Folders Dialog to Obtain Network Machines or Shares http://vbnet.mvps.org/index.html?code/browse/browsenetwork.htm
Guy
"Patrick Fredin" a écrit dans le message de news: uTaAo2K%
Bonjour,
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin entier, dans le style "Serveur1Compagnie1Paie".
Je vous remercie pour votre aide.
-- Patrick
Fabrice MALAINGRE
Bonsoir Patrick,
Voici un petit exemple qui, je l'espère, devrait faire l'affaire ! Le code est à placer dans un formulaire contenant un unique bouton :
'************************************************************** Option Explicit Option Base 0
'================= ' Type declarations '================= Private Type SHITEMID cb As Long abID() As Byte End Type
Private Type ITEMIDLIST mkid As SHITEMID End Type
Private Type BROWSEINFO hwndOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type
'===================== ' Function declarations '===================== Private Declare Function SHBrowseForFolder _ Lib "Shell32.dll" Alias "SHBrowseForFolderA" _ (lpbi As BROWSEINFO) As Long Private Declare Function SHGetPathFromIDList _ Lib "Shell32.dll" Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, _ ByVal pszPath As Any) As Long Private Declare Function SHGetSpecialFolderLocation _ Lib "Shell32.dll" _ (ByVal hwndOwner As Long, _ ByVal nFolder As Long, _ ppidl As ITEMIDLIST) As Long
Private Sub Command1_Click() '---------------- ' Local constants '---------------- Const l_lNOERROR As Long = 0
'---------------- ' Local variables '---------------- Dim l_lReturnCode As Long Dim l_recBrowseInfo As BROWSEINFO Dim l_recItemIdList As ITEMIDLIST Dim l_pItemIdList As Long Dim l_sFolderName As String * MAX_PATH
'----- ' Body '----- ' Search for the network neighborhood system folder With l_recBrowseInfo .hwndOwner = Me.hWnd l_lReturnCode = SHGetSpecialFolderLocation(Me.hWnd, _ CSIDL_NETWORK, _ l_recItemIdList) If (l_lReturnCode = l_lNOERROR) Then .pidlRoot = l_recItemIdList.mkid.cb End If .pszDisplayName = String$(MAX_PATH, _ 0) .lpszTitle = "My own personal browser!" .ulFlags = 0 'Put BIF_BROWSEFORCOMPUTER if you want to browse for computer End With
' Browse the network neighborhood system folder l_pItemIdList = SHBrowseForFolder(l_recBrowseInfo)
' Retrieve the selected remote folder path If (l_pItemIdList <> 0) Then If (SHGetPathFromIDList(l_pItemIdList, l_sFolderName) <> 0) Then MsgBox UCase$(Left$(l_sFolderName, _ InStr(l_sFolderName, vbNullChar) - 1)) End If End If End Sub '**************************************************************
Cordialement
____________________________ Fabrice MALAINGRE Architecte Logiciel - Chef de Projet THEORIS - www.theoris.fr
Bonsoir Patrick,
Voici un petit exemple qui, je l'espère, devrait faire l'affaire !
Le code est à placer dans un formulaire contenant un unique bouton :
'**************************************************************
Option Explicit
Option Base 0
'================= ' Type declarations
'================= Private Type SHITEMID
cb As Long
abID() As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
'===================== ' Function declarations
'===================== Private Declare Function SHBrowseForFolder _
Lib "Shell32.dll" Alias "SHBrowseForFolderA" _
(lpbi As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList _
Lib "Shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As Any) As Long
Private Declare Function SHGetSpecialFolderLocation _
Lib "Shell32.dll" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ppidl As ITEMIDLIST) As Long
Private Sub Command1_Click()
'----------------
' Local constants
'----------------
Const l_lNOERROR As Long = 0
'----------------
' Local variables
'----------------
Dim l_lReturnCode As Long
Dim l_recBrowseInfo As BROWSEINFO
Dim l_recItemIdList As ITEMIDLIST
Dim l_pItemIdList As Long
Dim l_sFolderName As String * MAX_PATH
'-----
' Body
'-----
' Search for the network neighborhood system folder
With l_recBrowseInfo
.hwndOwner = Me.hWnd
l_lReturnCode = SHGetSpecialFolderLocation(Me.hWnd, _
CSIDL_NETWORK, _
l_recItemIdList)
If (l_lReturnCode = l_lNOERROR) Then
.pidlRoot = l_recItemIdList.mkid.cb
End If
.pszDisplayName = String$(MAX_PATH, _
0)
.lpszTitle = "My own personal browser!"
.ulFlags = 0 'Put BIF_BROWSEFORCOMPUTER if you want to browse for
computer
End With
' Browse the network neighborhood system folder
l_pItemIdList = SHBrowseForFolder(l_recBrowseInfo)
' Retrieve the selected remote folder path
If (l_pItemIdList <> 0) Then
If (SHGetPathFromIDList(l_pItemIdList, l_sFolderName) <> 0) Then
MsgBox UCase$(Left$(l_sFolderName, _
InStr(l_sFolderName, vbNullChar) - 1))
End If
End If
End Sub
'**************************************************************
Cordialement
____________________________
Fabrice MALAINGRE
Architecte Logiciel - Chef de Projet
THEORIS - www.theoris.fr
'================= ' Type declarations '================= Private Type SHITEMID cb As Long abID() As Byte End Type
Private Type ITEMIDLIST mkid As SHITEMID End Type
Private Type BROWSEINFO hwndOwner As Long pidlRoot As Long pszDisplayName As String lpszTitle As String ulFlags As Long lpfn As Long lParam As Long iImage As Long End Type
'===================== ' Function declarations '===================== Private Declare Function SHBrowseForFolder _ Lib "Shell32.dll" Alias "SHBrowseForFolderA" _ (lpbi As BROWSEINFO) As Long Private Declare Function SHGetPathFromIDList _ Lib "Shell32.dll" Alias "SHGetPathFromIDListA" _ (ByVal pidl As Long, _ ByVal pszPath As Any) As Long Private Declare Function SHGetSpecialFolderLocation _ Lib "Shell32.dll" _ (ByVal hwndOwner As Long, _ ByVal nFolder As Long, _ ppidl As ITEMIDLIST) As Long
Private Sub Command1_Click() '---------------- ' Local constants '---------------- Const l_lNOERROR As Long = 0
'---------------- ' Local variables '---------------- Dim l_lReturnCode As Long Dim l_recBrowseInfo As BROWSEINFO Dim l_recItemIdList As ITEMIDLIST Dim l_pItemIdList As Long Dim l_sFolderName As String * MAX_PATH
'----- ' Body '----- ' Search for the network neighborhood system folder With l_recBrowseInfo .hwndOwner = Me.hWnd l_lReturnCode = SHGetSpecialFolderLocation(Me.hWnd, _ CSIDL_NETWORK, _ l_recItemIdList) If (l_lReturnCode = l_lNOERROR) Then .pidlRoot = l_recItemIdList.mkid.cb End If .pszDisplayName = String$(MAX_PATH, _ 0) .lpszTitle = "My own personal browser!" .ulFlags = 0 'Put BIF_BROWSEFORCOMPUTER if you want to browse for computer End With
' Browse the network neighborhood system folder l_pItemIdList = SHBrowseForFolder(l_recBrowseInfo)
' Retrieve the selected remote folder path If (l_pItemIdList <> 0) Then If (SHGetPathFromIDList(l_pItemIdList, l_sFolderName) <> 0) Then MsgBox UCase$(Left$(l_sFolderName, _ InStr(l_sFolderName, vbNullChar) - 1)) End If End If End Sub '**************************************************************
Cordialement
____________________________ Fabrice MALAINGRE Architecte Logiciel - Chef de Projet THEORIS - www.theoris.fr
Patrick Fredin
Merci beaucoup pour vos reponses.
-- Patrick
"Patrick Fredin" wrote in message news:uTaAo2K%
Bonjour,
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin entier, dans le style "Serveur1Compagnie1Paie".
Je vous remercie pour votre aide.
-- Patrick
Merci beaucoup pour vos reponses.
--
Patrick
"Patrick Fredin" <nospams_patrick.fredin@iquebec.com> wrote in message
news:uTaAo2K%23EHA.1124@TK2MSFTNGP10.phx.gbl...
Bonjour,
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un
répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin
entier, dans le style "\Serveur1Compagnie1Paie".
J'aimerais utiliser une boite de dialogue Windows pour sélectionner un répertoire qui se trouve sur un serveur et pouvoir récupérer son chemin entier, dans le style "Serveur1Compagnie1Paie".