下面这段程序在W2k下面没是么反应,为何,请大家指点
int numberOfHost = 1;
struct hostent *remoteHostent;
WSADATA wsaData;
int iRet = WSAStartup(MAKEWORD(2,1), &wsaData);
if ( iRet != 0 )
{
exit( 1 );
}
int nRemoteAddr = inet_addr("10.150.17.93");
int localAddr =inet_addr("10.150.16.154");
remoteHostent= (struct hostent*)malloc( sizeof(struct hostent ));
struct in_addr sa;
sa.s_addr = nRemoteAddr;
remoteHostent = gethostbyaddr( (char*)&nRemoteAddr,4, AF_INET );
if (!remoteHostent )
exit(1);
unsigned char macAddress[6];
ULONG macAddLen = 6;
iRet=SendARP(nRemoteAddr, localAddr,(PULONG)&macAddress, &macAddLen);
// MessageBox((char*)macAddress,NULL,MB_OK);
m_remotemac.SetWindowText((char*)macAddress);
int numberOfHost = 1;
struct hostent *remoteHostent;
WSADATA wsaData;
int iRet = WSAStartup(MAKEWORD(2,1), &wsaData);
if ( iRet != 0 )
{
exit( 1 );
}
int nRemoteAddr = inet_addr("10.150.17.93");
int localAddr =inet_addr("10.150.16.154");
remoteHostent= (struct hostent*)malloc( sizeof(struct hostent ));
struct in_addr sa;
sa.s_addr = nRemoteAddr;
remoteHostent = gethostbyaddr( (char*)&nRemoteAddr,4, AF_INET );
if (!remoteHostent )
exit(1);
unsigned char macAddress[6];
ULONG macAddLen = 6;
iRet=SendARP(nRemoteAddr, localAddr,(PULONG)&macAddress, &macAddLen);
// MessageBox((char*)macAddress,NULL,MB_OK);
m_remotemac.SetWindowText((char*)macAddress);
解决方案 »
- MFC中setwindowtext未定义字符
- 多线程出错(火车票一票多出)情况?孙鑫书上COPY的代码有问题.
- 了解YOUKU,或者土豆等流媒体服务器的状况的进来谈谈
- 如何输出这个字符串?
- 32位机器上float 的表示 16位怎么表示
- 字符数组怎样才能变成CString的变量,怎样判断字符数组为空。谢谢。。
- 请教诸位大侠:DataGrid组件(v6.0),怎样改变列的宽度,我要给每列设定不同的宽度,不是要固定的那种
- 很弱智的问题,散分!
- 怎样算出框架CFrameWnd除去标题,菜单,工具条和状态条后的高度
- 我是初学,几个送分问题,欢迎指教
- 关于打印的问题!谢谢!
- 急!急!如何使打印机停止走纸?
// Note: Win2000 only
// NOT NT 4.0, Win9x, WinME#pragma comment( lib, "Iphlpapi" )
#pragma comment( lib, "Ws2_32" )#include <windows.h>
#include <Iphlpapi.h>int main( ) {IPAddr ip = 0;
ULONG mac = 0;
DWORD error = 0; DWORD dwSize = sizeof( ULONG) ;
ip = inet_addr("192.168.0.100");
//ip = inet_addr("xxx.xxx.xxx.xxx");
error = SendARP(ip,0,&mac,&dwSize); return 0;
}
一个MAC上可以帮定多个IP地址,所以不同的IP他也返回相同的MAC。
个人观点
是什么原因呢
int ip = 0; //here
unsigned char mac[6];
DWORD error = 0;
ULONG dwSize = 6;
m_szRemoteIP.GetWindowText(m_szremoteip);
ip = inet_addr(m_szremoteip);
error = SendARP(ip,0,(PULONG)&mac,&dwSize);
if (error == NO_ERROR )
{
// printf( "MacAddress: " );
// printf( "%d\n", mac );
m_szRemoteMAC.Format("%02X-%02X-%02X-%02X-%02X-%02X",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);//here
}
else
// printf( "SendARP Error:%d\n", GetLastError());
return;
m_remotemac.SetWindowText(m_szRemoteMAC);