- void CViewAdapterInfoDlg::GetInfo()
- {
- if (pinfo!=NULL)
- delete (pinfo);
- unsigned long nError;
- nError = GetAdaptersInfo(pinfo,&len);
- if (nError==0)
- {
- ParseData();
- }
- if (nError==ERROR_NO_DATA)
- {
- AfxMessageBox("No adapter information exists for the local computer");
- }
- if (nError==ERROR_NOT_SUPPORTED)
- {
- AfxMessageBox("GetAdaptersInfo is not supported by the operating system running on the local computer");
- }
- if (nError==ERROR_BUFFER_OVERFLOW)
- {
- pinfo= (PIP_ADAPTER_INFO)malloc(len);
- nError = GetAdaptersInfo(pinfo,&len);
- if (nError==0)
- {
- ParseData();
- }
- }
- return;
- }
- void CViewAdapterInfoDlg::ParseData()
- {
- if (pinfo!=NULL)
- {
- m_macaddress.Format("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address[0],pinfo->Address[1],pinfo->Address[2],pinfo->Address[3],pinfo->Address[4],pinfo->Address[5]);
- m_description = pinfo->Description;
- m_type.Format("%d",pinfo->Type);
- PIP_ADDR_STRING pAddressList = &(pinfo->IpAddressList);
- m_IpAddress ="";
- do
- {
- m_IpAddress += pAddressList->IpAddress.String;
- pAddressList = pAddressList->Next;
- if (pAddressList != NULL)
- m_IpAddress +="/r/n";
- } while (pAddressList != NULL);
- m_subnet.Format("%s",pinfo->IpAddressList.IpMask.String);
- m_gateway.Format("%s",pinfo->GatewayList.IpAddress.String);
- if (pinfo->HaveWins)
- m_PrimaryWinsServer.Format("%s",pinfo->PrimaryWinsServer.IpAddress.String );
- else
- m_PrimaryWinsServer.Format("%s","N/A" );
- if (pinfo->DhcpEnabled )
- m_dhcp.Format("%s",pinfo->DhcpServer.IpAddress.String );
- else
- m_dhcp.Format("%s","N/A");
- pinfo = pinfo->Next;
- }
- else
- {
- m_buttonnext.EnableWindow(FALSE);
- }
- UpdateData(FALSE);
- }