就是这段代码啦。MS的专家,请问这样得到的mac地址正确吗? function GetMacADDR(IPstr:string):string; label Fend; var DestIP:IPAddr; pMacAddr: PULong; AddrLen: ULong; MacAddr: array[0..5] of byte; p: PByte; s: string; i: integer; SendARP:PSendARP; HM:Thandle; begin Result:=''; hm := loadlibrary('iphlpapi.dll'); if hm = 0 then goto Fend; SendARP := getprocaddress(hm, 'SendARP'); if @SendARP=nil then goto Fend ; DestIP := inet_addr(PChar(IPstr)); pMacAddr := @MacAddr[0]; AddrLen := SizeOf(MacAddr); SendARP(DestIP, 0, pMacAddr, AddrLen); p := PByte(pMacAddr); if Assigned(p) and (AddrLen>0) then for i := 0 to AddrLen-1 do begin s := s + IntToHex(p^,2) + '-'; Inc(p); end; SetLength(s, length(s)-1); Result:=s; Fend: FreeLibrary(hm); end;
在同一个网段。IP是不可能一样的。在不同的网段,IP有可能一样,但是如果有连接关系的话,子网掩码肯定是不会一样的。。
你是要做什么啊。。
,
我想用这唯一性的东西来加密,在同一个网络中的程序可以运行
而IP地址在两个网络中有可能相同,所以也就没什么意义了MAC地址?我在工作站上能得到SERVER的MAC吗?请教!
关于如何通过VB得到MAC地址,请参照这个URL的sample code.
http://support.microsoft.com/support/kb/articles/Q175/4/72.asp关于在VB中实现消息的广播发送,有两种方法:1、调用winsock APIs: Platform SDK中有一个关于怎样用Winsock APIs来发送multicasting 消息的例子BCast(<Driver:>\Program Files\Microsoft Platform SDK\Samples\NetDS\WinSock\Bcast),您可以作为参考。2、您可以用VB .NET中的class library来实现 .....
udpReceiver = New UdpClient(ReceiverPort)
multicastAddress = IPAddress.Parse("224.0.0.1")
udpReceiver.JoinMulticastGroup(multicastAddress):
....更详细的信息,请查找MSDN关于.NET Socket编程的文章。http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemNetSockets.asp?frame=truehttp://msdn.microsoft.com/nhp/default.asp?contentid=28000519&frame=true-微软亚洲技术中心 VB开发支持本贴子仅供CSDN的用户作为参考信息使用。其内容不具备任何法律保障。您需要考虑到并承担使用此信息可能带来的风险。具体事项可参见使用条款 (http://www.csdn.net/microsoft/terms.shtm)。
可见微软。
难怪他这么有钱!
有这么多的高手!。
看看!连问题的地质都回答得如此清楚!!
这是csdn上菜鸟的福音!!
愿神保佑vb保佑微软。保佑csdn的兄弟们!!
在客户端的确有办法通过IP取得子网内机器的mac地址。我用delphi实现过。但是不知VB怎么做啊
function GetMacADDR(IPstr:string):string;
label Fend;
var
DestIP:IPAddr;
pMacAddr: PULong;
AddrLen: ULong;
MacAddr: array[0..5] of byte;
p: PByte;
s: string;
i: integer;
SendARP:PSendARP;
HM:Thandle;
begin
Result:='';
hm := loadlibrary('iphlpapi.dll');
if hm = 0 then goto Fend;
SendARP := getprocaddress(hm, 'SendARP');
if @SendARP=nil then goto Fend ;
DestIP := inet_addr(PChar(IPstr));
pMacAddr := @MacAddr[0];
AddrLen := SizeOf(MacAddr);
SendARP(DestIP, 0, pMacAddr, AddrLen);
p := PByte(pMacAddr);
if Assigned(p) and (AddrLen>0) then
for i := 0 to AddrLen-1 do
begin
s := s + IntToHex(p^,2) + '-';
Inc(p);
end;
SetLength(s, length(s)-1);
Result:=s;
Fend:
FreeLibrary(hm);
end;
请问如何发送自定义的mac地址数据包,是否需要DDK?
http://www.csdn.net/expert/topicview1.asp
领分
http://www.csdn.net/expert/topicview1.asp
这个地址对别人是无效的,没有贴子号码啊!!
http://www.csdn.net/expert/topicview.asp?id=263827
224.x.x.x的保留地址,而且据说不是所有网卡都能正常
支持。
如果是广播,只需要指定目的IP为255.255.255.255,就
表示本子网广播,也可以将一个子网的主机位全部置一,
表示子网广播。很容易就实现。
谢谢大家的关心和帮助!给分!