Results 1 to 4 of 4

Thread: (Resolved) Get Desktop Path help...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137

    (Resolved) Get Desktop Path help...

    Hello,

    Would like to retrieve the path to the desktop from my app. If anyone will help please .......

    Thanxs

    vbBoy.
    Last edited by vbBoy; Oct 14th, 2001 at 04:10 AM.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    Look if this helps

  3. #3
    Matthew Gates
    Guest
    To get the desktop, use the SHGetSpecialFolderLocation API function.


    VB Code:
    1. Private Declare Function SHGetSpecialFolderLocation _
    2. Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As _
    3. Long, pidl As ITEMIDLIST) As Long
    4.  
    5. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
    6. Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath _
    7. As String) As Long
    8.  
    9. Private Type [i]S[/i]HITEMID
    10.     cb As Long
    11.     abID As Byte
    12. End Type
    13. Private Type ITEMIDLIST
    14.     mkid As [i]S[/i]HITEMID
    15. End Type
    16.  
    17. Private Function GetSpecialFolder(CSIDL As Long) As String
    18.     Dim r As Long
    19.     Dim IDL As ITEMIDLIST
    20.     r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
    21.     If r = NOERROR Then
    22.         Path$ = Space$(512)
    23.         r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
    24.         GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
    25.         Exit Function
    26.     End If
    27.     GetSpecialfolder = ""
    28. End Function
    29.  
    30.  
    31. Private Sub Command1_Click()
    32.     MsgBox GetSpecialFolder(&H0)
    33. End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2001
    Posts
    137

    Reply to Matthew Gates

    Thanxs,

    It works.

    vbBoy.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width