I wrote a program that calls GetWindowThreadProcessId. This function will either return a DWORD with the process ID if the second argument is NULL, or the second argument can be a pointer to a DWORD that the process ID is written to. When I call this function, different values are written to the PID variable depending on whether or the second argument is a pointer, or the other technique is used. May someone please explain this weird behavior?
[ code]
#include <iostream>
#include <Windows.h>
int main()
{
HWND hWnd;
DWORD PID;
HANDLE hProc;
hWnd = FindWindow(NULL, L"Untitled - Notepad");
if (!hWnd)
{
std::cout << "Failed to find window" << std::endl;
return 0;
}