Zurück zur Homepage

Sonderverzeichnisse

Spezialverzeichnisse, wie den Pfad zum Desktop, liefert diese Funktionen.

Beispieldatei (Spezialverzeichnisse.zip 12 kB)

Private Declare Function SHGetSpecialFolderLocation2lng _
  Lib "shell32.dll" Alias "SHGetSpecialFolderLocation" _
  (ByVal hwndOwner As Long, _
  ByVal nFolder As Long, _
  pidl As DummyStruct) _
  As Long

Private Declare Function SHGetPathFromIDList _
  Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
  (ByVal pidl As Long, _
  ByVal pszPath As String) _
  As Long

 Private Type DummyStruct
  cb As Long
  id As Long
End Type

'Private Const CSIDL_COMMON_APPDATA = &H23
Private Const CSIDL_COMMON_DESKTOPDIRECTORY = &H19
'Private Const CSIDL_COMMON_DOCUMENTS = &H2E
'Private Const CSIDL_COMMON_FAVORITES = &H1F
Private Const CSIDL_COMMON_STARTMENU = &H16
Private Const CSIDL_COMMON_STARTUP = &H18
'Private Const CSIDL_COMMON_TEMPLATES = &H2D
'Private Const CSIDL_CONTROLS = &H3
'Private Const CSIDL_COOKIES = &H21
Private Const CSIDL_DESKTOPDIRECTORY = &H10
'Private Const CSIDL_DRIVES = &H11
Private Const CSIDL_FAVORITES = &H6
Private Const CSIDL_FONTS = &H14
'Private Const CSIDL_HISTORY = &H22
'Private Const CSIDL_INTERNET = &H1
'Private Const CSIDL_INTERNET_CACHE = &H20
'Private Const CSIDL_MYPICTURES = &H27
Private Const CSIDL_NETHOOD = &H13
Private Const CSIDL_PERSONAL = &H5
'Private Const CSIDL_PRINTERS = &H4
Private Const CSIDL_PRINTHOOD = &H1B
'Private Const CSIDL_PROFILE = &H28
'Private Const CSIDL_PROGRAM_FILES = &H26
'Private Const CSIDL_PROGRAM_FILES_COMMON = &H2B
Private Const CSIDL_PROGRAM_FILES_COMMONX86 = &H2C
'Private Const CSIDL_PROGRAM_FILESX86 = &H2A
Private Const CSIDL_PROGRAMS = &H2
Private Const CSIDL_RECENT = &H8
Private Const CSIDL_SENDTO = &H9
Private Const CSIDL_STARTMENU = &HB
Private Const CSIDL_STARTUP = &H7
Private Const MAX_PATH = 260

Public Function Autostart_User_SF() As String
  Autostart_User_SF = Spezialverzeichnis(CSIDL_STARTUP)
  End Function

Public Function Startmenü_User_SF() As String
  Startmenü_User_SF = Spezialverzeichnis(CSIDL_STARTMENU)
  End Function

Public Function SendTo_User_SF() As String
  SendTo_User_SF = Spezialverzeichnis(CSIDL_SENDTO)
  End Function

Public Function Recent_User_SF() As String
  Recent_User_SF = Spezialverzeichnis(CSIDL_RECENT)
End Function

 Public Function Programme_User_SF() As String
  Programme_User_SF = Spezialverzeichnis(CSIDL_PROGRAMS)
End Function

Public Function Druckumgebung_User_SF() As String
  Druckumgebung_User_SF = Spezialverzeichnis(CSIDL_PRINTHOOD)
End Function

Public Function EigeneDateien_User_SF() As String
  EigeneDateien_User_SF = Spezialverzeichnis(CSIDL_PERSONAL)
End Function

Public Function Netzwerkumgebung_User_SF() As String
  Netzwerkumgebung_User_SF = Spezialverzeichnis(CSIDL_NETHOOD)
End Function

Public Function Font_SF() As String
  Font_SF = Spezialverzeichnis(CSIDL_FONTS)
End Function

 Public Function Favoriten_User_SF() As String
  Favoriten_User_SF = Spezialverzeichnis(CSIDL_FAVORITES)
End Function

Public Function Desktopdirectory_User_SF() As String
  Desktopdirectory_User_SF = Spezialverzeichnis(CSIDL_DESKTOPDIRECTORY)
End Function

Public Function Autostart_All_SF() As String
  Autostart_All_SF = Spezialverzeichnis(CSIDL_COMMON_STARTUP)
End Function

Public Function Startmenü_All_SF() As String
  Startmenü_All_SF = Spezialverzeichnis(CSIDL_COMMON_STARTMENU)
End Function

Public Function Desktopdirectory_All_SF() As String
  Desktopdirectory_All_SF = Spezialverzeichnis(CSIDL_COMMON_DESKTOPDIRECTORY)
End Function

Private Function Spezialverzeichnis(Verzeichnis As Long) As String
  Dim strPfad As String, a As DummyStruct
  SHGetSpecialFolderLocation2lng 0&, Verzeichnis, a
  strPfad = String(MAX_PATH, 0)
  SHGetPathFromIDList ByVal a.cb, ByVal strPfad
  Spezialverzeichnis = Left$(strPfad, InStr(strPfad, Chr$(0)) - 1)
End Function