.ini 中的信息怎么才能让控件上面得到显示
我有一个commad控件数组和一个.ini 文件 我希望command 控件上面(比如caption等等)能够得到我.ini 文件上面得到信息.并且可以执行.ini 文件中这些command 控件相对应的.exe 请问用vb 如何完成thanks
my email:sunjun812163.net ( 最好有方法或原代码)
问题点数:25、回复次数:2Top
1 楼Richard2001(Richard)回复于 2001-04-17 13:27:00 得分 0
用API函数GetPrivateProfileString()获取.ini文件中的信息进行处理,用
Shell() 函数执行.exe文件。
Top
2 楼T2(無藥可救)回复于 2001-04-17 13:39:00 得分 25
Public 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 Long
Public 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
Public Function g_GetIniString(ByVal f_strKey As String, _
ByVal f_strSubKey As String, _
ByVal f_strIniFileName As String) As String
On Error GoTo ErrExit
Dim strTemp As String * 144
Dim nRetCode As Long
Dim strWinDir As String
'the following series of the API function call "GetPrivateProfileString"
'retrieves info from the user's .ini file ---this file originally
'had its values set by the setup program for that module
nRetCode = GetPrivateProfileString(f_strKey, f_strSubKey, Space(144), strTemp, 144, f_strIniFileName)
g_GetIniString = Left(strTemp, InStr(strTemp, Chr$(0)) - 1)
ErrExit:
End Function
Public Function g_WriteIniString(ByVal f_strKey As String, ByVal f_strSubKey As String, _
ByVal f_strValue As Variant, ByVal f_strIniFile As String) As String
On Error GoTo ErrExit
Dim i As Integer
Dim strTemp As String
Dim n As Long
strTemp = f_strValue
For i = 1 To Len(f_strValue) Step 1
If Mid$(f_strValue, i, 1) = vbCr Or Mid$(f_strValue, i, 1) = vbLf Then Mid$(f_strValue, i) = ""
Next
n = WritePrivateProfileString(f_strKey, f_strSubKey, strTemp, f_strIniFile)
ErrExit:
g_WriteIniString = Err.Description
End Function
Top




