如何提取当前浏览器窗口中地址栏内的url内容呢?(100)

  • 主题发起人 主题发起人 shijies
  • 开始时间 开始时间
S

shijies

Unregistered / Unconfirmed
GUEST, unregistred user!
找到了以下代码,却不能通过编译。function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall; var buffer: array[0..255] of char; begin Result := True; GetClassName(hwnd,buffer,256); if StrPas(Buffer)=/'Edit/' then begin SendMessage(hwnd,WM_GETTEXT,256,lparam); Result:=False; end; end; //SendMessage+WM_GETTEXT procedure TForm1.Button1Click(Sender: TObject); var hwnd: Integer; buffer: array[0..255] of char; begin hwnd := FindWindow(/'CabinetWClass/',nil); if hwnd< > 0 then begin EnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0])); Caption := StrPas(buffer); end; end;
 
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); varhwnd: Integer;buffer: array[0..255] of char;beginhwnd := FindWindow('IEFrame',nil);if hwnd<> 0 thenbeginEnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0]));Edit1.text:= StrPas(buffer);end;end;function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean;varbuffer: array[0..255] of char;beginResult := True;GetClassName(hwnd,buffer,256);if StrPas(Buffer)='Edit' thenbeginSendMessage(hwnd,WM_GETTEXT,256,lparam);Result:=False;end;end;end.[Error] Unit1.pas(36): Variable required[Error] Unit1.pas(14): Unsatisfied forward or external declaration: 'TForm1.EnumChildWindowsProc'[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
 
这样也不行。unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; procedure Button1Click(Sender: TObject); function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall; private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); varhwnd: Integer;buffer: array[0..255] of char;beginhwnd := FindWindow('IEFrame',nil);if hwnd<> 0 thenbeginEnumChildWindows(hwnd,@EnumChildWindowsProc,Integer(@buffer[0]));Edit1.text:= StrPas(buffer);end;end;function Tform1.EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;varbuffer: array[0..255] of char;beginResult := True;GetClassName(hwnd,buffer,256);if StrPas(Buffer)='Edit' thenbeginSendMessage(hwnd,WM_GETTEXT,256,lparam);Result:=False;end;end;end.[Error] Unit1.pas(36): Variable required[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
 

Similar threads

后退
顶部