Results 1 to 3 of 3

Thread: disable enable network connections?

  1. #1
    Join Date
    Apr 2009
    Qt products
    Unix/X11 Windows

    Default disable enable network connections?

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

  2. #2
    Join Date
    Apr 2009
    Qt products
    Unix/X11 Windows

    Default Re: disable enable network connections?

    anyone has solution?

  3. #3
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits

    Default Re: disable enable network connections?

    Hmm... I'm having a deja vu. I though I already answered that question.

    Anyway --- no, Qt has no facilities for managing network interfaces.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. more network connections simultaneously
    By cmeliak in forum Qt Programming
    Replies: 9
    Last Post: 8th June 2006, 00:17


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.