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 解决android 9上无法使用http协议

wmi技术介绍和应用

Delphi winapi: gettickcount - 获取系统已启动的时间

Delphi nethttpclient1 数据库查询

Delphi ioutils单元查找文件夹高级功能

Delphi图像数据压缩解压缩实例

Delphi fmx 获取控件句柄

Delphi 获取汉字拼音首字母

Delphi 程序启动后隐藏窗体和任务栏

Delphi pchar和array [0..255] of char的区别

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



打赏

取消

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

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

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

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

评论

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