点击这里给我发消息

我的ITblog我作主  关注→ 『伊波拉』→ 测试 SzDlinXie- ITblog     

·√· 本ITblog站点记录相关的软件技术文档、网络技术杂志、测试技术杂谈等技术文档的管理站点.联系方式:MSN:dowling@sunlike.cn QQ:94595885

导航

<2025年4月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

留言簿(5)

随笔分类

文章分类

随笔档案

文章档案

阅读排行榜

评论排行榜

统计

积分与排名

测试技术网站链接

最新评论

.net读写INI文件的函数

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

    Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
        Dim Str As String = 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 WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
        WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName)
    End Function


写:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
        Dim path As String
        path = Application.StartupPath + "\文件名.ini"
        WriteINI("aa", "a1", 内容, path)
            
        Catch ex As Exception
            
        End Try
    End Sub

读:
Dim path As String
        path = Application.StartupPath + "\文件名.ini"
        textbox.Text = GetINI("aa", "a1", "", path)


posted on 2008-12-31 14:10 szdlinxie 阅读(297) 评论(0)  编辑 收藏 引用 所属分类: 电脑技术杂志数据库信息资料操作系统技术杂谈

只有注册用户登录后才能发表评论。
点击这里给我发消息