Yeah it does, so what is the difference between FindWindow function and FindWindowA ? |
WinAPI functions that take strings come in 3 flavors:
TCHAR flavor (FindWindow)
char flavor (FindWindowA)
wchar_t flavor (FindWindowW)
TCHAR is #defined as either chars or wchar_t depending on your project settings. But for the purposes of writing stable, consistent code, you should consider it its own type.
Since you are giving it a char array in the form of a string literal, you want to use the char version of the function (FindWindowA). To use the TCHAR version, you would want to give it a TCHAR string:
1 2 3
|
FindWindowA(0, "Calculator"); // <- char string, 'A' version of the function
FindWindowW(0, L"Calculator"); // <- wchar_t string, 'W' version of the function
FindWindow(0, TEXT("Calculator")); // TCHAR string, 'normal' version of the function
|
This is true of practically all WinAPI structs/functions.
And why add an “&” in front of the variable processID? |
Because GetWindowThreadProcessId needs a pointer to a DWORD. The & symbol is the "address of" operator, which gives you a pointer to the processID variable.