I am trying to build a simple application that consist of a function that disable and enable connection.I am using Qtcreator to code.with mingw.I've found some online code which I've used for understanding and to test if it works in Qt:
bool EnableConnection(LPCWSTR wszName, bool bEnable)
bool result = false;
typedef void (__stdcall * LPNcFreeNetconProperties)(NETCON_PROPERTIES* pProps);
HMODULE hmod = LoadLibraryA("netshell.dll");
LPNcFreeNetconProperties NcFreeNetconProperties = (LPNcFreeNetconProperties)GetProcAddress(hmod, "NcFreeNetconProperties");
if (!NcFreeNetconProperties )
INetConnectionManager * pMan = 0;
HRESULT hres = CoCreateInstance(CLSID_ConnectionManager,
IEnumNetConnection * pEnum = 0;
hres = pMan->EnumConnections(NCME_DEFAULT, &pEnum);
INetConnection * pCon = 0;
bool done = false;
while (pEnum->Next(1, &pCon, &count) == S_OK && !done)
NETCON_PROPERTIES * pProps = 0;
hres = pCon->GetProperties(&pProps);
if (wcscmp(pProps->pszwName,wszName) == 0)
result = (pCon->Connect() == S_OK);
result = (pCon->Disconnect() == S_OK);
done = true;
I have tried to link them up with these:
My Lib folder contains:
win32:LIBS += -Lc:/Path/Lib -liphlpapi -lole32 -lnetshell
win32:INCLUDEPATH += c:/Path/Include
My Include folder contains:
netcon.h (found this file online)
However when i tried to build my application i get errors like:
1. undefined reference to CLSID_ConnectionManager or IID_INetConnectionManager and
2. __uuidof not declared.
3. and I think there is something wrong with the statement for __stdcall
Is there anything I've missed here???
I am new to programming in windows and have been unable to find any solution for this.Have encountered several errors like this already...How can I include all the dependent files and libs once and for all?I am unable to use visual studio although I have Visual C++ 08 installed because it is a requirement for me to use Qt in this project.
Will appreciate any valuable advice.
Thanks in advanced.