by Richard Chute (added to Karthikeyan's) ()
Category: Windows API Call/Explanation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Sun 28th July 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Get Shell Folders locations using SHGetSpecialFolderLocation API. Updates include personal folders like Application Data, All Users folders,
API Declarations
' Updates by Richard Chute
' Intended for use in a module
Private Type SHITEMID
SHItem As Long
itemID() As Byte
End Type
Private Type ITEMIDLIST
shellID As SHITEMID
End Type
Const SF_DESKTOP = &H0
Const SF_PROGRAMS = &H2
Const SF_MYDOCS = &H5
Const SF_FAVORITES = &H6 ' 98+
Const SF_STARTUP = &H7
Const SF_RECENT = &H8
Const SF_SENDTO = &H9
Const SF_STARTMENU = &HB
Const SF_MYMUSIC = &HD ' Me+
Const SF_DESKTOP2 = &H10
Const SF_NETHOOD = &H13
Const SF_FONTS = &H14
Const SF_SHELLNEW = &H15
Const SF_STARTUP2 = &H18
Const SF_ALLUSERSDESK = &H19
Const SF_APPDATA = &H1A
Const SF_PRINTHOOD = &H1B
Const SF_APPDATA2 = &H1C
Const SF_TEMPINETFILES = &H20
Const SF_COOKIES = &H21
Const SF_HISTORY = &H22
Const SF_ALLUSERSAPPDATA = &H23
Const SF_WINDOWS = &H24
Const SF_WINSYSTEM = &H25
Const SF_PROGFILES = &H26
Const SF_MYPICS = &H27 ' Me+
Const SF_USERDIR = &H28
Const SF_WINSYSTEM2 = &H29
Const SF_COMMON = &H2B
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwnd As Long, ByVal folderid As Long, shidl As ITEMIDLIST) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal shidl As Long, ByVal shPath As String) As Long
Dim Path As String * 256
Dim myid As ITEMIDLIST
Dim rval As Long
'Get desktop path
If IsMissing(useForm) Then
rval = SHGetSpecialFolderLocation(Form1.hwnd, whichFolder, myid)
Else
rval = SHGetSpecialFolderLocation(useForm.hwnd, whichFolder, myid)
End If
If rval = 0 Then ' If success
rval = SHGetPathFromIDList(ByVal myid.shellID.SHItem, ByVal Path)
If rval Then ' If True
getSpecialFolder = Left(Path, InStr(Path, Chr(0)) - 1)
End If
End If
End Function
No comments have been posted about Get Shell Folders locations using SHGetSpecialFolderLocation API. Updates include personal folders . Why not be the first to post a comment about Get Shell Folders locations using SHGetSpecialFolderLocation API. Updates include personal folders .