vb.net创建ini vbnet lib

【vb.net】求个用VS2013读写INI的代码vb.net有自己的设置,不需要ini,在工程【属性】-【设置】中设置 。
——————
ini设置属性 。
'声明API函数
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 WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
Return WritePrivateProfileString(Section, AppName, lpDefault, FileName)
End Function
‘调用writeini函数存储属性 。
‘section为节点,也就是ini中带[]符号的节点文本
’APPname为存储的名称,即ini文件中等于符号前面的文本
’ipdefault为存储的属性,即等于符号右边的文本 。
‘filename为存储的ini文件地址,如d:\save.ini
————————
ini返回属性 。
'声明API函数
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 Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
Dim Str As String = ""
Str = LSet(Str, IniCount)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
’调用getini函数
‘说明同上 。
VB中配置文件怎么用vb读写ini 这个方法在vb.net自带都有 你可以在vb.net创建一个ini 在.net叫config主要方法 思想和 读写 .txt文件一样对字符串操作 。
vb.net如何在D盘新建一个test.ini文件呢?'创建一个文本文件,把文本框里vb.net创建ini的文字写入到该文件vb.net创建ini , 当然vb.net创建ini , vb.net创建ini你可以使用一个字符串变量
Dim MyStream As New System.IO.FileStream("D:\test.ini", System.IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.Default)
MyWriter.WriteLine(TextBox1.Text)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
求大神指点 vb.net 怎么读 ini 配置呢VB.NET读写INI配置文件
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String
path = Application.StartupPath"\Send.ini"
TextBox1.Text = GetINI("Send", "Send1", "", path)
TextBox2.Text = GetINI("Send", "Send2", "", path)
Dim IsSms As Integer = GetINI("Send", "IsSms", "", path)
If (IsSms = 1) Then
Me.RadioButton1.Checked = True
ElseIf (IsSms = 0) Then
Me.RadioButton2.Checked = True
End If
End Sub
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 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
【vb.net创建ini vbnet lib】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"\Send.ini"
WriteINI("Send", "Send1", TextBox1.Text, path)
WriteINI("Send", "Send2", TextBox2.Text, path)
If (Me.RadioButton1.Checked = True) Then
WriteINI("Send", "IsSms", 1, path)
ElseIf (Me.RadioButton2.Checked = True) Then
WriteINI("Send", "IsSms", 0, path)
End If
MsgBox("配置设置已经成功?。。。?)
Catch ex As Exception
MsgBox("错误?。。。?)
End Try
End Sub
vb.net创建ini的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet lib、vb.net创建ini的信息别忘了在本站进行查找喔 。

    推荐阅读