WinCE注册表值监视器

时间:2012-06-06 20:25:08

标签: c# events registry

晚上好,

我需要一些关于在WinCE中监控注册表值的建议。我正在编写一个Windows窗体应用程序,它需要监视注册表中的值,并在事件发生变化时触发事件,是否有人能指出我正确的方向如何实现这一目标?

非常感谢提前。

1 个答案:

答案 0 :(得分:0)

我设法使用PInvoke代码实现了这个:

   [DllImport("coredll.dll", SetLastError = true)]
    static extern int RegOpenKeyEx(UIntPtr hKey, string lpSubKey, uint ulOptions, int samDesired, out UIntPtr phkResult);

    [DllImport("coredll.dll", SetLastError = true)]
    static extern UIntPtr CeFindFirstRegChange(UIntPtr hKey, [In, MarshalAs(UnmanagedType.Bool)] bool bWatchSubtree, uint dwNotifyFilter);

    [DllImport("coredll.dll", SetLastError = true)]
    public static extern UInt32 WaitForSingleObject(UIntPtr Handle, UInt32 Wait);

    [DllImport("coredll.dll", SetLastError = true)]
    static extern Int32 CeFindNextRegChange(UIntPtr hChangeHandle);

    [DllImport("coredll.dll", SetLastError = true)]
    static extern Int32 CeFindCloseRegChange(UIntPtr hChangeHandle);

    [DllImport("coredll.dll", SetLastError = true)]
    public static extern int RegCloseKey(UIntPtr hKey);

并使用WaitForSingleObject。