How can i change the cursor (image) in the whole windows OS

I need to change the cursor in all windows, not just in the application, i have try this:

this.Cursor = Cursors.WaitCursor;

And this:

System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

But it only changes the cursor in my application.

Any idea?


Solution 1:

Assuming you have your own cursor file (.cur) to apply you could hack this.

First you will have to change thje default Arrow cursor in the Registry, then you will need to call some P-Invoke to allow the OS to update the current sytem paramerters so the cursor actually changes.

Somthing like:

    private void ChangeCursor(string curFile)
    {
        Registry.SetValue(@"HKEY_CURRENT_USER\Control Panel\Cursors\", "Arrow", curFile);
        SystemParametersInfo(SPI_SETCURSORS, 0, null, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); 
    }

    const int SPI_SETCURSORS = 0x0057; 
    const int SPIF_UPDATEINIFILE = 0x01; 
    const int SPIF_SENDCHANGE = 0x02; 

    [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
    public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint? pvParam, uint fWinIni);

Usage:

 ChangeCursor(@"C:\MyCursor.cur");

Solution 2:

You cannot change the cursor of the entire OS without modifying the registry.

You need to modify the registry to change the cursor.

See here for a tutorial and the exact Registry keys you need to modify - programmatically.

http://www.thebitguru.com/articles/14-Programmatically+Changing+Windows+Mouse+Cursors