Skip to content

Instantly share code, notes, and snippets.

@davidedg
Created April 23, 2019 07:55
Show Gist options
  • Save davidedg/8f74f1a2733ab255db6afbff8b263b64 to your computer and use it in GitHub Desktop.
Save davidedg/8f74f1a2733ab255db6afbff8b263b64 to your computer and use it in GitHub Desktop.
WM_SETTINGCHANGE in Powershell (https://www.angryadmin.co.uk/?p=855)
if (-not ("win32.nativemethods" -as [type])) {
add-type -Namespace Win32 -Name NativeMethods -MemberDefinition @"
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam,
uint fuFlags, uint uTimeout, out UIntPtr lpdwResult);
"@
}
$HWND_BROADCAST = [intptr]0xffff;
$WM_SETTINGCHANGE = 0x1a;
$result = [uintptr]::zero
[win32.nativemethods]::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE,[uintptr]::Zero, "Environment", 2, 5000, [ref]$result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment