PDA

View Full Version : disable enable network connections?



remy06
4th May 2009, 20:35
hi all,

I will like to create a function to disable/enable network connection in my program.I've tried a test code sample but it does not work and I suspect I did not properly included and link the necessary headers and libs..



#include <windows.h>
#include <iphlpapi.h>
#include <objbase.h>
#include <netcon.h>
#include <stdio.h>
.....
void disableNIC(char * AdapterName)
{
INetConnectionManager* pNet;
INetConnection* pConn;
IEnumNetConnection* pEnum;
NETCON_PROPERTIES* pProps;
wchar_t Temp[255];
ULONG uCount = 0;

swprintf(Temp, L"%S", AdapterName);
CoInitialize(NULL);
CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pNet);
//CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, __uuidof(INetConnectionManager), (void**)&pNet);
pNet->EnumConnections(NCME_DEFAULT, &pEnum);
....
...
}

it has an error with "undefined referenced to CLSID_ConnectionManager" and "IID_INetConnectionManager",or _uuidof was not declared in this scope.

I've included objbase.h and netcon.h and have added libole32.a to my Lib directory and I linked it like this: win32:LIBS += -Ld:/Path/Lib -liphlpapi -lole32 -lnetshell
Is there anything that I've missed and how to solve it?

Is there any functions in Qt that can be used to disable/enable connections instead?

Appreciate any advice.

remy06
8th May 2009, 16:33
anyone has solution?

wysota
8th May 2009, 18:52
Hmm... I'm having a deja vu. I though I already answered that question.

Anyway --- no, Qt has no facilities for managing network interfaces.