|
(рабочий стол, папка шрифтов, меню кнопки ПУСК и
т.д)
Добавьте на форму элемент CommandButton. Необходимое
пояснение: изменяя значение аргумента speFolder
функции GetSpecFolder() на любой аргумент инструкции Enum
SpecialFolderIDs вы получите путь к папке, заданной
аргументом speFolder. В событии Command1_Click()
показана пара примеров с различным аргументом speFolder. Private Enum SpecialFolderIDs
sfidDESKTOP = &H0 'рабочий стол
sfidPROGRAMS = &H2
sfidPERSONAL = &H5
sfidFAVORITES = &H6
sfidSTARTUP = &H7
sfidRECENT = &H8
sfidSENDTO = &H9
sfidSTARTMENU = &HB
sfidDESKTOPDIRECTORY = &H10
sfidNETHOOD = &H13
sfidFONTS = &H14
sfidTEMPLATES = &H15
sfidCOMMON_STARTMENU = &H16
sfidCOMMON_PROGRAMS = &H17
sfidCOMMON_STARTUP = &H18
sfidCOMMON_DESKTOPDIRECTORY = &H19
sfidAPPDATA = &H1A
sfidPRINTHOOD = &H1B
sfidProgramFiles = &H10000
sfidCommonFiles = &H10001
End Enum
Private Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal
hwndOwner As Long, ByVal nFolder As SpecialFolderIDs, ByRef pIdl As Long) As Long
Private Declare Function SHGetPathFromIDListA Lib "shell32" (ByVal pIdl As Long,
ByVal pszPath As String) As Long
Const NOERROR = 0
Dim sPath As String
Dim IDL As Long
Dim strPath As String
Dim lngPos As Long
Private Function GetSpecFolder(speFolder As SpecialFolderIDs)
If SHGetSpecialFolderLocation(0, speFolder, IDL) = NOERROR Then
sPath = String$(255, 0)
SHGetPathFromIDListA IDL, sPath
lngPos = InStr(sPath, Chr(0))
If lngPos > 0 Then
GetSpecFolder = Left$(sPath, lngPos - 1)
End If
End If
End Function
Private Sub Command1_Click()
MsgBox GetSpecFolder(sfidFAVORITES)
MsgBox GetSpecFolder(sfidPROGRAMS)
End Sub
|
|