-
Notifications
You must be signed in to change notification settings - Fork 3
/
M_omAPISpecialFolders.def
48 lines (44 loc) · 1.07 KB
/
M_omAPISpecialFolders.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Option Compare Database
Option Explicit
Private Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hwnd As Long, ByVal nFolder As Long, Pidl As Long) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal Pidl As Long, ByVal folderPath As String) As Long
Enum SpecialFolderConst
sfAppData = 26
sfCDBurning = 59
sfCookies = 33
sfDesktop = 0
sfFavorites = 6
sfFonts = 20
sfHistory = 34
sfLocalAppData = 28
sfMyDocuments = 5
sfMyMusic = 13
sfMyPictures = 39
sfMyVideo = 14
sfNetHood = 19
sfPrintHood = 27
sfProfile = 40
sfProgramFiles = 38
sfRecent = 8
sfSendTo = 9
sfStartMenu = 11
sfStartMenuPrograms = 2
sfStartUp = 7
sfSystem = 37
sfTempInternet = 32
sfTemplates = 21
sfWindows = 36
End Enum
Public Function SpecialFolder(ByVal SFConst As SpecialFolderConst) As String
Dim Pidl As Long
Dim s As String * 260
Dim l As Long
l = SHGetSpecialFolderLocation(0, SFConst, Pidl)
If l = 0 Then
l = SHGetPathFromIDList(Pidl, s)
If l = 1 Then
s = Left(Trim(s), InStr(s, Chr(0)) - 1)
SpecialFolder = Trim(s)
End If
End If
End Function