辛亥百年纪念 - 产品组件系列01

本文介绍了一个使用Delphi编程语言实现的功能组件,该组件通过读取注册表的相关键值并按照特定顺序组合,用于密码的安全存放。具体过程包括定位密码位置、解析日期、验证安装信息以及组合关键字符串等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

“天下为公”

---------------------------

《读取注册表信息》

此组件目的:读取相关键值,并按照一定的顺序组合他们。

此组件用途:密码存放


==Code=========

{*-------------------------------------------------------------------------- Delphi菜鸟XiaoBin 2006.5.31于黑龙江草甸子 http://blog.youkuaiyun.com/xiaobin_hlj80 veic_2005@163.com --------------------------------------------------------------------------*} unit UreadReg; interface uses Windows, SysUtils, Registry, Classes, Forms, StrUtils; // type TreadXBF=function(DimRecord: Integer;filename1:WideString):WideString;stdcall; // var myreg:TRegistry; childstr1,childstr6:string[1]; childstr4,childstr5:string[2]; childstr2,childstr3:string[4]; installbool:Boolean; connstring:TreadXBF; Function readREG(xbf:WideString):WideString; implementation Function readREG(xbf:WideString):WideString; var XBFconnect:string; XBFconn1,REGconn2,XBFconn3:string; tempregbin:array [0..15]of char; XBFlen:integer; h1:THandle; // P : PChar; Err : DWord; ErrStr:string; year,month,day,DOW:Word; dayStr,monthStr:string; nowdate:string; installdate:string; TimeLag:integer; //2007.1.6定位密码位置 pwdCoordinate:integer; begin myreg:=TRegistry.Create; with myreg.Create do begin myreg.RootKey:=HKEY_LOCAL_MACHINE; if not OpenKey('SoftWare\veic\cps',False)then begin Application.MessageBox('操作系统出现问题或人为恶意改动!','OS ERROR',MB_OK); CloseKey; Application.Terminate; end; //内嵌过程start P := pchar('yyyy-MM-dd'); if SetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SSHORTDATE,P) then begin // end else begin Err := GetLastError; case Err of ERROR_INVALID_ACCESS : ErrStr:='INVALID_ACCESS'; ERROR_INVALID_FLAGS : ErrStr:='INVALID_FLAGS'; ERROR_INVALID_PARAMETER : ErrStr:='INVALID_PARAMETER'; end; end; DecodeDateFully(Now,year,month,day,DOW); if month<10 then begin monthStr:='0'+IntToStr(month); end else monthStr:=IntToStr(month); if day<10 then begin dayStr:='0'+IntToStr(day); end else dayStr:= IntToStr(day); nowdate:=IntToStr(year)+monthStr+dayStr; if ValueExists('InstallDate')then begin installdate:=myreg.ReadString('InstallDate'); TimeLag:=StrToInt(nowdate)-StrToInt(installdate); DateTimeToFileDate(Now); //判断时间差(begin) if TimeLag>300000 then begin // end; //判断时间差(end) end else begin installbool:=True; Application.MessageBox('丢失安装信息,程序无法运行!','OS ERROR',MB_OK); Application.Terminate; end; //内嵌过程stop if ValueExists('support1')then begin myreg.ReadBinaryData('support1',tempregbin,4); childstr1:= tempregbin end else begin installbool:=True; exit; end; if ValueExists('support2')then begin myreg.ReadBinaryData('support2',tempregbin,16); childstr2:= tempregbin end else begin installbool:=True; exit; end; if ValueExists('support3')then begin myreg.ReadBinaryData('support3',tempregbin,16); childstr3:= tempregbin end else begin installbool:=True; exit; end; if ValueExists('support4')then begin myreg.ReadBinaryData('support4',tempregbin,8); childstr4:= tempregbin end else begin installbool:=True; exit; end; if ValueExists('support5')then begin myreg.ReadBinaryData('support5',tempregbin,8); childstr5:= tempregbin end else begin installbool:=True; exit; end; if ValueExists('support6')then begin myreg.ReadBinaryData('support6',tempregbin,4); childstr6:= tempregbin end else begin Application.MessageBox('丢失安装信息,程序无法运行!','OS ERROR',MB_OK); installbool:=True; exit; end; end;//withend REGconn2:=childstr2+childstr5+childstr6+childstr1+childstr3+childstr4; try h1:=0; try h1:=LoadLibrary('XBFGenerate.dll'); if h1<>0 then @connstring:=GetprocAddress(h1,'readXBF'); if (@connstring<>nil)then XBFconnect:=connstring(-1,xbf); finally FreeLibrary(h1); end; except Application.MessageBox('配置错误,请重新填写各个值!','提示',MB_OK); Exit; end; //XBFconnect:=readXBF(-1,xbf); XBFconn1:=LeftStr(XBFconnect,29); //2007.1.6定位密码位置 pwdCoordinate:=pos(';Pe',XBFconnect); XBFlen:=length(XBFconnect); XBFconn3:=RightStr(XBFconnect,XBFlen-pwdCoordinate+1); Result:=XBFconn1+REGconn2+XBFconn3; end; end.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值