You are mixing "handle" types. OpenProcess() returns a HANDLE to a process. GetClassName() requires a "handle" to a window of type HWND.

gg