日期:2014-05-18 浏览次数:20759 次
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32 Public Function WriteINI(ByVal sSection As String, ByVal sKey As String, ByVal sValue As String, ByVal sFileName As String) As Long WriteINI = WritePrivateProfileString(sSection, sKey, sValue, sFileName) End Function
[DllImport("kernel32.dll")] public static extern long WritePrivateProfileString(string section, string key, string val, string filePath); public static void WriteINI(string Section, string Key, string Val, string FilePath) { WritePrivateProfileString(Section, Key, Val, FilePath); }
------解决方案--------------------
楼主就是要在C#中调用API函数吧?
改写如下:
[DllImport("kernel32.dll"), EntryPoint="WritePrivateProfileStringA"]
public static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
public long WriteINI(string Section, string Key, string Val, string FilePath)
{
return WritePrivateProfileString(Section, Key, Val, FilePath);
}
详细请参考
http://dev.csdn.net/article/75/75553.shtm