利用API创建文件目录
PrivateDeclareFunctionCreateDirectoryLib"kernel32"Alias"CreateDirectoryA"(ByVallpPathNameAsString,lpSecurityAttributesAsSECURITY_ATTRIBUTES)AsLong
PrivateTypeSECURITY_ATTRIBUTES
nLengthAsLong
lpSecurityDescriptorAsLong
bInheritHandleAsLong
EndType
SubMain()
'在C盘创建了"VB编程乐园"目录
CallCreateNewDirectory("C:\VB编程乐园")
MsgBox"在C盘创建了VB编程乐园目录"
EndSub
PublicSubCreateNewDirectory(NewDirectoryAsString)
DimsDirTestAsString
DimSecAttribAsSECURITY_ATTRIBUTES
DimbSuccessAsBoolean
DimsPathAsString
DimiCounterAsInteger
DimsTempDirAsString
DimiFlagAsInteger
iFlag=0
sPath=NewDirectory
IfRight(sPath,Len(sPath))<>"\"Then
sPath=sPath&"\"
EndIf
iCounter=1
DoUntilInStr(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
EndSub
- 最新文章
- 怎样用VB在应用程序中调用API[04-17]
- VB中访问API函数之防错技巧[04-17]
- 如何提高调用WindowAPI函数编程技巧[04-17]
- 在VB中建立可旋转的文本特效[04-17]
- VB中实现同一窗口的多个实例及控件的动态增减[04-17]
- 利用子类处理技术限制窗体的大小[04-17]
- 相关文章
