GetPrivateProfileString "No2", "no2", "", getstr, 50, inipath
showstr = getstr + "\"
trimgetstr = Val(getstr)
Debug.Print showstr
Print trimgetstr
For i = 0 To trimgetstr Step 1
GetPrivateProfileString "folder", "foldername" & i, "", getstr2, 100, inipath
filedir = "h:\test\" + getstr2
Debug.Print filedir
MkDir filedir
DoEvents
Next i这段程序有问题吗?主要是看mkdir filedir那句,提示有问题,但是在该路径上又可以创建这个文件夹的
showstr = getstr + "\"
trimgetstr = Val(getstr)
Debug.Print showstr
Print trimgetstr
For i = 0 To trimgetstr Step 1
GetPrivateProfileString "folder", "foldername" & i, "", getstr2, 100, inipath
filedir = "h:\test\" + getstr2
Debug.Print filedir
MkDir filedir
DoEvents
Next i这段程序有问题吗?主要是看mkdir filedir那句,提示有问题,但是在该路径上又可以创建这个文件夹的
Debug.Print filedir
MkDir filedirmkdir只能一级一级的建立目录
请确定h:\test\已经存在
????我是说h:\test存在啊,可是下级目录是我要创建的,我在想是不是一开始定义
getstr2的时候这样有问题的,dim getstr2 as string*100这样的话,如果用trim函数就没有作用了是不是?
'********************************************************************************
'* 模块名称:mdlInIFile
'* 功能描述:处理配置文件模块
'* 设 计:阿九
'* 作 者:阿九
'********************************************************************************Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As LongPrivate Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As LongPrivate Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long, _
ByVal lpFileName As String) As LongPrivate Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, _
ByVal lpString As Any, _
ByVal lpFileName As String) As Long
'********************************************************************************
'** 函数功能:从ini配置文件中读取指定段名、关键字名的值
'** 调用语法: GetInIKeyValue(SectionName as string,KeyName As String,FileName As String)
'** 参数说明:
'** SectionName :段名
'** KeyName :关键字名
'** FileName :ini文件名包括路径
'** 返 回 值:
'** String :返回关键字值
'** 处理说明:
'** 调用API函数GetPrivateProfileString
'******************************************************************************
Public Function GetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal FileName As String) As String
Dim KeyValue$
Dim strTmp As String
KeyValue$ = String$(512, " ")
GetPrivateProfileString SectionName, KeyName, "", KeyValue$, 512, FileName
strTmp = Trim(KeyValue$)
GetInIKeyValue = Left(strTmp, Len(strTmp) - 1)
End Function'********************************************************************************
'** 函数功能:从ini配置文件中写入指定段名、关键字名及值
'** 调用语法: SetInIKeyValue(SectionName as string,KeyName As String,KeyValue as string ,FileName As String)
'** 参数说明:
'** SectionName :段名
'** KeyName :关键字名
'** KeyValue :关键字值
'** FileName :ini文件名包括路径
'** 返 回 值:
'** 处理说明:
'** 调用API函数WritePrivateProfileString
'******************************************************************************
Public Sub SetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal KeyValue As String, _
ByVal FileName As String)
Dim lng As Long
lng = WritePrivateProfileString(SectionName, KeyName, KeyValue, FileName)
End Sub'********************************************************************************
'** 函数功能:读取系统目录路径
'** 调用语法: GetSysDir()
'** 参数说明:
'** 返 回 值:
'** String :系统目录
'** 处理说明:
'** 调用API函数GetSystemDirectory
'******************************************************************************
Public Function GetSysDir() As String
Dim sysDir$
Dim strTmp As String
sysDir = String$(128, " ")
GetSystemDirectory sysDir$, 127
strTmp = Trim(sysDir$)
GetSysDir = Left(strTmp, Len(strTmp) - 1)
End Function