Ejemplo n.º 1
0
        public int GetFocusedIndex()
        {
            int focusedIndex;

            return(folderView != null && folderView.GetFocusedItem(out focusedIndex) == 0
                    ? focusedIndex : -1);
        }
Ejemplo n.º 2
0
        void Test()
        {
            ShellWindows shellWindows = new ShellWindows();

            try
            {
                foreach (IWebBrowser2 win in shellWindows)
                {
                    WinAPI.IServiceProvider sp = win as WinAPI.IServiceProvider;
                    object sb;
                    sp.QueryService(SID_STopLevelBrowser, typeof(IShellBrowser).GUID, out sb);


                    IShellBrowser shellBrowser = (IShellBrowser)sb;
                    IShellView    sv;
                    shellBrowser.QueryActiveShellView(out sv);
                    Console.WriteLine(win.LocationURL + " " + win.LocationName);
                    IFolderView fv = sv as IFolderView;

                    if (fv != null)
                    {
                        Timer t = new Timer();
                        t.Interval = 200;
                        t.Tick    += (o, se) => {
                            int fitem;
                            if (0 == fv.GetFocusedItem(out fitem))
                            {
                                IntPtr pid;
                                if (0 == fv.Item(fitem, out pid))
                                {
                                    //invokea(pid);
                                }

                                Marshal.FreeHGlobal(pid);
                            }
                        };
                        t.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                if (shellWindows != null)
                {
                    Marshal.ReleaseComObject(shellWindows);
                }
            }
        }