Attribute VB_Name = "mod_MkDirEx"
' Modul for Visual Basic 6
' Copyright (C) 2003-2006 Jan Vorel
'
' This program is free software; you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation; either version 2 of the License, or
' (at your option) any later version.

' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.

' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

' This is a shared modul, class modul, usercontrol or form. It is also
' published under the GNU General Public License.

' If you have any questions, suggestions or bug reports about this product,
' contact me: info@ctuser.net; Do not contact me about general B.A.S.I.C.
' language or A.P.I. issues

Option Explicit
Option Base 0

Private Declare Function CreateDirectoryA Lib "kernel32" (ByVal lpPathName As String, lpSecurityAttributes As Any) As Long

Public Function MkDirEx(ByVal FullPath As String, ByVal AddUninst As Boolean) As Boolean
Dim xChar1 As String
Dim xLong1 As Long

xLong1 = InStr(FullPath, "\")
If Not xLong1 = 0& Then
  FullPath = FullPath & "\"
  xChar1 = Left(FullPath, xLong1 - 1&)
  FullPath = Mid(FullPath, xLong1 + 1&)
  On Error Resume Next
  Do
    xLong1 = InStr(FullPath, "\")
    If xLong1 = 0& Then
      Exit Do
      Else
      xChar1 = xChar1 & "\" & Left(FullPath, xLong1 - 1&)
      Call CreateDirectoryA(xChar1, ByVal 0&)
      'MkDir xChar1
      FullPath = Mid(FullPath, xLong1 + 1&)
      End If
    Loop
  MkDirEx = ((GetAttr(xChar1) And 16&) = 16&)
  On Error GoTo 0
  End If
End Function

