本篇文章给大家分享的是有关VB.NET中怎么访问INI文件,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
10年的邢台县网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整邢台县建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联公司从事“邢台县网站设计”,“邢台县网站推广”以来,每个客户项目都认真落实执行。
在VB.NET2005+winxp中,我使用GetPrivateProfileString实现VB.NET访问INI文件这一功能,如果文件路径中含有中文,就会遇到一个奇怪的问题:***次读取正常,第二次读取就取不到值
VB.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 Integer, ByVal lpFileName As String) As IntegerPrivate m_filename As String =
"c:\椅子\slcuserinfo.INI"Public Function GetINIValue(ByVal lpKeyName
As String, ByVal strName As String) As StringDim strTmp As String
'Dim fileTmp As String
'fileTmp = m_filename
strTmp = New String(" ", 100)
'Call GetPrivateProfileString(lpKeyName,
strName, "", strTmp, Len(strTmp), fileTmp)Call GetPrivateProfileString(lpKeyName,
strName, "", strTmp, Len(strTmp), m_filename)GetINIValue = Left$(strTmp, InStr(strTmp,
vbNullChar) - 1)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 Integer, ByVal lpFileName As String) As IntegerPrivate m_filename As String = "c:\椅子\
slcuserinfo.INI"Public Function GetINIValue(ByVal lpKeyName
As String, ByVal strName As String) As StringDim strTmp As String
'Dim fileTmp As String
'fileTmp = m_filename
strTmp = New String(" ", 100)
'Call GetPrivateProfileString(lpKeyName,
strName, "", strTmp, Len(strTmp), fileTmp)Call GetPrivateProfileString(lpKeyName,
strName, "", strTmp, Len(strTmp), m_filename)GetINIValue = Left$(strTmp, InStr(strTmp,
vbNullChar) - 1)End Function
以上就是VB.NET中怎么访问INI文件,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。
文章题目:VB.NET中怎么访问INI文件
网页URL:http://lswzjz.com/article/iicgpd.html