我有写入用户名,IP和密码必须为const char*
的文档,并且当我将变量放在const char
中时,我收到此错误消息。无法在参数传递中将'const char *'转换为'WCHAR *'
这是我的代码:
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <windows.h>
using namespace std;
typedef int (__cdecl *MYPROC)(LPWSTR);
int main()
{
HINSTANCE hinstDLL;
MYPROC ProcAdd;
hinstDLL = LoadLibrary("LmServerAPI.dll");
if(hinstDLL != NULL){
ProcAdd = (MYPROC) GetProcAddress(hinstDLL,"LmServer_Login");
if(ProcAdd != NULL){
const char* IP = "xxx.177.xxx.23";
const char* name = "username";
const char* pass = "password";
int port = 888;
ProcAdd(IP,port,name,pass);
system ("pause");
}
}
}
而且我得到了这个错误:
cannot convert
const char*' to
WCHAR*' in argument passing
我必须使用哪种类型的变量,这些变量又如何呢?
一个'LPWSTR'又名'wchar_t的*'? – 2014-09-27 10:47:41
我是新的C++,不能转换const char *'toWCHAR *'参数传递这是错误从dev ++ – DTDest 2014-09-27 10:49:42
是否有某些原因'ProcAdd'需要一个'LPWSTR'如果你强制(根据你的问题)一个' const char *',其中常量不是字符宽度匹配? – WhozCraig 2014-09-27 10:49:50