| 网站首页 | 新闻 | 新书 | 专家 | 技巧 | 源码作品 | 工具/资源 | 商城 | 风采 | 留言 | 论坛 | 网址 | 承接 | 
您现在的位置: Access/Office中国 >> 技巧 >> Access >> API >> 文章正文 用户登录 新用户注册
利用API创建文件目录         ★★★
利用API创建文件目录
作者:朱亦文 文章来源:Access开发者 点击数: 本日:{$DayHits} 更新时间:2006-11-23 23:23:39
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盘创建了"accessbbs"目录
Call CreateNewDirectory("C:\accessbbs")
MsgBox "在C盘创建了 accessbbs 目录"
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

文章录入:tm    责任编辑:tm 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    专 题 栏 目
    最 新 热 门
    最 新 推 荐
    相 关 文 章
    快速读取 TextBox 第 N 
    利用API函数实现特殊窗体
    API改变主窗口背景
    API中VB字符串作参数传递
    Windows API 函数 for V
    再发一篇关于通过API利用
    在子窗体中预览报表
    如何利用API实现代码延时
    API实现的延时函数
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)