VB6,把数据库配置文件写到INI文件
一个INI文件,是数据库连接的配置怎么样实现 读写INI文件,来连接数据库配置 --------------------编程问答-------------------- '写入INI文件
FileOpen(1, "C:\y.ini", OpenMode.Output)
PrintLine(1, "我是一个兵")
PrintLine(1, "来自老百姓")
。。。。
FileClose(1)
'读INI文件
Dim xC as string
FileOpen(1, "C:\y.ini", OpenMode.Input)
xc=lineinput(1)
。。。。
FileClose(1)
'还可以用 IO.StreamReader 和 IO.StreamWriter
--------------------编程问答-------------------- 楼上回答,好像不是在点上 --------------------编程问答-------------------- '这是读的。
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
'Public strFtpTargetPath As String = GetINI("FTP", "strFtpTargetPath", "", Pth)
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String '读ini
Dim Str As String = ""
Str = LSet(Str, 256)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
’这是写的。
Public Function WriteIniString(ByVal section As String, ByVal keystring As String, ByVal value1 As String) As Object
WritePrivateProfileString(section, keystring, value1, VB6.GetPath & "\HSMacro.ini")
WriteIniString = value1
End Function --------------------编程问答--------------------
‘还要加这个。
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
补充:.NET技术 , VB.NET