Home > Back-end >  How to acquire the network card disabled state Index value
How to acquire the network card disabled state Index value

Time:09-25

I want to get a piece of card, use, GetAdaptersInfo function
But this function only to obtain the active state of network card, can't retrieve disabling condition, can ask next under Windows have this API for disabling condition state of network card,

CodePudding user response:

#include
# pragma comment (lib, "IPHLPAPI. Lib")
//////////////////////

Void CMFCTestDlg: : OnBnClickedButton1 ()
{
PIP_ADAPTER_INFO info;
Info=(IP_ADAPTER_INFO *) malloc (sizeof (IP_ADAPTER_INFO));
ULONG ulOutBufLen=sizeof (IP_ADAPTER_INFO);


If (GetAdaptersInfo (info, & amp; UlOutBufLen)==ERROR_BUFFER_OVERFLOW)
{
//ulOutBufLen length: list (memory card information),
//this is according to the number of CARDS to
//the first call to get ulOutBufLen GetAdaptersInfo length
//to allocate memory
Free (info);
Info=(IP_ADAPTER_INFO *) malloc (ulOutBufLen);
}
//called again GetAdaptersInfo, multiple network card information are in the info
If (GetAdaptersInfo (info, & amp; UlOutBufLen)==ERROR_NO_DATA)
{
MessageBox (_T (" disabled "));
}
The else
{
MessageBox (_T (" connected "));
}
Free (info);
Info=NULL;
}
  • Related