Delphi里实现获取资源管理器路径以及IE打开网址列表


本文整理自网络,侵删。

 
本文主要是实现在Delphi里如何获取资源管理器打开的路径以及IE打开的地址列表的功能,主要是使用IShellWindows和IWebBrowser2接口,具体代码如下:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses SHDocVw;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  I: integer;
  spDisp: IDispatch;
  IE1: IWebBrowser2;
  ShellWindow: IShellWindows;
begin
  ListBox1.clear;
  ShellWindow := CoShellWindows.Create;
  for I := 0 to ShellWindow.Count - 1 do
  begin
    try
      spDisp := ShellWindow.Item(I);
      if (spDisp <> nil) then
      begin
        spDisp.QueryInterface(IWebBrowser2, IE1);
        if IE1 <> nil then
        begin
          ListBox1.items.add(IE1.Get_LocationURL());
        end;
      end;
    except
      on EAccessViolation do
      begin
        exit
      end;
    end;
  end;
end;

end.
当前使用的Delphi版本:delphi10.2  操作系统window10,运行效果如下:

相关阅读 >>

Delphi topendialog设置多个过滤条件

Delphi twebbrowser静音

Delphi 官方使用并行编程库介绍

Delphi ioutils 获取当前目录下所有的文件/文件夹

Delphi内存映射大文件

Delphi实现类似android锁屏的密码锁控件

Delphi 同时激活两个窗体

Delphi让程序运行后自我删除或恢复名称

Delphi 实现无标题栏但有边框的窗口

Delphi xe5记录android应用程序(日志输出)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...