//实现向网页自动填写用户名密码并自动点击登录按钮 完成全自动凳录Function FillForm(WebBrowser: TWebBrowser2; FieldName: String; Value: String):Boolean;Vari, j: Integer;FormItem: Variant;BeginResult := False;//no form on documentIf WebBrowser.OleObject.Document.all.tags('FORM').Length = 0 ThenBeginExit;End;For I := 0 To WebBrowser.OleObject.Document.forms.Length - 1 DoBeginFormItem := WebBrowser.OleObject.Document.forms.Item(I);For j := 0 To FormItem.Length - 1 DoBeginTry//when the fieldname is found, try to fill outIf FormItem.Item(j).Name = FieldName ThenBeginFormItem.Item(j).Value := Value;Result := True;End;ExceptExit;End;End;End;End;FillForm(浏览器控件名称, 编辑框名称, 内容)
str:=(Webbrowser1.DocumentasIHTMLDocument2).cookie;
----------------------------------------------
TConfig=record
A:Boolean;
B:Integer;
C:Boolean;
D:Integer;
//以此类推非常多,下面还有数组
sName:array[0..8]ofstring;
boUse:array[0..8]ofBoolean;
wNum:array[0..8]ofWord;
end;
var
Config:TConfig=(
A:False;
B:0;
C:True;
D:2;
//以此类推非常多,下面还有数组
sName:('1','2','3','4','5','6','7','8');
boUse:(False,True,False,False,True,False,True,False,False);
wNum:(0,1,0,4,0,3,0,0,0);
);
当定义时,初始了,在程序运行中,需要初始成定义时的数据,只能一个个赋值吗?还是有其它办法吗?
----------------------------------------------
delphi众人拾柴火焰高!支持盒子~~~~~~~~~~
----------------------------------------------
武稀松
----------------------------------------------
/wqyfavor
在程序运行的时候用户可以修改结构中的类型数据用户还可以执行恢复默认设置,当他恢复默认设置的时候能否将这个结构初始化成结构定义那里的值只能一个一个的赋予给结构中的成员吗?
----------------------------------------------
delphi众人拾柴火焰高!支持盒子~~~~~~~~~~
统一值的话,你可以用fillchar
----------------------------------------------
卖源码/item.htm?spm=686.1000925.1000774.16.gmrHsT&id=37407600038每天点一下广告,支持盒子不关闭
----------------------------------------------
/wqyfavor
你还是不懂得我的意识
结构内非常多如果一个一个赋值会很麻烦我想整个RECORD初始值
----------------------------------------------
delphi众人拾柴火焰高!支持盒子~~~~~~~~~~
全局变量或Const定义的常量可以给初始值.
你先定义一个全局变量或常量.
当想赋初始值的时候就等于这个变量或常量不就得了.
----------------------------------------------
武稀松
不过如果有动态数组或者对象引用那肯定是不能直接等于的。
----------------------------------------------
-
----------------------------------------------
兼金软件工作室
----------------------------------------------
cnblogs中我写的关于Delphi的blog,欢迎访问:
/egust/
RecBskyCust=record
Ver:integer;
Cust_ID:integer;
Cust_name:string[40];
Cust_NiName:string[40];
Email:shortstring;
MPhone:string[80];
Phone:string[80];
SFZ:string[18];
pass:string[40];
Func:integer;
Reg_Time:TDateTime;
UpDate_Time:TDateTime;
QQ:integer;
Msn:shortstring;
OtherIM:shortstring;
Company:shortstring;
Area_Code:integer;
PostCode:integer;
Address:shortstring;
CUST_STATES:TPassStates;
Descr:string;
end;
functionCopyRecord(Rs:RecBskyCust;varRD:RecBskyCust):boolean;overload;
begin
Result:=False;
try
DisposeRecord(RD);
System.move(Rs,RD,sizeof(Rs)-sizeof(string));
RD.Descr:=Rs.Descr;
Result:=True;
except
onE:Exceptiondo
Application.MessageBox(PChar(E.Message+'错误号:'+IntToStr(E.HelpContext)),'错误!',MB_OK+MB_ICONERROR+MB_TOPMOST);
end;
end;
functionDisposeRecord(VarR:RecBskyCust):boolean;
begin
Result:=False;
try
R.Descr:='';
zeromemory(@R,sizeof(R));
Result:=True;
except
onE:Exceptiondo
Application.MessageBox(PChar(E.Message+'错误号:'+IntToStr(E.HelpContext)),'错误!',MB_OK+MB_ICONERROR+MB_TOPMOST);
end;
end;
除了string类型还有动态数组和其它指针类型也需要单独处理,所以尽量把这类数据类型放到record的最后
网上有这种代码了,只是因为写的较早,有些地方写的不那么言简意赅,而且在XE后的版本中有问题(因为Unicode字符的关系)
下面是精简修改过的代码,只取第一块硬盘的序列号,Win7 + XE 测试通过。需要先安装JwApi函数库,因为有些结构体在库中有声明了
[delphi]view plain copyunituGetHDSN;interfaceusesWindows,JwaWinIoctl;functionGetIdeSerialNumber:AnsiString;implementationtypeTIdSector=packedrecordwGenConfig:USHORT;wNumCyls:USHORT;wReserved:USHORT;wNumHeads:USHORT;wBytesPerTrack:USHORT;wBytesPerSector:USHORT;wSectorsPerTrack:USHORT;wVendorUnique:array[0..2]ofUSHORT;sSerialNumber:array[0..19]ofAnsiChar;wBufferType:USHORT;wBufferSize:USHORT;wECCSize:USHORT;sFirmwareRev:array[0..7]ofAnsiChar;sModelNumber:array[0..39]ofAnsiChar;wMoreVendorUnique:USHORT;wDoubleWordIO:USHORT;wCapabilities:USHORT;wReserved1:USHORT;wPIOTiming:USHORT;wDMATiming:USHORT;wBS:USHORT;wNumCurrentCyls:USHORT;wNumCurrentHeads:USHORT;wNumCurrentSectorsPerTrack:USHORT;ulCurrentSectorCapacity:ULONG;wMultSectorStuff:USHORT;ulTotalAddressableSectors:ULONG;wSingleWordDMA:USHORT;wMultiWordDMA:USHORT;bReserved:array[0..127]ofByte;end;PIdSector=^TIdSector;constIDE_ATA_IDENTIFY=$EC;functionLittleToBig(Data:Word):Word;asmxchgah,alend;functionGetIdeSerialNumber:AnsiString;varhDevice:THandle;Size,cbBytesReturned:DWORD;SCIP:TSendCmdInParams;SCOP:PSendCmdOutParams;P:PWORD;I:Integer;beginResult:='';hDevice:=CreateFile('\\.\PhysicalDrive0',GENERIC_READorGENERIC_WRITE,FILE_SHARE_READorFILE_SHARE_WRITE,nil,OPEN_EXISTING,0,0);ifhDevice=INVALID_HANDLE_VALUEthenExit;Size:=SizeOf(TSendCmdOutParams)+IDENTIFY_BUFFER_SIZE-1;SCOP:=AllocMem(Size);SCIP.irDriveRegs.bCommandReg:=IDE_ATA_IDENTIFY;ifDeviceIoControl(hDevice,SMART_RCV_DRIVE_DATA,@SCIP,SizeOf(TSendCmdInParams)-1,SCOP,Size,cbBytesReturned,nil)=FalsethenbeginFreeMem(SCOP);CloseHandle(hDevice);Exit;end;//处理一下序列号在内存中的顺序withPIdSector(@SCOP^.bBuffer[0])^dobeginSetLength(Result,Length(sSerialNumber));P:=@Result[1];CopyMemory(P,@sSerialNumber[0],Length(sSerialNumber));forI:=1toLength(sSerialNumber)div2dobeginP^:=LittleToBig(P^);Inc(P);end;end;FreeMem(SCOP);end;end.
盒子 收藏帖子 转移-实现向网页自动填写用户名密码并自动点击登录按钮 完成全自动凳录...