三度网教程:是一个免费提供流行视频软件教程、在线学习分享的学习平台!

在.net中读写INI文件 40Star(原作)

时间:2024/6/3作者:未知来源:三度网教程人气:


在.net中读写INI文件40Star(原作)

在.net中读写ini文件和Vb6中的做法是一致的,唯一注意的一点是Api声明中的Long型变量要改为int32类型在.net中

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
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strIni As String
strIni = New String(" ", 100)
GetPrivateProfileString("AppName", "KeyA", "", strIni, 100, "C:\a.ini")
WritePrivateProfileString("AppName", "KeyB", "MyValue", "C:\a.ini")
MsgBox(strIni)
End Sub

这段代码在.net + Win2000中调试通过

关键词:  在.net中读写INI文件        40Star(原作)





Copyright © 2012-2018 三度网教程(http://www.3du8.cn) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版