首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

如何样删除INI文件下的内容

2012-02-22 
怎么样删除INI文件下的内容?如果我想把ini文件中的某个特定的section下面的key&value都删除调.如果不能用a

怎么样删除INI文件下的内容?
如果我想把ini文件中的某个特定的section下面的key&value都删除调.      
    如果不能用api,有什么办法.      
    例:      
    [section]      
    key=value1      
       
    [section1]      
    newkey=newvalue      
       
    想删除          
    newkey=newvalue

[解决办法]
Private Declare Function GetPrivateProfileString Lib "kernel32 " Alias "GetPrivateProfileStringA " (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString 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 lplFileName As String) As Long
Private R As Long
Private iStr As String
Private FilePath As String

Public Function WriteIni(AppName As String, KeyName As String, InString As String, FilePath As String) As String
iStr = InString
R = WritePrivateProfileString(AppName, KeyName, InString, FilePath)
If R <> 1 Then Debug.Print "Write Err! "
End Function

call writeini( "section1 ", "newkey ",vbnullstring, "c:\1.ini ")

热点排行