什么可能导致SHChangeNotifyRegister在Windows Mobile上失败?

时间:2009-09-24 06:30:13

标签: c# .net-3.5 windows-mobile visual-c++

我有以下代码:

SHChangeNotifyEntry changeentry = new SHChangeNotifyEntry();




        changeentry.pIdl = GetPidlFromFolderID(this.Handle, CSIDL.CSIDL_DESKTOP);
        changeentry.Recursively = true;


             uint notifyid = SHChangeNotifyRegister(
             this.Handle,
             SHCNF.SHCNF_PATHA ,
             SHCNE.SHCNE_ALLEVENTS,
             WM_SHNOTIFY,
             1,
             ref changeentry);

我的代码在SHChangeNotifyRegister崩溃了。我正在尝试在Windows Mobile中注册一个用于文件更改通知的表单。

我想我可能会将错误的参数传递给SHChangeNotifyRegister。

1 个答案:

答案 0 :(得分:3)

pinvoke.net可以方便地找到dllimport和结构定义,或者至少为它们找到一个起点:)

SHChangeNotifyEntry

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
struct SHChangeNotifyEntry
{
    public IntPtr pIdl;
    [MarshalAs(UnmanagedType.Bool)] public Boolean Recursively;
}

SHChangeNotifyRegister

[DllImport("shell32.dll", SetLastError=true, EntryPoint="#2", CharSet=CharSet.Auto)]
static extern UInt32 SHChangeNotifyRegister(
            IntPtr hWnd,
            SHCNF fSources,
            SHCNE fEvents,
            uint wMsg,
            int cEntries,
            ref SHChangeNotifyEntry pFsne)

正如其他人所说,尝试发布你拥有的dllimports,以及你传递给p / invokes的结构定义,以及你得到的确切错误消息/异常。