下面的错误是@ GetFullPathName()函数
1 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"
2 IntelliSense: argument of type "char *" is incompatible with parameter of type "LPWSTR"当我试图运行我的程序时,我一直收到上面的错误。变量的类型是适当的,但它总是说不是吗?对此有什么想法吗?我不认为有必要把它们打出来。
#include "stdafx.h"
using namespace std;
int main(int argc, _TCHAR* argv[])
{
/* Get path of DLL we're loading */
string name;
cin >> name;
const char* DLL_NAME = name.c_str();
HWND handle = FindWindow(0, L"Calculator");
if(handle == NULL){
cout << "Couldn't find process window!" << endl;
}else{
cout << "Process window found, continuing..." << endl;
DWORD id;
GetWindowThreadProcessId(handle, &id);
char DLL_LOCATION[MAX_PATH] = {0};
GetFullPathName(DLL_NAME, MAX_PATH, DLL_LOCATION, NULL);
}
return 0;
}发布于 2013-08-04 03:29:38
变量的类型是适当的,但它总是说不是吗?
不,他们不是。LPCWSTR和LPWSTR分别是const wchar_t*和wchar_t*的别名。为此,您必须使用std::wstring而不是std::string。
他们的意思是:
LPCWSTR:指向宽字符串的长指针LPWSTR:指向宽字符串的长指针或者,您不能将您的项目编译为unicode (通过将字符集更改为Multi),这样Windows将期望“常规”字符串。
编辑:我应该注意到,就像字符串有广泛的模拟一样,std::cout和std::cin也是以std::wcout和std::wcin的形式出现的。
发布于 2013-08-04 03:30:10
您正在编译Unicode构建,所以所有Windows函数都需要Unicode字符串。
你可以:
std::wstring等)GetFullPathNameA等)发布于 2013-08-04 03:32:16
LPCWSTR是const wchar_t*。切换到wchar_t也更好,因为所有的windows本机都可以使用wchar_t。
https://stackoverflow.com/questions/18039436
复制相似问题