Private 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 Sub Command1_Click()
Dim str As String
str = Space$(1000)
profilePath = App.Path & "ABC.INI"
a = GetPrivateProfileString("ROOT", "START", "", str, 1000, profilePath)
If a = 0 Then
MsgBox Left$(str, Len(Trim$(str)) - 1), vbInformation
Else
MsgBox "读取配置文件失败!", vbExclamation
End If
End Sub
------------------------------------------------------------------------
ACB.INI文件:
[ROOT]
START=2006-2-16 9:32:06
Dim str As String
str = Space$(1000)
profilePath = App.Path & "ABC.INI"
a = GetPrivateProfileString("ROOT", "START", "", str, 1000, profilePath)
If a = 0 Then
MsgBox Left$(str, Len(Trim$(str)) - 1), vbInformation
Else
MsgBox "读取配置文件失败!", vbExclamation
End If
End Sub
------------------------------------------------------------------------
ACB.INI文件:
[ROOT]
START=2006-2-16 9:32:06
解决方案 »
- 参数传递问题
- 如何用VB备份和还原XP的注册表
- 用Nullsoft安装软件时怎样注册控件啊
- 【请教】相对路径的问题,不会写,跪地求解!
- vb调用excel时,打印线的属性怎么设置(就是打印时将边框打印出来),行数随记录集在变
- Cnwanglin没分了
- 在VB中如何用低级读写将两个音频文件(.wav)合并成一个.wav文件?
- 列表框内容我点击显示出标签后我在点击就会覆盖了,怎么破?
- VB中能否使用函数指针?
- 如何使用terminalProcess这个API呀?各位大虾拜托啦!
- 请教split函数如何根据双引号进行拆分?
- 用Setup Factory v 7.0打包,在别的机器上安装出问题了,急啊!
function ReadINIFile
Dim X As Long X = GetPrivateProfileString(lpappname, lpKeyName, "~", temp, Len(temp), App.Path + "\Profile.ini")
ReadINIFile = Left(temp, InStr(temp, Chr(0)) - 1)
end function
function ReadINIFile
Dim X As Long
Dim temp As String * 128
X = GetPrivateProfileString(lpappname, lpKeyName, "~", temp, Len(temp), App.Path + "\Profile.ini")
ReadINIFile = Left(temp, InStr(temp, Chr(0)) - 1)
end function
按照你提供的代码,我改了我原来的,可是读取时提示失败啊!!Private 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 Sub Command2_Click()
Dim profilePath as String
Dim str As String * 128
profilePath = App.Path & "ABC.INI" a = GetPrivateProfileString("ROOT", "START", "~", str, Len(str), profilePath)
If a = 0 Then
MsgBox Left(str, InStr(str, Chr(0)) - 1), vbInformation
Else
MsgBox "读取配置文件失败!", vbExclamation
End If
End Sub