我使用c ++语言编写Windows7 x64。
当我使用ShellExecuteEx函数向网络摄像头显示标记时,我创建了一个打开firefox浏览器的项目。我的项目适用于visual studio 2010。
但是,当我尝试使用Qt Creator运行我的项目时,我收到此错误:
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
代码是:
#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
我认为问题是shell32.lib。如果是的话,我的电脑里没有这个库。我该如何解决?
你能帮助我吗?
提前致谢!
答案 0 :(得分:1)
很简单。只需右键单击项目专业文件并添加外部库。选择系统库,静态并给出shell32.lib的路径
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib
答案 1 :(得分:0)
这是我解决这个问题的方法:
.pro文件中的: INCLUDEPATH + =“C:\ Program Files \ Microsoft SDKs \ Windows \ v7.0A \ Lib” (文件shellAPI.lib的路径)
在我的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