有没有对.inf文件操作的函数??

谁为谁狂 2004-07-27 09:50:59
只找到VB对.ini文件操作的函数,请问没有对.inf文件操作的函数呢?
...全文
216 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
goj2000 2004-08-12
  • 打赏
  • 举报
回复
一个绝对经典的在VB中操作.ini文件的通用类... (goj2000原创)

http://www.csdn.net/Develop/read_article.asp?id=23780
rainstormmaster 2004-08-12
  • 打赏
  • 举报
回复
//对,没错!操作INI文件的函数也是一样可以操作.inf文件的!

错了,二者的文件格式是有区别的
可以用读写文本文件的方法读写
doudoushen 2004-08-12
  • 打赏
  • 举报
回复
setupgetlinetext
setupgetintfield
zcm123 2004-08-12
  • 打赏
  • 举报
回复

'/对ini文件进行读写操作

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Private Declare Function GetFullPathName Lib "kernel32" Alias "GetFullPathNameA" (ByVal lpFileName As String, ByVal nBufferLength As Long, ByVal lpBuffer As String, ByVal lpFilePart As String) As Long
Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long

Function ReadIni(AppName As String, KeyName As String, FileName As String) '/读取非系统ini
Dim Ret As String
Dim NC As Integer
Ret = String(1024, 0)
NC = GetPrivateProfileString(AppName, KeyName, "", Ret, 1024, FileName)
If NC <> 0 Then Ret = Left$(Ret, Len(Ret) - 1024 + NC) Else Ret = ""
ReadIni = Ret
End Function

Function WriteIni(AppName As String, KeyName As String, lpString As String, FileName As String) '/写入非系统ini
WritePrivateProfileString AppName, KeyName, lpString, FileName
End Function

Function ReadSystemIni(AppName As String, KeyName As String) '/读取系统ini
Dim Ret As String
Dim NC As Integer
Ret = String(1024, 0)
NC = GetProfileString(AppName, KeyName, "", Ret, 1024)
If NC <> 0 Then Ret = Left$(Ret, Len(Ret) - 1024 + NC) Else Ret = ""
ReadSystemIni = Ret
End Function

Function WriteSystemIni(AppName As String, KeyName As String, lpString As String) '/写系统ini
WriteProfileString AppName, KeyName, lpString
End Function

Function SystemPath() As String '/获得系统路径
Dim SystemDirectory As String
Dim X As Long
SystemDirectory = String(1024, 0)
X = GetSystemDirectory(SystemDirectory, 1024)
SystemPath = Left$(SystemDirectory, Len(SystemDirectory) - 1024 + X)
End Function

Function WindowsPath() As String '/获得windows路径
Dim WindowsDirectory As String
Dim X As Long
WindowsDirectory = String(1024, 0)
X = GetWindowsDirectory(WindowsDirectory, 1024)
WindowsPath = Left$(WindowsDirectory, Len(WindowsDirectory) - 1024 + X)
End Function

Function TempPath() As String '/获得临时文件路径
Dim TempDirectory As String
Dim X As Long
TempDirectory = String(1024, 0)
X = GetTempPath(1024, TempDirectory)
TempPath = Left$(TempDirectory, Len(TempDirectory) - 1024 + X)
End Function



SafeF8 2004-08-12
  • 打赏
  • 举报
回复
对,没错!操作INI文件的函数也是一样可以操作.inf文件的!
gdami 2004-07-28
  • 打赏
  • 举报
回复
一样的操作吧。只是后缀不一样而已。
liuyan4794 2004-07-28
  • 打赏
  • 举报
回复
API函数:
Private Declare Function GetPrivateProfileString Lib "kernel32.dll" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32.dll" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
xao7n 2004-07-28
  • 打赏
  • 举报
回复
当作文本文件来操作
Fancly 2004-07-28
  • 打赏
  • 举报
回复
mark

1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧