I have documentation where written that username, IP and password must be const char* and when I'm putting varaibles in const char, I'm getting this error message.
This is my code:
#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");          
        }          
    }
}
And I got this error:
cannot convert
const char*' toWCHAR*' in argument passing
Which kind of variable must I use for those arguments and how?
You are most likely using one of the Visual Studio compilers, where in Project Settings, there is a Character set choice. Choose from:
Calling functions that accept strings in the Unicode setting requires you to make Unicode string literals:
"hello"
Is of type const char*, whereas:
L"hello"
is of type const wchar_t*. So either change your configuration to Not set or change your string literals to wide ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With