如何通过程序导入导出ie得cookie ( 积分: 100 )

  • 主题发起人 主题发起人 PowerVR
  • 开始时间 开始时间
P

PowerVR

Unregistered / Unconfirmed
GUEST, unregistred user!
尝试了好久都没有对应的办法:(
 
尝试了好久都没有对应的办法:(
 
这是mainfromunit.DFM
object MainForm: TMainForm
Left = 192
Top = 107
BorderStyle = bsDialog
Caption = 'Explorer Cookies'
ClientHeight = 413
ClientWidth = 437
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 8
Top = 8
Width = 84
Height = 13
Caption = '&Explorer Cookies:'
FocusControl = ListBox1
end
object Label2: TLabel
Left = 8
Top = 192
Width = 26
Height = 13
Caption = '&Text:'
FocusControl = Memo1
end
object ListBox1: TListBox
Left = 8
Top = 24
Width = 425
Height = 161
ItemHeight = 13
PopupMenu = CookiesPopup
TabOrder = 0
OnClick = ListBox1Click
end
object Memo1: TMemo
Left = 8
Top = 208
Width = 425
Height = 177
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Courier'
Font.Style = []
Lines.Strings = (
'Memo1')
ParentFont = False
ScrollBars = ssVertical
TabOrder = 1
end
object Actions: TActionList
Left = 8
Top = 384
object LoadCookies: TAction
Caption = '&Load Cookies'
OnExecute = LoadCookiesExecute
end
object DeleteCookie: TAction
Caption = '&Delete Cookie'
OnExecute = DeleteCookieExecute
OnUpdate = DeleteCookieUpdate
end
object SearchCookie: TAction
Caption = '&Search Cookie...'
OnExecute = SearchCookieExecute
end
end
object CookiesPopup: TPopupMenu
Left = 40
Top = 384
object DeleteCookiePopup: TMenuItem
Action = DeleteCookie
end
object LoadCookiesPopup: TMenuItem
Action = LoadCookies
end
object SearchCookie1: TMenuItem
Action = SearchCookie
end
end
end
这是mainfromunit.PAS
unit MainFormUnit;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActnList, Menus;

type
TMainForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
ListBox1: TListBox;
Memo1: TMemo;
Actions: TActionList;
LoadCookies: TAction;
CookiesPopup: TPopupMenu;
DeleteCookie: TAction;
DeleteCookiePopup: TMenuItem;
LoadCookiesPopup: TMenuItem;
SearchCookie: TAction;
SearchCookie1: TMenuItem;
procedure LoadCookiesExecute(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure DeleteCookieUpdate(Sender: TObject);
procedure DeleteCookieExecute(Sender: TObject);
procedure SearchCookieExecute(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
Folder: string;
end;

var
MainForm: TMainForm;

implementation

uses Registry;

{$R *.DFM}

function CookieFolder: string;
const
SCookieKey = '/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders';
var
Reg: TRegistry;
begin
Result := '';
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
if Reg.OpenKey(SCookieKey, False) then
Result := Reg.ReadString('Cookies');
finally
Reg.Free;
end;
end;

procedure TMainForm.LoadCookiesExecute(Sender: TObject);
var
Found: Integer;
SearchRec: TSearchRec;
Strings: TStrings;
begin
Strings := ListBox1.Items;
Strings.Clear;
Folder := CookieFolder;
Found := FindFirst(Folder + '/*.txt', faAnyFile, SearchRec);
while Found = 0 do begin
if (SearchRec.Attr and faDirectory) = 0 then
Strings.Add(SearchRec.Name);
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
LoadCookies.Execute;
end;

procedure TMainForm.ListBox1Click(Sender: TObject);
var
FileName: string;
begin
if ListBox1.ItemIndex = -1 then exit;
FileName := Folder + '/' + ListBox1.Items[ListBox1.ItemIndex];
try
Memo1.Lines.LoadFromFile(FileName);
except
on E: Exception do begin
Memo1.Lines.Clear;
Memo1.Lines.Add(E.Message);
end;
end;
end;

procedure TMainForm.DeleteCookieUpdate(Sender: TObject);
begin
(Sender as TAction).Enabled := ListBox1.ItemIndex <> -1;
end;

procedure TMainForm.DeleteCookieExecute(Sender: TObject);
var
FileName: string;
begin
FileName := Folder + '/' + ListBox1.Items[ListBox1.ItemIndex];
DeleteFile(FileName);
ListBox1.Items.Delete(ListBox1.ItemIndex);
end;

procedure TMainForm.SearchCookieExecute(Sender: TObject);
var
ACookie: string;
i: Integer;
begin
if not InputQuery('Search Cookie', 'What cookie would you search for?',
ACookie) then Exit;
ACookie := UpperCase(ACookie);
for i := 0 to ListBox1.Items.Count - 1 do begin
if Pos(ACookie, UpperCase(ListBox1.Items)) > 0 then begin
ListBox1.ItemIndex := i;
ListBox1Click(Self);
Exit;
end;
end;
end;

end.
这是程序 ExplorerCookies.dpr
program ExplorerCookies;

uses
Forms,
MainFormUnit in 'MainFormUnit.pas' {MainForm};

{$R *.RES}

begin
Application.Initialize;
Application.Title := 'Explorer Cookies';
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
全部存成文件,编译就行了
来源于超级猛料2003,像这种东西找超级猛料2003,里边差不多都有
 
谢谢,好久没有碰delphi,所以没有得到最新的超级猛料2003,有下载地址嘛?
 
可能我没有说明,我意思是导入cookie,让IE接受这个cookie
 
你如果能知道COOKIE里放的里些什么,可以自己建一个呀
http://download.chinaitlab.com/soft/8497.htm
http://www.playicq.com/1/5862.html
还有你用GOOGLE搜一个超级猛料就有很多
 
下载了,不过里面没有写怎么导入
自己建立得ie不接受呢
 
在MSDN中有Internet API,就是定义在Wininet.pas中的函数。
其中有InternetSetCookie和InternetGetCookie,so....:)
注意:用InternetSetCookie如果没有设expire的话,程序退出Cookie就会过期
 
接受答案了.
 
后退
顶部