Einzelnen Beitrag anzeigen

Benutzerbild von bitsetter
bitsetter

Registriert seit: 17. Jan 2007
1.169 Beiträge
 
Turbo Delphi für Win32
 
#4

Re: Windows Explorer Pfad in der Adressleiste ermitteltn

  Alt 10. Dez 2007, 21:57
Hi,

folgendes funktioniert bei mir unter Windows XP und Win98:
Delphi-Quellcode:
uses SHDocVw_TLB;

var
  ShellWin: IShellWindows;
  i: Integer;
  ClName: array[0..64]of Char;
  Pfad: AnsiString;
begin
  ShellWin := CoShellWindows.Create;
  for i := 0 to Pred(ShellWin.Count) do
    with ShellWin.Item(i) as IWebBrowser2 do
    begin
      GetClassName(hwnd, ClName, SizeOf(ClName));
      if (string(ClName)= 'ExploreWClass') or (string(ClName)= 'CabinetWClass') then
      begin
        Pfad:= StringReplace(LocationURL, 'file:///', '', [rfReplaceAll, rfIgnoreCase]);
        Pfad:= StringReplace(Pfad, '/', '\', [rfReplaceAll]);
        Pfad:= StringReplace(Pfad, '%20', ' ', [rfReplaceAll]);
        if DirectoryExists(Pfad) then
          ListBox1.Items.Add(IncludeTrailingPathDelimiter(Pfad));
        //ListBox1.Items.Add(Format('%d %s %s', [HWND, LocationURL, LocationName]))
      end;
    end;
Gruß bitsetter
"Viele Wege führen nach Rom"
Wolfgang Mocker (geb. 1954), dt. Satiriker und Aphoristiker
  Mit Zitat antworten Zitat