Results 1 to 2 of 2

Thread: Get the desktop directory?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    28

    Question

    Is there any way to get the desktop directory within VB code similar to how the windows directory or system directories are obtainable using GetSystemDirectory and GetSystemDirectory, respectively?

    Thanks.

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666

    Cool Maybe this?

    Try this:
    Code:
    Const CSIDL_DESKTOPDIRECTORY = &H10
    
    Declare Function SHGetSpecialFolderPath Lib "shell32.dll" Alias "SHGetSpecialFolderPathA" (ByVal hwndOwner As Long, ByVal lpszPath As String, ByVal nFolder As Long, ByVal fCreate As Long) As Long
    
    Function GetDesktopFolder()
    
    
    Dim pathname As String  ' receives the path of Desktop
    Dim retval As Long  ' return value
    
    ' Make enough room in the buffer to receive the string.
    pathname = Space(260)
    ' Get the path name of the My Documents special folder
    retval = SHGetSpecialFolderPath(Form1.hWnd, pathname, CSIDL_DESKTOPDIRECTORY, 0)
    ' Remove the empty space from the string.
    pathname = Left(pathname, InStr(pathname, vbNullChar) - 1)
    ' Display the result.
    GetDesktopFolder = pathname
    
    End Function
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

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