Hello,
Would like to retrieve the path to the desktop from my app. If anyone will help please .......
Thanxs
vbBoy.
Printable View
Hello,
Would like to retrieve the path to the desktop from my app. If anyone will help please .......
Thanxs
vbBoy.
Look if this helps
To get the desktop, use the SHGetSpecialFolderLocation API function.
VB Code:
Private Declare Function SHGetSpecialFolderLocation _ Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As _ Long, pidl As ITEMIDLIST) As Long Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _ Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath _ As String) As Long Private Type [i]S[/i]HITEMID cb As Long abID As Byte End Type Private Type ITEMIDLIST mkid As [i]S[/i]HITEMID End Type Private Function GetSpecialFolder(CSIDL As Long) As String Dim r As Long Dim IDL As ITEMIDLIST r = SHGetSpecialFolderLocation(100, CSIDL, IDL) If r = NOERROR Then Path$ = Space$(512) r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$) GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1) Exit Function End If GetSpecialfolder = "" End Function Private Sub Command1_Click() MsgBox GetSpecialFolder(&H0) End Sub
Thanxs,
It works.
vbBoy.