谁能把这段C#代码翻译成VB.NET

lhzongji 2004-06-18 04:05:38
[DllImport("Iphlpapi.dll")]
private static unsafe extern int SendARP(Int32 dest,Int32 host,ref IntPtr mac,ref IntPtr length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);

Int32 ldest= inet_addr("157.60.68.163");//目的地的ip
Int32 lhost= inet_addr("157.60.68.33");//本地的ip

try
{
Byte[] macinfo=new Byte[6];
Int32 length=6;

IntPtr mac=new IntPtr(macinfo[0]);
IntPtr len=new IntPtr(6);
int ii=SendARP(ldest,lhost, ref mac, ref len);

Console.WriteLine("Mac Add:"+mac);
Console.WriteLine("length:"+len);


}
catch(Exception err)
{
Console.WriteLine(err);
}
...全文
106 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
EventLog 2004-07-05
  • 打赏
  • 举报
回复
[DllImport("Iphlpapi.dll")] private static unsafe extern int SendARP(Int32 dest,Int32 host,ref IntPtr mac,ref IntPtr length); [DllImport("Ws2_32.dll")] private static extern Int32 inet_addr(string ip); Int32 ldest= inet_addr("157.60.68.163");//目的地的ip Int32 lhost= inet_addr("157.60.68.33");//本地的ip try { Byte[] macinfo=new Byte[6]; Int32 length=6; IntPtr mac=new IntPtr(macinfo[0]); IntPtr len=new IntPtr(6); int ii=SendARP(ldest,lhost, ref mac, ref len); Console.WriteLine("Mac Add:"+mac); Console.WriteLine("length:"+len); } catch(Exception err) { Console.WriteLine(err); }
netvsj2ee 2004-07-02
  • 打赏
  • 举报
回复
[DllImport("Iphlpapi.dll")]
private static unsafe extern int SendARP(Int32 dest,Int32 host,ref IntPtr mac,ref IntPtr length);
[DllImport("Ws2_32.dll")]
private static extern Int32 inet_addr(string ip);

Int32 ldest= inet_addr("157.60.68.163");//目的地的ip
Int32 lhost= inet_addr("157.60.68.33");//本地的ip

try
{
Byte[] macinfo=new Byte[6];
Int32 length=6;

IntPtr mac=new IntPtr(macinfo[0]);
IntPtr len=new IntPtr(6);
int ii=SendARP(ldest,lhost, ref mac, ref len);

Console.WriteLine("Mac Add:"+mac);
Console.WriteLine("length:"+len);


}
catch(Exception err)
{
Console.WriteLine(err);
}
think8848 2004-07-02
  • 打赏
  • 举报
回复
在c#里面我昨天就译了呀?怎么难道我译的错误?

Private Declare Auto Function SendARP Lib "Iphlpapi.dll" (ByVal dest As Integer, ByVal host As Integer, ByRef mac As IntPtr, ByRef length As IntPtr) As Integer
Private Declare Auto Function inet_addr Lib "Ws2_32.dll" (ByVal ip As String) As Integer

Dim ldest As Integer = inet_addr("172.16.0.4") '目的地的IP
Dim lhost As Integer = inet_addr("172.16.3.154") '本地的IP


Try
Dim macinfo(6) As Byte
Dim length As Integer = 6
Dim mac As IntPtr = New IntPtr(macinfo(0))
Dim len As IntPtr = New IntPtr(6)
Dim ii As Integer = SendARP(ldest, lhost, mac, len)
Me.Text = mac.ToString & len.ToString


Catch ex As Exception
ex.ToString()
End Try
miaojx 2004-07-02
  • 打赏
  • 举报
回复
分数太少
qianguob 2004-07-02
  • 打赏
  • 举报
回复
上面有工具,
qianguob 2004-07-02
  • 打赏
  • 举报
回复
http://www.developerfusion.com/utilities/convertvbtocsharp.aspx
CsdnRob 2004-07-01
  • 打赏
  • 举报
回复
UP
lhzongji 2004-06-18
  • 打赏
  • 举报
回复
UP
lhzongji 2004-06-18
  • 打赏
  • 举报
回复
不是吧。没人帮我。HELP!··········

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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