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
SHGetSpecialFolderPath retrieves the name of the path of a special folder on the system. This function only works with special folders which are physical directories on a disk. The function will fail if the special folder is a virtual folder.
If an error occured, the function returns 0. If successful, the function returns a non-zero value.
None.
' This code is licensed according to the terms and conditions listed here.
' Display the path of the directory used as the My Documents
' special folder. This might not be "C:\My Documents" if the user renamed it!
Dim pathname As String ' receives the path of My Documents
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_PERSONAL, 0)
' Remove the empty space from the string.
pathname = Left(pathname, InStr(pathname, vbNullChar) - 1)
' Display the result.
Debug.Print "The My Documents special folder is: "; pathname
SHGetFolderPath, SHGetSpecialFolderLocation
Go back to the alphabetical Function listing.
Go back to the Reference section index.
Last Modified: September 26, 1999
This page is copyright © 1999 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/s/shgetspecialfolderpath.html