Click to See Complete Forum and Search --> : compiling err: "cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'"


SliderMan
April 29th, 2007, 02:21 PM
Hi there!
im tring to make a trainer (for cheating a game)
so i have to find the window of the game to get an handle for writing the process memory:


#include <windows.h>


void main () {

FindWindow("Minesweeper", NULL);
}



thats how i did it and its giving me the following err:
"error C2664: 'FindWindowW' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast"

why is that?
thanks in advance for helping.
moshe.

TheCPUWizard
April 29th, 2007, 02:49 PM
Because a "char" is not a "WCHAR". :D


One is 8 bit. The other is 16 bit (W is for Wide). You should use the "_T()" macro so the compiler will properly generate your literals...

FindWindow(_T("Minesweeper"), NULL);

SliderMan
April 29th, 2007, 02:56 PM
"Main.cpp(6) : error C3861: '_T': identifier not found"
this what im getting right now. :\
thanks for helping but i think its something with wrong with my compiler :\ Documentation
saied i should write like i did. "FindWindow("Minesweeper", NULL); "
thanks answering! something else that u can think about?

Notsosuperhero
April 29th, 2007, 03:20 PM
Have you tried using the TEXT() macro?


FindWindow(TEXT("className"), NULL);


To use the _T macro you have to include tchar.h

TEXT() is defined in winnt.h which is included when you include windows.h

TheCPUWizard
April 29th, 2007, 05:31 PM
i think its something with wrong with my compiler :


Nothing is wrong with your compiler. You simply cant mix 8 and 16 bit character representations. Your documentation is simply assuming you have configured your compiler for 8 bit characters, which was the most common setting years ago.....

SliderMan
April 30th, 2007, 02:50 PM
its was the project configuration yes ur right. im sorry. havent noticed
and TEXT () could work i have try it
thank you guys :P