Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a method retrieving the cursor position and get the coordinate on a specific window using GetCursorPos() and ScreenToClient(). All It work perfectly except a strange thing.

If the target window is run under administrator privilege and my application run under current user's privilege, I cant get the coordinate until my application window is over the target.

Same thing happen if I run my appliction as administrator and the target run under current user.

Why ?


The problem isnt getting the coordinate of the cursor, but getting the coordinate when the privilege of both application are different.


I am using VS2010 under Win7 x64.


Edit:

On Stackoverflow someone added a comment that the problem could be ScreenToClient() as I dont have the permission.

Any clue about this ? (I dont found information on MSDN)
Posted
Updated 25-Jun-12 2:48am
v2

1 solution

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[^]
 
Share this answer
 
Comments
Vitaly Tomilov 25-Jun-12 13:56pm    
The very core of API, SendMessage has this limitation that prevents sending messages across accounts, but not all of them, just few select ones, like WM_COPYDATA, etc., see in MSDN.

This first appeared in Vista, the limitation does not exist in XP.
jo le serb 25-Jun-12 13:59pm    
Thanks for the precision.
Vitaly Tomilov 25-Jun-12 14:03pm    
You're welcome! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900