Programmatically update the mouse cursors with PowerShell

After updating the mouse cursors at HKEY_CURRENT_USER\Control Panel\Cursors, the system will not automatically reload them, it must be instructed to do so.  With the below PowerShell function, the system will reload the cursors and the changes made in the registry will be immediately reflected.

 
function Update-Cursors {
    add-type -MemberDefinition @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
 
const int SPI_SETCURSORS = 0x0057; 
const int SPIF_UPDATEINIFILE = 0x01; 
const int SPIF_SENDCHANGE = 0x02;
 
public static void UpdateCursors() {
    SystemParametersInfo(SPI_SETCURSORS, 0, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
}
"@ -Name CursorSPI -Namespace Temp
 
    [Temp.CursorSPI]::UpdateCursors()
 
}
August 17, 2013