delphi 获取360极速浏览器url
时间: 2023-08-04 22:08:38 浏览: 228
Delphi嵌套IE网页
3星 · 编辑精心推荐
以下是使用 Delphi 获取 360 极速浏览器当前打开标签页的 URL 的示例代码:
```
uses
Winapi.Windows, Winapi.ShellAPI;
function Get360ChromeURL: string;
var
ShellWindow: HWND;
ShellChildWindow: HWND;
ChromeWindow: HWND;
ChromeChildWindow: HWND;
ChromeAddressBar: HWND;
ChromeAddressBarLength: Integer;
ChromeAddressBarText: string;
begin
Result := '';
ShellWindow := GetShellWindow;
if ShellWindow <> 0 then
begin
ShellChildWindow := GetWindow(ShellWindow, GW_CHILD);
while ShellChildWindow <> 0 do
begin
ChromeWindow := FindWindowEx(ShellChildWindow, 0, 'Chrome_WidgetWin_1', nil);
if ChromeWindow <> 0 then
begin
ChromeChildWindow := FindWindowEx(ChromeWindow, 0, 'Chrome_RenderWidgetHostHWND', nil);
if ChromeChildWindow <> 0 then
begin
ChromeAddressBar := FindWindowEx(ChromeChildWindow, 0, 'Chrome_OmniboxView', nil);
if ChromeAddressBar <> 0 then
begin
ChromeAddressBarLength := GetWindowTextLength(ChromeAddressBar);
SetLength(ChromeAddressBarText, ChromeAddressBarLength + 1);
GetWindowText(ChromeAddressBar, PChar(ChromeAddressBarText), ChromeAddressBarLength + 1);
Result := ChromeAddressBarText;
Break;
end;
end;
end;
ShellChildWindow := GetWindow(ShellChildWindow, GW_HWNDNEXT);
end;
end;
end;
```
该代码使用 Windows API 函数查找 360 极速浏览器主窗口的子窗口,然后找到 URL 地址栏控件,并获取其文本内容作为当前打开标签页的 URL。
阅读全文