Programming/Delphi

현재 떠있는 익스플로러 타이틀과 URL 가져오기

통통만두 2010. 12. 16. 20:32
반응형
function GetWebBrowserURL: String;
var
   m_WebBrowser                     : IWebBrowser2;
   ShellWindow                      : IShellWindows;
   WebIE                            : OleVariant;
   TmpIE                            : OleVariant;
   Loop                             : Integer;
begin
   ShellWindow := CoShellWindows.Create;

   try
      for Loop := ShellWindow.Count-1 downto 0 do
      begin
         WebIE := ShellWindow.Item( Loop );
         if not Assigned( IDispatch(WebIE) ) then Continue;
         if (IDispatch(WebIE).QueryInterface(IWebBrowser2, m_WebBrowser) = S_OK) then
         begin
            if (Trim(m_WebBrowser.LocationURL) = '') or (Copy(m_WebBrowser.LocationURL, 1, 6) = 'file:/') then Continue;

            Result := Format('%s' + _URL_CHAR_LEFT + '%s' + _URL_CHAR_RIGHT + '%s', [Result, m_WebBrowser.LocationName, m_WebBrowser.LocationURL]);
         end;
      end;

      if Copy(Result, 1, 1) = _URL_CHAR_LEFT then
         Delete(Result, 1, 1);

   finally
      ShellWindow := nil;
   end;
end;
반응형

'Programming > Delphi' 카테고리의 다른 글

로컬 아이피 알아내기  (0) 2010.12.16
파일 버전 알아내기  (0) 2010.12.16
사운드 플레이  (0) 2010.12.16
임시폴더 경로 구하기  (0) 2010.12.16
프로그램 중복실행 방지  (0) 2010.12.16