From the MSDN:
The input desktop must be the current desktop when you call GetCursorPos. Call OpenInputDesktop to determine whether the current desktop is the input desktop. If it is not, call SetThreadDesktop with the HDESK returned by OpenInputDesktop to switch to that desktop.
This page (where I got the above quote from) which asks the question "GetCursorPos not working if desktop is locked", has the following information:
You can't get this information while the desktop is locked. While the
desktop is locked, the security subsystem takes over, and your desktop is
off limits.
At that point, you would have to hook into the O/S (people have done it
by replacing GINA.dll, but you can't do this in managed code, and on top of
that, you can't do it in Vista, as it has a different model).
While the desktop is locked, you are going to have to do without cursor
information if you are using managed code.