[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace wxProtecter
{
class Win32Api
{
// SendMessageTimeout tools
public enum SendMessageTimeoutFlags : uint
{
SMTO_NORMAL = 0x0000,
SMTO_BLOCK = 0x0001,
SMTO_ABORTIFHUNG = 0x0002,
SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
}
const int WM_SETTINGCHANGE = 0x001A;
const int HWND_BROADCAST = 0xffff;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageTimeout(
IntPtr windowHandle,
uint Msg,
IntPtr wParam,
IntPtr lParam,
SendMessageTimeoutFlags flags,
uint timeout,
out IntPtr result
);
public static IntPtr NotifyOS()
{
IntPtr result;
//修改后发送一个消息给系统
//调用
SendMessageTimeout(
new IntPtr(HWND_BROADCAST),
WM_SETTINGCHANGE,
IntPtr.Zero,
IntPtr.Zero,
SendMessageTimeoutFlags.SMTO_NORMAL,
1000,
out result);
return result;
}
}
}
以上代码 是在网上查找到的 不过我在本机上测试 执行该函数 一直卡主超时,操作系统为Win7 64位,求测试 ,求修改注册表后不重启立即生效的方法!!!
|