// 我这个博客转载这么多技术性文章,是为了以后学习要用,到时候遇到困难,不需要东找西拼。-__- ~真是不简单啊~。
1、更改webbrowser的cookie路径
2、延时1秒,启动webbrowser
3、更改webbrowser的cookie路径为原来的
4、登录账号
5、记录下cookie
6、设置cookie, internetsetcookie
7、测试是否成功
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses unitFunc;
function GetIECookiePath():string;
var
UserProfile :string;
Key ,Name ,CookiePath ,CachePath :string;
begin
UserProfile := GetEnvironmentVariable('USERPROFILE'); //获取环境变量
//...1、Cookies 文件夹路径
Key := 'Software/Microsoft/Windows/CurrentVersion/Explorer/User Shell Folders';
Name := 'Cookies';
CookiePath := regRead(HKEY_CURRENT_USER ,Key ,Name);
CookiePath := StringReplace(CookiePath,'%USERPROFILE%',UserProfile,[rfReplaceAll]);
//...2、Cache 文件夹路径
Key := 'Software/Microsoft/Windows/CurrentVersion/Explorer/User Shell Folders';
Name := 'Cache';
CachePath := regRead(HKEY_CURRENT_USER ,Key ,Name);
CachePath := StringReplace(CachePath,'%USERPROFILE%',UserProfile,[rfReplaceAll]);
Result := CookiePath;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
CookiePath :string;
fs :TFileStream;
ms :TMemoryStream;
ss :TStringStream;
begin
CookiePath := GetIECookiePath + '/index.dat';
fs := TFileStream.Create(CookiePath,fmShareDenyNone);
ms := TMemoryStream.Create;
ss := TStringStream.Create('');
try
fs.Position := 0;
ms.CopyFrom(fs,fs.Size);
fs.Position := 0;
ss.CopyFrom(fs,fs.Size);
finally
fs.Free;
end;
memo1.Text := ss.DataString;
ss.Free;
ms.Free;
end;
end.
http://hi.baidu.com/vovolololo/blog/item/86d9a402d14a2182d43f7c5b.html
资料:
%WINDIR% {系统目录 - C:/WINDOWS}
%SYSTEMROOT% {系统目录 - C:/WINDOWS}
%SYSTEMDRIVE% {系统根目录 - C:}
%HOMEDRIVE% {当前用户根目录 - C:}
%USERPROFILE% {当前用户目录 - C:/Documents and Settings/wy}
%HOMEPATH% {当前用户路径 - /Documents and Settings/wy}
%TMP% {当前用户临时文件夹 - C:/DOCUME~1/wy/LOCALS~1/Temp}
%TEMP% {当前用户临时文件夹 - C:/DOCUME~1/wy/LOCALS~1/Temp}
%APPDATA% {当前用户数据文件夹 - C:/Documents and Settings/wy/Application Data}
%PROGRAMFILES% {程序默认安装目录 - C:/Program Files}
%COMMONPROGRAMFILES% {文件通用目录 - C:/Program Files/Common Files}
%USERNAME% {当前用户名 - wy}
%ALLUSERSPROFILE% {所有用户文件目录 - C:/Documents and Settings/All Users}
%OS% {操作系统名 - Windows_NT}
%COMPUTERNAME% {计算机名 - IBM-B63851E95C9}
%NUMBER_OF_PROCESSORS% {处理器个数 - 1}
%PROCESSOR_ARCHITECTURE% {处理器芯片架构 - x86}
%PROCESSOR_LEVEL% {处理器型号 - 6}
%PROCESSOR_REVISION% {处理器修订号 - 0905}
%USERDOMAIN% {包含用户帐号的域 - IBM-B63851E95C9}
%COMSPEC% {C:/WINDOWS/system32/cmd.exe}
%PATHEXT% {执行文件类型 - .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.pyo;.pyc;.py;.pyw}
%PATH% {搜索路径}
例如将一个带背景的LABEL变成一个TIMAGE图片类型,可以这样做:
image1.width:=label1.width;
image1.height:=label1.height;
label1.perform(WM_PAINT,image1.Canvas.Handle,0);