Const CSIDL_DESKTOP As Long = &H0
Const CSIDL_INTERNET As Long = &H1
Const CSIDL_PROGRAMS As Long = &H2
Const CSIDL_CONTROLS As Long = &H3
Const CSIDL_PRINTERS As Long = &H4
Const CSIDL_PERSONAL As Long = &H5
Const CSIDL_FAVORITES As Long = &H6
Const CSIDL_STARTUP As Long = &H7
Const CSIDL_RECENT As Long = &H8
Const CSIDL_SENDTO As Long = &H9
Const CSIDL_BITBUCKET As Long = &HA
Const CSIDL_STARTMENU As Long = &HB
Const CSIDL_MYDOCUMENTS As Long = &HC
Const CSIDL_MYMUSIC As Long = &HD
Const CSIDL_MYVIDEO As Long = &HE
Const CSIDL_DESKTOPDIRECTORY As Long = &H10
Const CSIDL_DRIVES As Long = &H11
Const CSIDL_NETWORK As Long = &H12
Const CSIDL_NETHOOD As Long = &H13
Const CSIDL_FONTS As Long = &H14
Const CSIDL_TEMPLATES As Long = &H15
Const CSIDL_COMMON_STARTMENU As Long = &H16
Const CSIDL_COMMON_PROGRAMS As Long = &H17
Const CSIDL_COMMON_STARTUP As Long = &H18
Const CSIDL_COMMON_DESKTOPDIRECTORY As Long = &H19
Const CSIDL_APPDATA As Long = &H1A
Const CSIDL_PRINTHOOD As Long = &H1B
Const CSIDL_LOCAL_APPDATA As Long = &H1C
Const CSIDL_ALTSTARTUP As Long = &H1D
Const CSIDL_COMMON_ALTSTARTUP As Long = &H1E
Const CSIDL_COMMON_FAVORITES As Long = &H1F
Const CSIDL_INTERNET_CACHE As Long = &H20
Const CSIDL_COOKIES As Long = &H21
Const CSIDL_HISTORY As Long = &H22
Const CSIDL_COMMON_APPDATA As Long = &H23
Const CSIDL_WINDOWS As Long = &H24
Const CSIDL_SYSTEM As Long = &H25
Const CSIDL_PROGRAM_FILES As Long = &H26
Const CSIDL_MYPICTURES As Long = &H27
Const CSIDL_PROFILE As Long = &H28
Const CSIDL_PROGRAM_FILES_COMMON As Long = &H2B
Const CSIDL_COMMON_TEMPLATES As Long = &H2D
Const CSIDL_COMMON_DOCUMENTS As Long = &H2E
Const CSIDL_COMMON_ADMINTOOLS As Long = &H2F
Const CSIDL_ADMINTOOLS As Long = &H30
Const CSIDL_CONNECTIONS As Long = &H31
Const CSIDL_COMMON_MUSIC As Long = &H35
Const CSIDL_COMMON_PICTURES As Long = &H36
Const CSIDL_COMMON_VIDEO As Long = &H37
Const CSIDL_RESOURCES As Long = &H38
Const CSIDL_RESOURCES_LOCALIZED As Long = &H39
Const CSIDL_COMMON_OEM_LINKS As Long = &H3A
Const CSIDL_CDBURN_AREA As Long = &H3B
Const CSIDL_COMPUTERSNEARME As Long = &H3D
Public Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
(ByVal pidl As Long, _
ByVal pszPath As String) _
As Long
Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, _
ByVal nFolder As Long, _
ByRef pidl As Long) _
As Long
Public Function GetSpecialFolder(ByVal CSIDL As Long) As String
Dim pidl As Long
Dim strPath As String
dim lngPos As Long
Dim csidltopidl As Long
If (csidl) Then
If SHGetSpecialFolderLocation(frmRef.hWnd, csidl, pidl) = 0 Then _
csidltopidl = pidl
Else
csidltopidl = 0&
End If
strPath = Space$(260)
If SHGetPathFromIDList(ByVal pidl, ByVal strPath) Then
lngPos = InStr(strPath, Chr$(0))
If (lngPos) Then _
GetSpecialWinFolder = Left$(strPath, lngPos - 1)
End If
End Function