vb 2008使用GetPrivateProfile系列函数的问题
时间:2011-08-03
来源:互联网
本人新作工程 需要使用Ini文件的有关函数。调试过程中 发现 无论是GetPrivateProfileString还是GetPrivateProfileInt
如果文件名称设置为固定路径如“C:\Setting.ini”则读写Ini文件都没有问题。
一旦文件路径换成了相对路径,问题就来了:如文件路径为 My.Application.Info.DirectoryPath +"\Setting.Ini"。(该路径下存在该文件)。执行GetPrivateProfileSring(Int)后,就什么结果也不能返回。路径也被修改成My.Application.Info.DirectoryPath +"\Setting"。(后面的.Ini没有了)那位高手能帮忙分析一下哈?
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal SectionName As String, _
ByVal KeyName As String, ByVal Defaultstring As String, ByVal Value As String, ByVal Size As Integer, ByVal FileName As String) As Integer '在配置文件内读取字符串信息
Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
代码就不贴了。那位高手能帮忙分析一下哈?
如果文件名称设置为固定路径如“C:\Setting.ini”则读写Ini文件都没有问题。
一旦文件路径换成了相对路径,问题就来了:如文件路径为 My.Application.Info.DirectoryPath +"\Setting.Ini"。(该路径下存在该文件)。执行GetPrivateProfileSring(Int)后,就什么结果也不能返回。路径也被修改成My.Application.Info.DirectoryPath +"\Setting"。(后面的.Ini没有了)那位高手能帮忙分析一下哈?
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal SectionName As String, _
ByVal KeyName As String, ByVal Defaultstring As String, ByVal Value As String, ByVal Size As Integer, ByVal FileName As String) As Integer '在配置文件内读取字符串信息
Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
代码就不贴了。那位高手能帮忙分析一下哈?
作者: jintian01 发布时间: 2011-08-03
Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
GetPrivateProfileSring(GetShortPathName(My.Application.Info.DirectoryPath +"\Setting.Ini"))
GetPrivateProfileSring(GetShortPathName(My.Application.Info.DirectoryPath +"\Setting.Ini"))
作者: BestBadGod 发布时间: 2011-08-03
BestBadGod
刚才看了你给的函数作用后!我没有试验。因为该函数的作用是压缩文件的的路径。可是我的文件GetPrivateProfileInt(...,strFileName)‘时路径信息是完全正确的 而且首次可以执行。
只是首次执行过后,文件后面的".Ini"就莫名奇妙的丢失了。
刚才看了你给的函数作用后!我没有试验。因为该函数的作用是压缩文件的的路径。可是我的文件GetPrivateProfileInt(...,strFileName)‘时路径信息是完全正确的 而且首次可以执行。
只是首次执行过后,文件后面的".Ini"就莫名奇妙的丢失了。
作者: jintian01 发布时间: 2011-08-03
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28