Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Send-EnvironmentChangeEvent {
- @"
- [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
- );
- "@ | Set-Variable ImportWin32Declaration
- if (-not ("Win32.NativeMethods" -as [Type])) {
- Add-Type -Namespace Win32 -Name NativeMethods -MemberDefinition $ImportWin32Declaration
- }
- $HWND_BROADCAST = [System.IntPtr] 0xffff
- $WM_SETTINGCHANGE = 0x1a
- $result = [System.UIntPtr]::Zero
- [Win32.NativeMethods]::SendMessageTimeout(
- $HWND_BROADCAST,
- $WM_SETTINGCHANGE,
- [System.UIntPtr]::Zero,
- "Environment",
- 2,
- 5000,
- [ref] $result
- )
- }
Add Comment
Please, Sign In to add comment