在NT,是用什么方法或调用什么函数获得网卡的物理地址

ufc 2000-02-24 12:56:00
在WINDOW(NT)下,系统是用什么方法或调用什么函数获得网卡的物理地址的如调用Getcomputername()来获得机器名一样,另外请告知那里有NT下打狗软件,本人被它折磨惨了..........谢谢!
...全文
340 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jxwa_wzw 2001-11-09
  • 打赏
  • 举报
回复
用sendarp()即可api函数,记得给我加分啊
King 2000-05-22
  • 打赏
  • 举报
回复
哎,借个光,NTDDK怎么找的?
sunsetyang 2000-04-23
  • 打赏
  • 举报
回复
用那个packet也太大材小用了吧!不是还有一个macaddr的例子吗?
使用时要加上你的网卡的名称加序号:
如你的网卡为ne2000,序号为1,则使用macaddr ne20001即可。

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <winioctl.h>
#define OID_802_3_CURRENT_ADDRESS 0x01010102
#DEVICE_PREFIX "\\\\.\\"

int
__cdecl
main(
int argc,
char ** argv
)
{

UCHAR LinkName[512];
UCHAR DeviceName[80];
UCHAR szMACFileName[80];
UCHAR OidData[4096];
NDIS_OID OidCode;
BOOLEAN bCreatedDevice;
DWORD ErrorNumber;
DWORD ReturnedCount;
HANDLE hMAC;

//
// Check to make sure we got the right number of arguments before we
// create any devices.
//

if (argc != 2)
{
printf("usage: macdmp <device>\n");
return(1);
}

//
// Check to see if the DOS name for the MAC driver already exists.
// Its not created automatically in version 3.1 but may be later.
//

if (QueryDosDevice(argv[1], LinkName, sizeof(LinkName)) == 0)
{
if ((ErrorNumber = GetLastError()) == ERROR_FILE_NOT_FOUND)
{
strcpy(DeviceName, "\\Device\\");
strcat(DeviceName, argv[1]);

//
// It doesn't exist so create it.
//
if (!DefineDosDevice( DDD_RAW_TARGET_PATH, argv[1], DeviceName))
{
printf(
"DefineDosDevice returned an error creating the device = %d\n",
GetLastError()
);
return(1);
}
bCreatedDevice = TRUE;
}
else
{
printf("QueryDosDevice returned an error = %d\n", GetLastError());
return(1);
}
}
else
{
bCreatedDevice = FALSE;
}

//
// Construct a device name to pass to CreateFile
//
strcpy(szMACFileName, DEVICE_PREFIX);
strcat(szMACFileName, argv[1]);

hMAC = CreateFile(
szMACFileName,
GENERIC_READ,
FILE_SHARE_READ and FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
INVALID_HANDLE_VALUE
);

if (hMAC != INVALID_HANDLE_VALUE)
{
//
// We successfully opened the driver, format the IOCTL to pass the
// driver.
//

OidCode = OID_802_3_CURRENT_ADDRESS;

if (DeviceIoControl(
hMAC,
IOCTL_NDIS_QUERY_GLOBAL_STATS,
&OidCode,
sizeof(OidCode),
OidData,
sizeof(OidData),
&ReturnedCount,
NULL
))
{
if (ReturnedCount == 6)
{
printf(
"Mac address = %02.2X-%02.2X-%02.2X-%02.2X-%02.2X-%02.2X\n",
OidData[0], OidData[1], OidData[2], OidData[3],
OidData[4], OidData[5], OidData[6], OidData[7]
);
}
else
{
printf(
"DeviceIoControl returned an invalid count = %d\n",
ReturnedCount
);
}
}
else
{
printf("DeviceIoControl returned an error = %d\n", GetLastError());
}
}
else
{
printf("CreateFile returned an error = %d\n", GetLastError());
}

if (bCreatedDevice)
{
//
// The MAC driver wasn't visible in the Win32 name space so we created
// a link. Now we have to delete it.
//
if (!DefineDosDevice(
DDD_RAW_TARGET_PATH and DDD_REMOVE_DEFINITION and
DDD_EXACT_MATCH_ON_REMOVE,
argv[1],
DeviceName)
)
{
printf(
"DefineDosDevice returned an error removing the device = %d\n",
GetLastError()
);
return(1);
}
}

return(0);
}
wangxian 2000-03-28
  • 打赏
  • 举报
回复
ARP
prolead 2000-03-17
  • 打赏
  • 举报
回复
机械出版社出版的《WINDOWS 网络编程》一书中有详细的说明及 IPCONFIG、 ROUTER、PING 等的源程序
prolead 2000-03-17
  • 打赏
  • 举报
回复
winipcfg
TeamD 2000-02-29
  • 打赏
  • 举报
回复
用NT下的IPCONFIG /ALL 命令可以查看到机器上每一块网卡的MAC地址。用程序的话我还不是很清楚如果有那一位知道的话可以E-mail给我。 yugz@263.net
zweiwang 2000-02-24
  • 打赏
  • 举报
回复
NTDDK 有Packet sample code .用该代码可获得MAC address
za 2000-02-24
  • 打赏
  • 举报
回复
Active Server Pages 错误 'ASP 0138'

嵌套的 Script 块

//global.asa, 行37

Script 块不能放在另一个 Script 块内。
radish 2000-02-24
  • 打赏
  • 举报
回复
这个问题已有人问过了,你可以到radsworld.yeah.net去,那有一篇我抄来的例子(C++ builder)的

6,849

社区成员

发帖
与我相关
我的任务
社区描述
Windows 2016/2012/2008/2003/2000/NT
社区管理员
  • Windows Server社区
  • qishine
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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