VB6,把数据库配置文件写到INI文件

qcxht 2012-08-21 09:18:24
一个INI文件,是数据库连接的配置

怎么样实现 读写INI文件,来连接数据库配置
...全文
110 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
大东哥哥的爹 2012-08-26
  • 打赏
  • 举报
回复

‘还要加这个。
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
大东哥哥的爹 2012-08-26
  • 打赏
  • 举报
回复
'这是读的。

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
waynexjw828 2012-08-25
  • 打赏
  • 举报
回复
楼上回答,好像不是在点上
hzybc 2012-08-23
  • 打赏
  • 举报
回复
'写入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



16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧