Windows has a mechanism called User Interface Privilege Isolation which prevents applications with lower privilege levels from communicating with applications at higher privilege levels. This is probably why the
ScreenToClient
function is failing. I'm sure that the
GetCursorPos
is succeeding.
Read more about UIPI here -
User Interface Privilege Isolation[
^]