void CTestDlg::OnButton1()
{
CString LocalAdap;
CString LocalMac;
CString LocalIP;
CString LocalSub;
CString LocalGate;
PIP_ADAPTER_INFO pAdapterInfo;
PIP_ADAPTER_INFO pAdapter = NULL;
DWORD dwRetVal = 0;
BOOL m_bBreak = FALSE;
pAdapterInfo = (IP_ADAPTER_INFO *)malloc(sizeof(IP_ADAPTER_INFO));
unsigned long ulOutBufLen = sizeof(IP_ADAPTER_INFO);
if(GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) != ERROR_SUCCESS)
{
GlobalFree(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO*)malloc(ulOutBufLen);
}
if((dwRetVal=GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR)
{
pAdapter = pAdapterInfo;
while(pAdapter)
{
LocalAdap.Format ("%s", pAdapter->Description);
LocalMac.Format ("%02X-%02X-%02X-%02X-%02X-%02X", pAdapter->Address[0], pAdapter->Address[1],
pAdapter->Address[2],pAdapter->Address[3], pAdapter->Address[4], pAdapter->Address[5]);
LocalIP.Format ("%s", pAdapter->IpAddressList.IpAddress.String);
LocalSub.Format ("%s", pAdapter->IpAddressList.IpMask.String);
if(pAdapter->Next == NULL)
{
m_bBreak = TRUE;
break;
}
pAdapter = pAdapter->Next;
}
}
else
{
AfxMessageBox("Call to GetAdapterInfo failed");
}
AfxMessageBox(LocalAdap);
AfxMessageBox(LocalMac);
AfxMessageBox(LocalIP);
AfxMessageBox(LocalSub);
}
'C & C++ > MFC Network' 카테고리의 다른 글
[Web] 인터넷 프로그래밍 (0) | 2011.04.25 |
---|---|
[MFC] HTTP 소켓 통신 (0) | 2011.04.23 |
[IP] IE BHO 전용 브라우져 시 새창 띄울때 IE모양 바꾸기~ (0) | 2011.04.18 |
[IP] 인터넷 임시파일 삭제 (0) | 2011.04.14 |
[IP] Web Page 다운로드 (0) | 2011.04.14 |
댓글