توابع API :
CreateFile
CreateDirectory
اول كه declare ميكنم و بعد در برنامه فراخوانيش ميكنم اين error رو ميده:
User-define type not define
Printable View
توابع API :
CreateFile
CreateDirectory
اول كه declare ميكنم و بعد در برنامه فراخوانيش ميكنم اين error رو ميده:
User-define type not define
دوست عزیز شما باید SECURITY_ATTRIBUTES را نیز در برنامه تعریف بکنید :
کد:Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type
Private Declare Function CreateDirectory Lib "kernel32" Alias "CreateDirectoryA" (ByVal lpPathName As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long
Public Sub CreateNewDirectory(NewDirectory As String)
Dim sDirTest As String
Dim SecAttrib As SECURITY_ATTRIBUTES
Dim bSuccess As Boolean
Dim sPath As String
Dim iCounter As Integer
Dim sTempDir As String
iFlag = 0
sPath = NewDirectory
If Right(sPath, Len(sPath)) <> "\" Then
sPath = sPath & "\"
End If
iCounter = 1
Do Until InStr(iCounter, sPath, "\") = 0
iCounter = InStr(iCounter, sPath, "\")
sTempDir = Left(sPath, iCounter)
sDirTest = Dir(sTempDir)
iCounter = iCounter + 1
SecAttrib.lpSecurityDescriptor = &O0
SecAttrib.bInheritHandle = False
SecAttrib.nLength = Len(SecAttrib)
bSuccess = CreateDirectory(sTempDir, SecAttrib)
Loop
End Sub
Private Sub Command1_Click()
Call CreateNewDirectory("c:\test")
End Sub
ممنون ولي خيلي وقته ديگه بلد شدم