|
-
Aug 17th, 2000, 09:25 AM
#1
Thread Starter
Junior Member
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.
-
Aug 17th, 2000, 10:28 AM
#2
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|