Declare Function SHGetFolderPath Lib "shell32.dll" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal lpszPath As String) As Long
SHGetFolderPath 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.
The function returns one of the following flags:
None.
Const S_OK = &H0
Const S_FALSE = &H1
Const E_INVALIDARG = &H80070057
Const SHGFP_TYPE_CURRENT = 0
Const SHGFP_TYPE_DEFAULT = 1
' 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 = SHGetolderPath(Form1.hWnd, CSIDL_PERSONAL, 0, SHGFP_TYPE_CURRENT, pathname)
' 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
SHGetFolderLocation, SHGetSpecialFolderPath
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/shgetfolderpath.html