magicdibot
Messages postés10Date d'inscriptionmercredi 18 décembre 2002StatutMembreDernière intervention28 mars 2005
-
7 juil. 2003 à 14:13
cs_BFR
Messages postés88Date d'inscriptionmardi 30 juillet 2002StatutMembreDernière intervention 1 mars 2008
-
7 juil. 2003 à 14:58
Bonjour,
Je cherche à récupérer le chemin du dossier sys Mesdocs.
Existe t il une variable d'environnement qui me permette de faire ça de la mm façon que la var. TEMP, TMP, WINDIR....
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
'Pour les répertoires Windows et System :
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
'===============================================================================
'
'===============================================================================
Public Function DossierSpecial(Frm As Form, ByVal CSIDL As Long) As String
'-Récupère un dossier spécial style c:\windows, c:\windows\recent...
'-Appel depuis une form
'Dim d
'd = DossierSpecial(Me, spFavoris)
'***************************************
'-variables nécessaires
Dim r As Long
Dim sPath As String
Dim IDL As ITEMIDLIST
Const NOERROR = 0
Const MAX_LENGTH = 260
'-Cherche le dossier spécial
r = SHGetSpecialFolderLocation(Frm.hwnd, CSIDL, IDL)
If r = NOERROR Then
'Recherche le dossier spécial à partir
'du "Type" IDL
sPath = Space$(MAX_LENGTH)
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal sPath)
If r Then
DossierSpecial = Left$(sPath, InStr(sPath, Chr$(0)) - 1)
End If
End If