远程客户端网卡MAC获得
2010-09-20 18:10
274 查看
Get MAC Address, SNMP Method
snmpmac.cpp
In my search for an ironclad method of finding the MAC address of the ethernet card of a system, I attempted the NetBIOS method as described in the FAQ, but found this to be unacceptable as some of our customers reportedly didn’t use [NetBIOS]. I passed over the RPC method, and found a solution in a page maintained by Stas Khirman and Raz Galili.... They describe a method of using the internal SNMP calls in Windows (NT, 95, and 2000 have worked for me) that are used by netstat and other windows utilities, but unfortunately provide no code example for finding the MAC code.
[Below is] a small program I’ve written up, so that hopefully other people won’t have to go through the same learning curve I did with SNMP. I will also attach a file, snmpapi.cpp, that was written by Stas Khirman and distributed on his web page.
http://www.docin.com/p-23654770.html
http://tangentsoft.net/wskfaq/examples/getmac-snmp.html
snmpmac.cpp
snmpapi.cpp /****************************************************************** * * Copyright (C) Stas Khirman 1998. All rights reserved. * * This program is distributed WITHOUT ANY WARRANTY * *******************************************************************/ /************************************************* * * Reproduction of SNMP.LIB and SNMPAPI.LIB base * functions * * Author: Stas Khirman (staskh@rocketmail.com) * * * Free software: no warranty; use anywhere is ok; spread the * sources; note any modifications; share variations and * derivatives (including sending to staskh@rocketmail.com). * * *************************************************/ #include <snmp.h> SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidCpy( OUT AsnObjectIdentifier *DstObjId, IN AsnObjectIdentifier *SrcObjId ) { DstObjId->ids = (UINT *)GlobalAlloc(GMEM_ZEROINIT,SrcObjId->idLength * sizeof(UINT)); if(!DstObjId->ids){ SetLastError(1); return 0; } memcpy(DstObjId->ids,SrcObjId->ids,SrcObjId->idLength*sizeof(UINT)); DstObjId->idLength = SrcObjId->idLength; return 1; } VOID SNMP_FUNC_TYPE SnmpUtilOidFree( IN OUT AsnObjectIdentifier *ObjId ) { GlobalFree(ObjId->ids); ObjId->ids = 0; ObjId->idLength = 0; } SNMPAPI SNMP_FUNC_TYPE SnmpUtilOidNCmp( IN AsnObjectIdentifier *ObjIdA, IN AsnObjectIdentifier *ObjIdB, IN UINT Len ) { UINT CmpLen; UINT i; int res; CmpLen = Len; if(ObjIdA->idLength < CmpLen) CmpLen = ObjIdA->idLength; if(ObjIdB->idLength < CmpLen) CmpLen = ObjIdB->idLength; for(i=0;i<CmpLen;i++){ res = ObjIdA->ids[i] - ObjIdB->ids[i]; if(res!=0) return res; } return 0; } VOID SNMP_FUNC_TYPE SnmpUtilVarBindFree( IN OUT RFC1157VarBind *VarBind ) { BYTE asnType; // free object name SnmpUtilOidFree(&VarBind->name); asnType = VarBind->value.asnType; if(asnType==ASN_OBJECTIDENTIFIER){ SnmpUtilOidFree(&VarBind->value.asnValue.object); } else if( (asnType==ASN_OCTETSTRING) || (asnType==ASN_RFC1155_IPADDRESS) || (asnType==ASN_RFC1155_OPAQUE) || (asnType==ASN_SEQUENCE)){ if(VarBind->value.asnValue.string.dynamic){ GlobalFree(VarBind->value.asnValue.string.stream); } } VarBind->value.asnType = ASN_NULL; }
In my search for an ironclad method of finding the MAC address of the ethernet card of a system, I attempted the NetBIOS method as described in the FAQ, but found this to be unacceptable as some of our customers reportedly didn’t use [NetBIOS]. I passed over the RPC method, and found a solution in a page maintained by Stas Khirman and Raz Galili.... They describe a method of using the internal SNMP calls in Windows (NT, 95, and 2000 have worked for me) that are used by netstat and other windows utilities, but unfortunately provide no code example for finding the MAC code.
[Below is] a small program I’ve written up, so that hopefully other people won’t have to go through the same learning curve I did with SNMP. I will also attach a file, snmpapi.cpp, that was written by Stas Khirman and distributed on his web page.
http://www.docin.com/p-23654770.html
http://tangentsoft.net/wskfaq/examples/getmac-snmp.html
相关文章推荐
- Java/JSP获得客户端网卡MAC地址的三种方法解析
- Java/JSP获得客户端网卡MAC地址的三种方法解析
- 获得远程或本地机器的网卡的MAC
- Java/JSP获得客户端网卡MAC地址的三种方法解析
- Java/JSP获得客户端网卡MAC地址的三种方法解析(附:获得真实IP)
- Java/JSP获得客户端网卡MAC地址的三种方法解析
- 何获得当前网卡的mac地址
- 获得客户端的MAC
- SSH客户端,FinalShell服务器管理,远程桌面加速软件,支持Windows,Mac OS X,Linux,版本2.6.3.1
- Java获得CPU序列号和网卡Mac地址
- ASP获得网卡的MAC地址
- C#获取本机网卡MAC和远程服务器网卡
- javascript获取客户端网卡MAC和IP地址和计算机名
- NETBIOS()获得网卡MAC
- 通过调用系统API获得网卡真实MAC地址
- C#获得CPU,硬盘,网卡MAC序号
- 【C++】获得本机所有网卡的IP和MAC地址信息
- 通过调用系统API获得网卡真实MAC地址
- PHP获取客户端的网卡mac物理地址
- ASP.Net获取客户端网卡MAC的小例子