vb.net转C#

zhangguiyou 2009-03-02 05:31:25
谁可以帮我把这几个方法转一下C#
    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


...全文
115 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ctan 2009-03-02
  • 打赏
  • 举报
回复
楼主就是要在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
xhueducls 2009-03-02
  • 打赏
  • 举报
回复
[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# p/invoke的格式
likevs 2009-03-02
  • 打赏
  • 举报
回复
记得给几分我Y

给你个地址,以后不用问别人了.

http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx
zgke 2009-03-02
  • 打赏
  • 举报
回复
[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);
}
zhangguiyou 2009-03-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 cryeyes 的回复:]
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

is hard for translate
[/Quote]
晕。就是不会转这一句。
成都慢生活 2009-03-02
  • 打赏
  • 举报
回复
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

is hard for translate

110,568

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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