delphi 获取360极速浏览器url
时间: 2023-08-04 13:08:38 浏览: 36
您可以使用以下代码来获取360极速浏览器当前打开的页面的 URL:
```
uses
ShellAPI;
function Get360BrowserURL: string;
var
hWnd: HWND;
IEHandle: HWND;
begin
Result := '';
hWnd := FindWindow('360Chrome_WidgetWin_1', nil);
if hWnd <> 0 then
begin
IEHandle := FindWindowEx(hWnd, 0, 'Chrome_WidgetWin_1', nil);
if IEHandle <> 0 then
begin
Result := '';
SetLength(Result, MAX_PATH);
SendMessage(IEHandle, WM_GETTEXT, MAX_PATH, LPARAM(PChar(Result)));
Result := PChar(Result);
end;
end;
end;
```
该代码首先通过 `FindWindow` 函数获取 360 极速浏览器的主窗口句柄,然后通过 `FindWindowEx` 函数找到浏览器窗口中的 IE 控件句柄。最后,通过 `SendMessage` 函数发送 `WM_GETTEXT` 消息获取当前页面的 URL。
相关问题
delphi 获取360极速浏览器的当前url
您好,获取360极速浏览器的当前URL,可以通过以下代码实现:
```
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
const
WM_COPYDATA = $004A;
type
TCopyDataStruct = record
dwData: ULONG_PTR;
cbData: DWORD;
lpData: Pointer;
end;
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function Get360BrowserURL: string;
function WMCopyDataHandler(var Msg: TMessage): Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.Get360BrowserURL: string;
var
h360Browser: HWND;
cds: TCopyDataStruct;
retData: PChar;
begin
Result := '';
h360Browser := FindWindow('360se6_Frame', nil); // 查找360极速浏览器的窗口句柄
if h360Browser <> 0 then
begin
ZeroMemory(@cds, SizeOf(cds));
cds.dwData := 0;
cds.lpData := 'GetTabUrl';
cds.cbData := (Length(cds.lpData) + 1) * SizeOf(Char);
retData := AllocMem(1024);
try
if SendMessage(h360Browser, WM_COPYDATA, Integer(Handle), Integer(@cds)) > 0 then
begin
Result := retData;
end;
finally
FreeMem(retData);
end;
end;
end;
function TForm1.WMCopyDataHandler(var Msg: TMessage): Boolean;
var
CDS: PCopyDataStruct;
begin
Result := False;
if Msg.Msg = WM_COPYDATA then
begin
CDS := PCopyDataStruct(Msg.LParam);
if CDS^.dwData = 0 then
begin
Memo1.Lines.Add(PChar(CDS^.lpData));
Result := True;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Add(Get360BrowserURL);
end;
```
以上代码中,主要是通过 FindWindow 函数查找360极速浏览器的窗口句柄,然后通过 SendMessage 函数向浏览器进程发送消息,获取当前选项卡的URL。注意,使用 SendMessage 函数需要在 Form1 类中添加一个消息处理函数 WM_COPYDATA。
用delphi获取chrome浏览器的当前url
可以通过以下代码获取Chrome浏览器的当前URL:
```delphi
uses
ActiveX, SHDocVw;
function GetCurrentChromeURL: string;
var
ShellWindows: IShellWindows;
IE: IWebbrowser2;
URL: OleVariant;
ItemIndex: Integer;
begin
Result := '';
ShellWindows := CoShellWindows.Create;
for ItemIndex := 0 to ShellWindows.Count - 1 do
begin
if Supports(ShellWindows.Item(ItemIndex), IWebbrowser2, IE) then
begin
if (IE.FullName = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe') or
(IE.FullName = 'C:\Program Files\Google\Chrome\Application\chrome.exe') then
begin
URL := IE.Document.LocationURL;
Result := URL;
Break;
end;
end;
end;
end;
```
注意需要在程序中引入 `ActiveX` 和 `SHDocVw` 单元。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)