利用API创建文件目录-钱玉炜
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-模块/函数/VBA


利用API创建文件目录

发表时间:2008/5/19 8:17:56 评论(0) 浏览(5982)  评论 | 加入收藏 | 复制
   
摘 要:利用API创建文件目录
正 文:
利用API创建文件目录


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


Private Type SECURITY_ATTRIBUTES

nLength As Long

lpSecurityDescriptor As Long

bInheritHandle As Long

End Type


Sub Main()

\'在C盘创建了"VB编程乐园"目录

Call CreateNewDirectory("C:\\VB编程乐园")

MsgBox "在C盘创建了 VB编程乐园 目录"

End Sub


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

Dim iFlag As Integer

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

Access软件网交流QQ群(群号:198465573)
 
 相关文章
API捕获鼠标在屏幕的任意位置  【纵云梯  2012/5/3】
VB API使用手册  【叶海峰  2012/5/11】
API函数参考手册_VB_API函数大全  【ihcn  2012/8/4】
API操作任务栏  【叶海峰  2012/9/13】
常见问答
技术分类
相关资源
文章搜索
关于作者

钱玉炜

文章分类

文章存档

友情链接