Error: argument of type char is incompatible with lpcwstr

2
#include <iostream>
#include <Windows.h>
#include <TlHelp32.h>

DWORD getbaseadress(DWORD Pid, TCHAR* n);
using namespace std;

int main(int argc, char* argv[]) 
{
    HWND hwnd = 0;
    DWORD pid = 0;

    hwnd = FindWindow(0,"PXG Cliente"); // erro aqui
    if (hwnd)
    {
        GetWindowThreadProcessId(hwnd, &pid);
        if (pid)
        {
            HANDLE ghandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION, pid);
            if (ghandle)
            {
                DWORD baseadress = getbaseadress(pid, "pxgcliente.exe");// ERRO AQUI

You are giving the following error:

  

argument of type char is incompatible with lpcwstr

How to solve?

    
asked by anonymous 15.02.2017 / 21:39

1 answer

1

The function is asking for a multibyte string then use L"PXG Cliente" .

I would take advantage of and use FindWindowEx() which is more modern. You should be using a lot of legacy stuff in that code.

    
15.02.2017 / 21:54