vb.net 读写ini文件

vb.net 读写ini文件,第1张

概述'********************************* '****INIファイル *** 作クラス******** '********************************* Public Class INIOper     '[PATH]     'TempPath=C:\Temp\Temp.pdf     '[XXXX]     'xxxxPath=C:\Temp\xxx.xl @H_502_0@'*********************************
'****INIファイル *** 作クラス********
'*********************************
Public Class INIOper


'[PATH]
'TempPath=C:\Temp\Temp.pdf
'[XXXX]
'xxxxPath=C:\Temp\xxx.xls



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 lpString As String,ByVal lpfilename As String) As Int32


'Ini Keyを読み込む
Public Shared Function Getini(ByVal Section As String,ByVal Appname As String) As String
Dim Str As String = LSet(Str,256)
GetPrivateProfileString(Section,Appname,"",Str,Len(Str),System.windows.Forms.Application.StartupPath + "\\Health.ini")
Return Microsoft.VisualBasic.left(Str,InStr(Str,Chr(0)) - 1)
End Function


'Iniファイルに書く
Public Shared Function WriteINI(ByVal sectionname As String,ByVal keyname As String,ByVal setValue As String) As Integer
Dim rc As Integer

@H_502_0@ rc = WritePrivateProfileString(sectionname,keyname,setValue,System.windows.Forms.Application.StartupPath + "\\Health.ini")

@H_502_0@ If rc Then
'ok
rc = 1
Else
rc = 0
End If
End Function


End Class

@H_502_0@●呼び出し方法:

@H_502_0@Private fn As String = INIOper.Getini("PATH","TempPath")

 总结

以上是内存溢出为你收集整理的vb.net 读写ini文件全部内容,希望文章能够帮你解决vb.net 读写ini文件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1267847.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存