1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| 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
'-------------------------------------------|
Const CSIDL_DESKTOP = &H0 ' (bureau) |
Const CSIDL_PROGRAMS = &H2 ' |
Const CSIDL_CONTROLS = &H3 ' |
Const CSIDL_PRINTERS = &H4 ' |
Const CSIDL_PERSONAL = &H5 ' | les constantes pour nFolder
Const CSIDL_FAVORITES = &H6 '(favoris) |
Const CSIDL_STARTUP = &H7 ' | (extraction du nom des dossiers spéciaux)
Const CSIDL_RECENT = &H8 '(fichiers récents)|
Const CSIDL_SENDTO = &H9 ' | (Elles sont toutes là. Je n'ai toutefois
Const CSIDL_BITBUCKET = &HA ' | "commenté" que celles que nous utilisons ici.
Const CSIDL_STARTMENU = &HB '(menu démarrer)| Le seul nom de chacun de ces membres est
Const CSIDL_DESKTOPDIRECTORY = &H10 ' | d'ailleurs assez révélateur de sa fonction..)
Const CSIDL_DRIVES = &H11 ' |
Const CSIDL_NETWORK = &H12 ' |
Const CSIDL_NETHOOD = &H13 ' |
Const CSIDL_FONTS = &H14 '(polices) |
Const CSIDL_TEMPLATES = &H15 ' |
'-------------------------------------------|
Const MAX_PATH = 260 ' constante pour pszPath
Private Type SHITEMID '--------------------------------|
cb As Long ' | structure SHITEMID
abID As Byte ' |
End Type '--------------------------------------------|
Private Type ITEMIDLIST '--------------------|
mkid As SHITEMID ' | structure ITEMIDLIST
End Type '----------------------------------|
Private Function GetSpecfold(CSIDL As Long) As String
Dim res As Long
Dim IDL As ITEMIDLIST
res = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If ra = 0 Then
chem$ = Space$(512)
res = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal chem$)
GetSpecfold = Left$(chem, InStr(chem, Chr$(0)) - 1)
Exit Function
End If
GetSpecfold = ""
End Function
Private Sub Command1_Click()
MsgBox GetSpecfold(CSIDL_RECENT)
End Sub |
Partager