我有寫入用戶名,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