I am trying to use some code that uses the IID_IShellDispatch
and CLSID_Shell
constants.
My includes:
#include <Windows.h>
#include <WinDef.h>
#include <Shellapi.h>
#include <iostream>
#include <string>
#include <ShlDisp.h>
#include <Shlobj.h>
The code:
BSTR source = SysAllocString(input.toStdWString().c_str());
BSTR dest = SysAllocString(outputDirectory.toStdWString().c_str());
HRESULT result;
IShellDispatch *pISD;
Folder *folder = NULL;
VARIANT vDir, vFile, vOpt;
CoInitialize(NULL);
result = CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, IID_IShellDispatch, (void **)&pISD);
...
The last line above throws error about undefined reference to CLSID_Shell and IID_IShellDispatch
The code is part of a Qt project so I am using a Qt project file (for qmake) and I have added the -lshell32
into the LIBS
section of it:
LIBS += -lshell32 -loleaut32 -lole32
Command executed is
g++ -Wl,-subsystem,windows -mthreads -o debug\wallch.exe object_script.wallch.Debug -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lshell32 -loleaut32 -lole32 -LC:\Qt\Qt5.2.0\5.2.0\mingw48_32\lib -lQt5Widgetsd -lQt5Networkd -lQt5Guid -lQt5Cored
Using MinGW on win7
I had to download the windows SDK and add it to my options like this: