SolvedHaving two errors

Posts 1–4 of 4 · Page 1 of 1
Having two errors
Having these two errors and cannot find out how to fix them; I googled everywhere. Underlined and made red the location of error..

1) Error: argument of type"const char*" is incompatible with parameter of type "LPCWSTR"

Code:
	}

		if (FindWindow("Valve001", NULL) == NULL) //is game closed?
			break;

		Sleep(20);
	}

Code:
do
	{
		this->setHwnd(FindWindow("Valve001", NULL));
		Sleep(20);
	} while (this->hwnd == NULL);
2) Error: argument of type "WCHAR*" is incompatible with "const char *"

Code:
static DWORD dll = 0;
	HANDLE s = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, this->pid);
	if (s == NULL || GetLastError() != 0)
		return false;
	MODULEENTRY32 m = { 0 };
	m.dwSize = sizeof(MODULEENTRY32);
	BOOL have = Module32First(s, &m);
	while (have)
	{
		if (strcmp(m.szModule, "client.dll") == 0)
		{
			dll = (DWORD)m.modBaseAddr;
			break;
		}
		have = Module32Next(s, &m);
	}
	CloseHandle(s);

	if (!dll)
		return false;
Hopefully one of you can help me.
This is a tricky one but it's one I haven't seen in my Visual studio for a while because I tend to work in mult-byte characters.

Two Solutions:
1. Set your character set to Multi-Byte
Project -> (Project Name) Properties -> Configuration Properties -> General -> Character Set

2. Construct a LPCWSTR Variable inside the function call and use wcsmp instead of strcmp
Code:
FindWindow(LPCWSTR("Valve001"), NULL)
if (wcscmp(m.szModule, LPCWSTR("client.dll")) == 0)
Quote Originally Posted by InunoTaishou View Post
This is a tricky one but it's one I haven't seen in my Visual studio for a while because I tend to work in mult-byte characters.

Two Solutions:
1. Set your character set to Multi-Byte
Project -> (Project Name) Properties -> Configuration Properties -> General -> Character Set

2. Construct a LPCWSTR Variable inside the function call and use wcsmp instead of strcmp
Code:
FindWindow(LPCWSTR("Valve001"), NULL)
if (wcscmp(m.szModule, LPCWSTR("client.dll")) == 0)
After I changed it to Multi-Byte it fixed the other issue also; thanks!
Option A:

Code:
#undef UNICODE
Option B:
Code:
MyFunction( L"MyString" );
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us