Question

I work on Windows7 x64 in c++ language.

I created a project that open firefox browser when I show a marker to my web cam, using ShellExecuteEx function. My project works well with visual studio 2010.

But, when I try to run my project with Qt Creator, I get this error:

main_cam.obj:-1: error: LNK2019: riferimento al simbolo esterno __imp__ShellExecuteExW@4 non risolto nella funzione _main
debug\cam.exe:-1: error: LNK1120: 1 esterni non risolti

The code is:

#include <iostream>
#include <stdio.h>
#include <string>   // for strings
#include <iomanip>  // for controlling float print precision
#include <sstream> // string to number conversion
#include <windows.h>
#include <ShellAPI.h>
include [...]
int main () {
[...]
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "firefox.exe";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
[...]
if (condition_is_verified) {

ShExecInfo.lpParameters = (LPCWSTR)"www.google.it";
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
}
[...]
}//end main 

I think problem is shell32.lib . If it is, I haven't this library in my pc. how can I fix it?

Can you help me?

Thanks in advance!

Was it helpful?

Solution

It is very simple. Just right click the the project pro file and add external library. Choose system library, static and give the path of shell32.lib which is

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib

OTHER TIPS

This is my solution to this problem :

in the .pro file : INCLUDEPATH += "C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib" ( the path to the file shellAPI.lib )

in my mainwindow.h :

#define NOMINMAX // You have to do this for windows.h to work, else u'll get mistakes with datetime.h           
#include <windows.h> // (without the space)    
#pragma comment(lib, "Shell32.lib")    
#include <ShellAPI.h> // without space also
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top