Public Enum CSIDL_LIST
CSIDL_DESKTOP& = &H0
CSIDL_PROGRAMS& = &H2
CSIDL_PROGRAM_FILES& = &H26
CSIDL_CONTROLS& = &H3
CSIDL_PRINTERS& = &H4
CSIDL_PERSONAL& = &H5
CSIDL_FAVORITES& = &H6
CSIDL_STARTUP& = &H7
CSIDL_RECENT& = &H8
CSIDL_SENDTO& = &H9
CSIDL_BITBUCKET& = &HA
CSIDL_STARTMENU& = &HB
CSIDL_DESKTOPDIRECTORY& = &H10
CSIDL_DRIVES& = &H11
CSIDL_NETWORK& = &H12
CSIDL_NETHOOD& = &H13
CSIDL_FONTS& = &H14
CSIDL_TEMPLATES& = &H15
End Enum
Public Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hWndOwner As Long, ByVal nFolder As Long, pidl As Long) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Function GetSpecialPath(CSIDL As CSIDL_LIST) As String
Dim Path As String
Dim pidl As Long
If SHGetSpecialFolderLocation(0, CSIDL, pidl) = 0 Then
Path = Space$(512)
Call SHGetPathFromIDList(ByVal pidl, ByVal Path)
GetSpecialPath = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialPath = ""
End Function
'폼
Private Sub Form_Load()
MsgBox GetSpecialPath(CSIDL_DESKTOP)
End Sub