- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi TWebBrowser 获取cookie
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
Memo1: TMemo;
PJWeb: TWebBrowser;
Button1: TButton;
Button2: TButton;
procedure PJWebNewWindow2(ASender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses ActiveX, MSHTML, ShellAPI;
procedure TForm1.Button1Click(Sender: TObject);
var
doc, doc1: IHTMLDocument2;
all: IHTMLElementCollection;
len, i, j, L: integer;
begin
doc := pjweb.Document as IHTMLDocument2;
memo1.Text := doc.cookie;
// doc.cookie := '11111111111111111111111';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
PJWeb.Navigate('http://www.delphitop.com/');
end;
procedure TForm1.PJWebNewWindow2(ASender: TObject; var ppDisp: IDispatch;
var Cancel: WordBool);
begin
Cancel := true;
end;
end.