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..

Qt Code:
  1. #include <windows.h>
  2. #include <iphlpapi.h>
  3. #include <objbase.h>
  4. #include <netcon.h>
  5. #include <stdio.h>
  6. .....
  7. void disableNIC(char * AdapterName)
  8. {
  9. INetConnectionManager* pNet;
  10. INetConnection* pConn;
  11. IEnumNetConnection* pEnum;
  12. NETCON_PROPERTIES* pProps;
  13. wchar_t Temp[255];
  14. ULONG uCount = 0;
  15.  
  16. swprintf(Temp, L"%S", AdapterName);
  17. CoInitialize(NULL);
  18. CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, IID_INetConnectionManager, (void**)&pNet);
  19. //CoCreateInstance(CLSID_ConnectionManager, NULL, CLSCTX_SERVER, __uuidof(INetConnectionManager), (void**)&pNet);
  20. pNet->EnumConnections(NCME_DEFAULT, &pEnum);
  21. ....
  22. ...
  23. }
To copy to clipboard, switch view to plain text mode 
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.