Created
June 13, 2018 21:04
-
-
Save antelio/8fd0ee4d6552ca13e54c9d5faf5bbc0a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (-not ("win32.nativemethods" -as [type])) { | |
# import sendmessagetimeout from win32 | |
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 | |
# notify all windows of environment block change | |
[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