Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following code:

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);

My code is crashing at the SHChangeNotifyRegister. I am trying to register a form for file change notification in Windows Mobile.

I think I may be passing incorrect parameters to SHChangeNotifyRegister.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
211 views
Welcome To Ask or Share your Answers For Others

1 Answer

pinvoke.net is handy for finding out dllimport and structure definitions, or at the very least getting a starting point for them :)

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)

As others have said, try posting the dllimports you have, and the structure definitions that you are passing into the p/invokes, and the exact error messages/exceptions you are getting.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...