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

lhzongji 2004-06-18 04:04:35
[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);
}

拜托了。
...全文
75 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
think8848 2004-07-01
  • 打赏
  • 举报
回复
下面的翻译应该是没有错的,但可能没有楼主所希望的结果。


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
CsdnRob 2004-07-01
  • 打赏
  • 举报
回复
up
lhzongji 2004-06-18
  • 打赏
  • 举报
回复
UP
lhzongji 2004-06-18
  • 打赏
  • 举报
回复
不是吧。没人帮我

110,533

社区成员

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

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

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