コード例 #1
4
ファイル: WindowMgr.cs プロジェクト: millsy/Process-Capture
        public string GetURL(int hwnd)
        {
            ShellWindows sw = new ShellWindows();
            
            IEnumerator windows = new ShellWindowsClass().GetEnumerator();
            while (windows.MoveNext())
            {
                if ((windows.Current as IWebBrowser2).HWND == hwnd)
                {
                    if ((windows.Current is IWebBrowser2))
                    {
                        IntPtr hw; 
                        IOleWindow win = ((windows.Current as IWebBrowser2).Document as IOleWindow);
                        if (win != null)
                        {
                            win.GetWindow(out hw);

                            if (IsWindowVisible(hw))
                            {
                                string activeTabUrl = ((windows.Current as IWebBrowser2).Document as mshtml.IHTMLDocument2).url;
                                return activeTabUrl;
                            }
                        }
                        else
                        {
                            return (windows.Current as IWebBrowser2).LocationURL;
                        }
                    }
                }
            }

            return "n/a";
        }