准备用C#写一个类似资源管理器的控件,我参考了Implementing IShellBrowser to host IShellView
http://www.codeproject.com/shell/explorer.asp实现方法简介
1、窗体实现IShellBrowser接口,IShellBrowser.GetWindow返回了这个窗体的句柄
   IShellBrowser中的其他方法只是简单的返回-1;
2、调用IShellFolder.CreateViewObject,得到IShellView指针
3、调用IShellView.CreateViewWindow,创建显示子控件
4、view.UIActivate(SVUIA_ACTIVATE_FOCUS),显示改控件运行后能在窗体上显示出来一个资源管理器的子窗口, 现在的问题是在这个窗口上操作有60%左右的几率会出现下面的错误
=========================================================================
System.AccessViolationException was unhandled
  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at TEST.Program.Main() in C:\Documents and Settings\Chenjian\桌面\TestBrowser\TEST\Program.cs:line 17
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()=========================================================================
我怀疑我的IShellBrowser借口定义有问题
=========================================================================
    [StructLayout(LayoutKind.Sequential, Pack = 4)]
    public struct OLEMENUGROUPWIDTHS
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public int[] width;
    }[ComImport(), Guid("000214E2-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IShellBrowser
    {
        [PreserveSig]
        uint GetWindow(out IntPtr phwnd);        [PreserveSig]
        uint ContextSensitiveHelp(int fEnterMode);        [PreserveSig]
        uint InsertMenusSB(
            [In]
            IntPtr hmenuShared,
            [In, Out, MarshalAs(UnmanagedType.LPArray)] 
            OLEMENUGROUPWIDTHS[] lpMenuWidths);        [PreserveSig]
        uint SetMenuSB(IntPtr hmenuShared, IntPtr holemenuRes, IntPtr hwndActiveObject);        [PreserveSig]
        uint RemoveMenusSB(IntPtr hmenuShared);        uint SetStatusTextSB(
            [In, MarshalAs(UnmanagedType.LPWStr)] 
            string pszStatusText);        [PreserveSig]
        uint EnableModelessSB(int fEnable);        [PreserveSig]
        uint TranslateAcceleratorSB(IntPtr pmsg, short wID);        [PreserveSig]
        uint BrowseObject(IntPtr pidl, uint wFlags);        [PreserveSig]
        uint GetViewStateStream(uint grfMode, ref IntPtr ppStrm);        [PreserveSig]
        uint GetControlWindow(uint id, out IntPtr phwnd);        [PreserveSig]
        uint SendControlMsg(uint id, uint uMsg, int wParam, int lParam, ref int pret);        [PreserveSig]
        uint QueryActiveShellView(IntPtr ppshv);        [PreserveSig]
        uint OnViewWindowActive(IShellView pshv);        [PreserveSig]
        uint SetToolbarItems(IntPtr lpButtons, uint nButtons, uint uFlags);
    }
=========================================================================请帮我看看IShellBrowser接口定义的有没有问题