by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 18th January 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Get Shell Folders locations using SHGetSpecialFolderLocation API
API Declarations
SHItem As Long
itemID() As Byte
End Type
Private Type ITEMIDLIST
shellID As SHITEMID
End Type
Const DESKTOP = &H0
Const PROGRAMS = &H2
Const MYDOCS = &H5
Const FAVORITES = &H6
Const STARTUP = &H7
Const RECENT = &H8
Const SENDTO = &H9
Const STARTMENU = &HB
Const NETHOOD = &H13
Const FONTS = &H14
Const SHELLNEW = &H15
Const TEMPINETFILES = &H20
Const COOKIES = &H21
Const HISTORY = &H22
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
rval = SHGetSpecialFolderLocation(Me.hwnd, DESKTOP, myid)
If rval = 0 Then ' If success
rval = SHGetPathFromIDList(ByVal myid.shellID.SHItem, ByVal Path)
If rval Then ' If True
MsgBox Left(Path, InStr(Path, Chr(0)) - 1)
End If
End If
End
End Sub
No comments have been posted about Get Shell Folders locations using SHGetSpecialFolderLocation API. Why not be the first to post a comment about Get Shell Folders locations using SHGetSpecialFolderLocation API.