#include "stdafx.h"
#include
#pragma comment(lib,"Iphlpapi.lib")
#include
#pragma comment(lib,"Rpcrt4.lib")//GUID
#include //启用、禁用网卡
#pragma comment(lib,"ole32.lib")
#include
int main(int argc, char* argv[])
{
INetConnectionManager *pManager;
INetConnection *pConnection;
IEnumNetConnection *pEnum;
ULONG celtFetched;
CoInitialize(NULL);
CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pManager);
pManager->EnumConnections(NCME_DEFAULT, &pEnum);
pManager->Release();
while( pEnum->Next(1, &pConnection, &celtFetched) == S_OK )
{
NETCON_PROPERTIES* properties;
pConnection->GetProperties(&properties);
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,properties->pszwName,-1,NULL,0,NULL,FALSE);
char *psText;
psText = new char[dwNum];
if(!psText)
{
delete []psText;
}
WideCharToMultiByte (CP_OEMCP,NULL,properties->pszwName,-1,psText,dwNum,NULL,FALSE);
printf(psText);
printf("\r\n");
delete []psText;
}
return 0;
}