Option Explicit
Option Private Module
' ---------------------------------------------------------
' Funktion myDrives
' Eingestellt von: Andre Schau
' Datum: 2011-09-10
' Kommentar:
' Parameter: Pfad
' Rückgabe: Erfolg = 1, ansonsten 0
' Aufruf:
' Sub Call_CreatePath()
' CreatePath "D:\Test\Ordner1\O2"
' End Sub
' Hinweis: durch die Kürze sollte die Funktion direkt im Sub
' integriert werden
' Beachte: Pfadeangabe wird interpretiert bis zum letzten
' Backslash - die Zeichenfolge nach dem letzten Backslash
' wird als Datei interpretiert!
' d.h. bei "D:\Test\Ordner1\O2" erfolgt die
' Anlage des kompletten Pfades bis D:\Test\Ordner1\

'API-Deklaration
Declare Function MakePath Lib "imagehlp.dll" Alias _
       "MakeSureDirectoryPathExists" (ByVal lpPath As StringAs Long

'Aufruf
Sub CreatePath_()
'Variablendeklaration
'String
Dim strPath$
strPath = "D:\Test\Ordner1\O2"
If CreatePath(strPath) = 0 Then
  MsgBox "Pfad konnte nicht angelegt werden."
Else
  MsgBox "Pfad wurde erfolgreich angelegt."
End If
End Sub

Function CreatePath(ByVal strPath As StringAs Long
 'API-Parameter Pfad, Anlage bis zum letzten Backslash
 'Rueckgabewert zuweisen
 CreatePath = MakePath(strPath)
End Function