Показать сообщение отдельно

  #2  
Старый 11.02.2010, 22:25
Dosia
Участник форума
Регистрация: 05.06.2009
Сообщений: 127
Провел на форуме:
1313455

Репутация: 249
По умолчанию

В модуль

Код:
Public Declare Function SHGetSpecialFolderLocation _
    Lib "shell32" (ByVal hWnd As Long, _
    ByVal nFolder As Long, ppidl As Long) As Long

Public Declare Function SHGetPathFromIDList _
    Lib "shell32" Alias "SHGetPathFromIDListA" _
    (ByVal Pidl As Long, ByVal pszPath As String) As Long

Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
    
Public Const MAX_PATH = 260
Public Const NOERROR = 0
Public Const CSIDL_APPDATA = &H1A

Public Function SpecFolder(ByVal lngFolder As Long) As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String

strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
If lngPidlFound = NOERROR Then
    lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
    If lngFolderFound Then
        SpecFolder = Left$(strPath, _
            InStr(1, strPath, vbNullChar) - 1)
    End If
End If
CoTaskMemFree lngPidl
End Function
Пример использования

Private Sub Form_Load()
MsgBox SpecFolder(CSIDL_APPDATA), vbInformation, ""
End Sub