Option Explicit
Private Const MAX_PATH = 256
Private Const CSIDL_DESKTOP = &H0
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" ( _
ByVal hWnd As Long, _
ByVal nFolder As Long, _
ppidl As Long _
) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" ( _
ByVal ppidl As Long, _
ByVal pszPath As String _
) As Long
Private Sub Form_Load()
Dim ret As Long
Dim ItemIDList As Long
Dim FolderPath As String * MAX_PATH
ret = SHGetSpecialFolderLocation(Form1.hWnd, CSIDL_DESKTOP, ItemIDList)
ret = SHGetPathFromIDList(ItemIDList, FolderPath)
Call MsgBox(FolderPath)
End Sub
|