Error: argument of type char is incompatible with lpcwstr

Asked

Viewed 76 times

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’re making the following mistake:

argument of type char is incompatible with lpcwstr

How to solve?

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points).

1 answer

1

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

I would take advantage and use the FindWindowEx() which is more modern. You must be using several legacy things in this code.

  • Thank you for the force :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.