Oh, no! You don't need to use P/Invoke as you do. You can use
for this purpose:http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.aspx
Note that it's bad to use P/Invoke unless it's absolutely unavoidable, because it totally kills your platform compatibility.
I recognize the problem if this API is not working. I explained the possible problem: there is a number of big incompatibilities between older GDI API and DirectX.
Then I have a different idea: instead of manipulating the mouse cursor, simulate mouse input by the function
Here, you unfortunately need to use P/Invoke, but you don't need to write it by yourself; it's already done for you:http://www.pinvoke.net/default.aspx/user32.sendinput
I tested it: it works very reliably. Actually, this is a low-level input, close to what is used by the hardware driver. You simulate input as it came from hardware, something you probably wanted to have in first place.
Please try it out and give me your feedback. You see, I never use any games, so I would like to here from you if you can solve this problem.—SA