| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> delphi >> yong DELPHI shi xian wen jian jia mi ya suo
 

yong DELPHI shi xian wen jian jia mi ya suo

2007-07-14 04:40:27 编辑來源:互联网 评论
 
本文为【用DELPHI实现文件加密压缩】的拼音翻译版
  yong DELPHI shi xian wen jian jia mi ya suo
  zuo zhe : e meng yuan (wnhoo)
  Mail:wnhoo@163.com
  feng hua xue yue e meng qing yuan
用DELPHI实现文件加密压缩
dian ji xia zai ci xiang xi shuo ming wen jian
  gai shu :
  zai zhe pian wen jian zhong , jiang shu dui dan ge wen jian de shu ju jia mi 、 shu ju ya suo 、 zi jie ya de shi xian 。 tong yang , ye ke yi shi xian dui duo ge wen jian huo wen jian jia de ya suo , zhi yao shao jia xiu gai bian ke shi xian 。
  guan jian zi : jia mi ya suo 、Zlib、 liu 、 zi yuan wen jian
  yin yan :
  zai ri chang zhong , wo men yi ding shi yong guo WINZip、WINRAR zhe yang de chu ming de ya suo ruan jian , jiu shi wo men kai fa ruan jian guo cheng zhong bu mian yao yu dao shu ju jia mi 、 shu ju ya suo de wen ti ! ben wen zhong jiu zhe yi ji shu wen ti zhan kai tan tao , tong shi gan xie ge wei wang you de ji qiao , zai wo mei ci mian dui wen ti yao jie jue de shi hou , shi ni men xin ku di mo suo chu lai de ji qiao zong shi rang wo huo ran kai lang , wen ti ying ren er jie 。 ben pian wen zhang zhu yao shi yun yong DELPH de qiang da de liu chu li fang mian de ji qiao lai shi xian de shu ju jia mi ya suo , bing yong yu shi ji de ruan jian cheng xu kai fa zhong , jiang wo ge ren de xin de 、 kai fa jing yan xie chu lai yu da jia fen xiang 。
  1、 xi tong gong neng
  1)、 shu ju ya suo
  shi yong DELPHI ti gong de liang ge liu lei (TComPRessionStream he TDecompressionStream) lai wan cheng shu ju de ya suo he jie ya suo 。
  2)、 shu ju jia mi ya suo
  tong guo Delphi bian cheng zhong “ liu ” de ying yong shi xian shu ju jia mi , zhu yao cai yong Tstream de liang ge pai sheng lei Tfilestream、Tmemorystream lai wan cheng de ; qi zhong shu ju ya suo bu fen cai yong 1) de shi xian fang fa
  3)、 shuang ji ya suo wen jian zi dong guan lian jie ya
  tong guo geng gai zhu ce biao de shi xian kuo zhan ming yu cheng xu wen jian de guan lian , zhu yao cai yong Tregistry; bing qie ,API han shu SHChangeNotify shi xian zhu ce xiao guo de li ji cheng xian 。
  4)、 ke sheng cheng zi jie ya wen jian
  zi jie ya de wen jian shi xian shu ju ya suo 1) yu shu ju jia mi ya suo 2) de zi dong jie ya ; bing qie , tong guo zi yuan wen jian de shi yong shi xian ke zhi xing de zi jie ya wen jian yu shu ju wen jian de he bing , lai wan cheng shu ju de zi jie ya shi xian 。
  2、 xi tong shi xian
  2.1、 gong zuo yuan li
用DELPHI实现文件加密压缩

  2.2、 guan jian ji shu de jiang shu
  ( yi )ZLIB
  1)、 ji lei TCustomZlibStream: shi lei TCompressionStream he TDecompressionStream lei de ji lei , ta zhu yao you yi ge shu xing : OnProgress, zai lei jin xing ya suo huo jie ya suo de guo cheng zhong hui fa sheng zhe ge de shi jian 。
  ge shi :Procedure OnProgress (Sender: TObject); dynamic;
  2)、 ya suo lei TCompressionStream: chu le ji cheng le ji lei de OnProgress shu xing wai , you zeng jia le yi ge shu xing :CompressionRate, ta de ding yi ru xia :
  Property CompressionRate: Single read GetCompressionRate;
  tong guo zhe ge shu xing , ke yi de dao ya suo bi 。
  ta de ji ge chong yao de fang fa ding yi ru xia :
  Constructor TCompressionStream.Create (CompressionLevel: TCompressionLevel; Dest: TStream);
  qi zhong :TcompressionLevel( ya suo lei xing ), ta you ru xia ji ge ding yi :
  1)、 clNone : bu jin xing shu ju ya suo ;
  2)、 clFastest: jin xing kuai su ya suo , xi sheng ya suo xiao lv ;
  3)、 clDefault: jin xing zheng chang ya suo ;
  4)、 clMax: jin xing zui da hua ya suo , xi sheng su du ;
  Dest: mu de liu , yong yu cun fang ya suo guo de shu ju 。
  Function TCompressionStream.Write (const Buffer; Count: Longint): Longint;
  qi zhong :Buffer: xu yao ya suo de shu ju ;
  Count: xu yao ya suo de shu ju de zi jie shu ;
  han shu fan hui xie ru liu de zi jie shu 。
  zhu yi : ya suo lei TCompressionStream de shu ju zhi neng shi xie ru de , ru guo shi tu cong qi nei bu du qu shu ju , jiang fa sheng yi ge "Error " yi chang 。 xu yao ya suo de shu ju tong guo fang fa Write xie ru liu zhong , zai xie ru de guo cheng zhong jiu bei ya suo , bing bao cun zai you gou zao han shu ti gong de nei cun liu (TmemoryStream) zhong , tong shi chu fa OnProcess shi jian 。
  3)、 jie ya suo lei TDecompressionStream : he ya suo lei TcompressionStream xiang fan , ta de shu ju shi zhi neng du chu de , ru guo shi tu wang qi nei bu xie shu ju , jiang fa sheng yi ge "Error " yi chang 。
  ta de ji ge chong yao fang fa ding yi ru xia :
  gou zao han shu :Constructor Create(Source: TStream);
  qi zhong :Source shi bao cun zhe ya suo shu ju de liu ;
  Function Read(var Buffer; Count: Longint): Longint;
  shu ju du chu han shu ,Buffer: cun shu ju huan chong qu ;Count: huan chong qu de da xiao ;
  han shu fan hui du chu de zi jie shu 。 shu ju zai du chu de guo cheng zhong , shu ju bei jie ya suo , bing chu fa OnProcess shi jian 。
  ( er ) liu
  zai Delphi zhong , suo you liu dui xiang de ji lei wei TStream lei , qi zhong ding yi le suo you liu de gong tong shu xing he fang fa 。
  TStream lei zhong ding yi de shu xing ru xia :
  1)、Size: ci shu xing yi zi jie fan hui liu zhong shu ju da xiao 。
  2)、Position: ci shu xing kong zhi liu zhong cun qu zhi zhen de wei zhi 。
  Tstream zhong ding yi de xu fang fa you si ge :
  1)、Read: ci fang fa shi xian jiang shu ju cong liu zhong du chu , fan hui zhi wei shi ji du chu de zi jie shu , ta ke yi xiao yu huo deng yu zhi ding de zhi 。
  2)、Write: ci fang fa shi xian jiang shu ju xie ru liu zhong , fan hui zhi wei shi ji xie ru liu zhong de zi jie shu 。
  3)、Seek: ci fang fa shi xian liu zhong du qu zhi zhen de yi dong , fan hui zhi wei yi dong hou zhi zhen de wei zhi 。
  han shu yuan xing wei :Function Seek(Offset:Longint;Origint:Word):Longint;virtual;abstract;
  shen shu Offset wei pian yi zi jie shu , shen shu Origint zhi chu Offset de shi ji yi yi , qi ke neng de qu zhi ru xia :
  soFromBeginning:Offset wei zhi zhen ju li shu ju kai shi de wei zhi 。 ci shi Offset bi xu da yu huo zhe deng yu ling 。
  soFromCurrent:Offset wei yi dong hou zhi zhen yu dang qian zhi zhen de xiang dui wei zhi 。
  soFromEnd:Offset wei yi dong hou zhi zhen ju li shu ju jie shu de wei zhi 。 ci shi Offset bi xu xiao yu huo zhe deng yu ling 。
  4)、Setsize: ci fang fa shi xian gai bian shu ju de da xiao 。
  ling wai ,TStream lei zhong huan ding yi le ji ge jing tai fang fa :
  1)、ReadBuffer: ci fang fa de zuo yong shi cong liu zhong dang qian wei zhi du qu shu ju , gen shang mian de Read xiang tong 。
  zhu yi : dang du qu de shu ju zi jie shu yu xu yao du qu de zi jie shu bu xiang tong shi , jiang chan sheng EReadError yi chang 。
  2)、WriteBuffer: ci fang fa de zuo yong shi zai dang qian wei zhi xiang liu xie ru shu ju , gen shang mian de Write xiang tong 。
  zhu yi : dang xie ru de shu ju zi jie shu yu xu yao xie ru de zi jie shu bu xiang tong shi , jiang chan sheng EWriteError yi chang 。
  3)、CopyFrom: ci fang fa de zuo yong shi cong qi ta liu zhong kao bei shu ju liu 。
  han shu yuan xing wei :Function CopyFrom(Source:TStream;Count:Longint):Longint;
  shen shu Source wei ti gong shu ju de liu ,Count wei kao bei de shu ju zi jie shu 。 dang Count da yu 0 shi ,CopyFrom cong Source shen shu de dang qian wei zhi kao bei Count ge zi jie de shu ju ; dang Count deng yu 0 shi ,CopyFrom she zhi Source shen shu de Position shu xing wei 0, ran hou kao bei Source de suo you shu ju ;
  Tstream chang jian pai sheng lei :
  TFileStream ( wen jian liu de cun qu )
  TStringStream ( chu li nei cun zhong de zi fu chuan lei xing shu ju )
  TmemoryStream ( dui yu gong zuo de nei cun qu yu shu ju chu li )
  TBlobStream (BLOB lei xing zi duan de shu ju chu li )
  TwinSocketStream (socket de du xie chu li )
  ToleStream (COM jie kou de shu ju chu li )
  TresourceStream ( zi yuan wen jian liu de chu li )
  qi zhong zui chang yong de shi TFileStream lei 。 shi yong TFileStream lei lai cun qu wen jian , shou xian yao jian li yi ge shi li 。 sheng ming ru xia :
  constructor Create(const Filename:string;Mode:Word);
  Filename wei wen jian ming ( bao kuo lu jing )
  Mode wei da kai wen jian de fang shi , ta bao kuo wen jian de da kai mo shi he gong xiang mo shi , qi ke neng de qu zhi he yi yi ru xia :
  da kai mo shi :
  fmCreate : yong zhi ding de wen jian ming jian li wen jian , ru guo wen jian yi jing cun zai ze da kai ta 。
  fmOpenRead : yi zhi du fang shi da kai zhi ding wen jian
  fmOpenWrite : yi zhi xie fang shi da kai zhi ding wen jian
  fmOpenReadWrite: yi xie xie fang shi da kai zhi ding wen jian
  gong xiang mo shi :
  fmShareCompat : gong xiang mo shi yu FCBs jian rong
  fmShareExclusive: bu yuan xu bie de cheng xu yi ren he fang shi da kai gai wen jian
  fmShareDenyWrite: bu yuan xu bie de cheng xu yi xie fang shi da kai gai wen jian
  fmShareDenyRead : bu yuan xu bie de cheng xu yi du fang shi da kai gai wen jian
  fmShareDenyNone : bie de cheng xu ke yi yi ren he fang shi da kai gai wen jian
  ( san ) zi yuan wen jian
  1)、 chuang jian zi yuan wen jian
  shou xian chuang jian yi ge .Rc de chun wen ben wen jian 。
  ge shi : zi yuan biao shi fu guan jian zi zi yuan wen jian ming
  zi yuan biao shi fu : cheng xu zhong tiao yong zi yuan shi de te shu biao hao ;
  guan jian zi : biao shi zi yuan wen jian lei xing ;
  Wave: zi yuan wen jian shi sheng yin wen jian ;
  RCDATA: JPEG wen jian ;
  AVI: AVI dong hua ;
  ICON: tu biao wen jian ;
  BITMAP: wei tu wen jian ;
  CURSOR: guang biao wen jian ;
  EXEFILE : EXE wen jian
  zi yuan wen jian ming : zi yuan wen jian de zai ci pan shang cun chu de wen jian quan ming
  li ru :
  myzjy exefile zjy.exe
  2)、 bian yi zi yuan wen jian
  zai DELPHI de an zhuang mu lu de \Bin xia , shi yong BRCC32.exe bian yi zi yuan wen jian .RC。 dang ran , ye ke yi jiang BRCC32 dan du kao bei dao cheng xu wen dang mu lu shi yong 。
  li ru :
  Brcc32 wnhoo_reg.Rc
  3)、 zi yuan wen jian yin yong
  …
  implementation
  {$R *.dfm}
  {$R wnhoo_reg.Res}
  …
  4)、 tiao yong zi yuan wen jian
  (1) cun qu zi yuan wen jian zhong de wei tu (Bitmap)
  Image.Picture.Bitmap.Handle :=LoadBitmap(hInstance,' zi yuan biao shi fu ');
  zhu : ru guo wei tu mei you zhuang zai cheng gong , cheng xu reng jiu zhi xing , dan shi Image jiang bu zai xian shi tu pian 。 ni ke yi gen ju LoadBitmap han shu de fan hui zhi pan duan shi fou zhuang zai cheng gong , ru guo zhuang zai cheng gong fan hui zhi shi fei 0, ru guo zhuang zai shi bai fan hui zhi shi 0。
  ling wai yi ge cun qu xian shi wei tu de fang fa ru xia
  Image.Picture.Bitmap.LoadFromResourceName(hInstance,' zi yuan biao shi fu ');
  (2) cun qu zi yuan wen jian zhong de guang biao
  Screen.Cursors[] shi yi ge guang biao shu zu , shi yong guang biao wen jian wo men ke yi jiang ding zhi de guang biao jia ru dao zhe ge shu xing zhong 。 yin wei mo ren de guang biao zai shu zu zhong suo yin zhi shi 0, suo yi chu fei xiang qu dai mo ren guang biao , zui hao jiang ding zhi de guang biao suo yin zhi she wei 1。
  Screen.Cursors[1] :=LoadCursor(hInstance,' zi yuan biao shi fu ');
  Image.Cursor :=1;
  (3) cun qu zi yuan wen jian zhong de tu biao
  jiang tu biao fang zai zi yuan wen jian zhong , ke yi shi xian dong tai gai bian ying yong cheng xu tu biao 。
  application.Icon.Handle := LoadIcon(hInstance,' zi yuan biao shi fu ');
  (4) cun qu zi yuan wen jian zhong de AVI
  Animate.ResName :='MyAvi' ; // zi yuan biao shi fu hao
  Animate.Active :=True ;
  (5) cun qu zi yuan wen jian zhong de JPEG
  ba jpeg dan yuan jia ru dao uses dan yuan zhong 。
  var
  Fjpg : TJpegImage ;
  FStream :TResourceStream ;
  begin
  Fjpg :=TJpegImage.Create ;
  //TresourceStream shi yong
  FStream := TResourceStream.Create (Hinstance,' zi yuan biao shi fu ', zi yuan lei xing ) ;
  FJpg.LoadFromStream (FStream) ;
  Image.Picture.Bitmap.Assign (FJpg);
  (6) cun qu zi yuan wen jian zhong de Wave
  ba MMSystem jia ru uses dan yuan zhong
  PlaySound(pchar('mywav'),Hinstance,Snd_ASync or Snd_Memory or snd_Resource) ;
  ( si )INI wen jian cao zuo
  (1) INI wen jian de jie gou :
  ; zhe shi guan yu INI wen jian de zhu shi bu fen
  [ jie dian ]
  guan jian zi = zhi
  ...
  INI wen jian yuan xu you duo ge jie dian , mei ge jie dian you yuan xu you duo ge guan jian zi , “=” hou mian shi gai guan jian zi de zhi ( lei xing you san zhong : zi fu chuan 、 zheng xing shu zhi he bu er zhi 。 qi zhong zi fu chuan cun zhu zai INI wen jian zhong shi mei you yin hao , bu er zhen zhi yong 1 biao shi , bu er jia zhi yong 0 biao shi )。 zhu shi yi fen hao “;” kai tou 。
  (2) INI wen jian de cao zuo
  1、 zai Interface de Uses jie zeng jia IniFiles;
  2、 zai Var bian liang ding yi bu fen zeng jia yi xing :inifile:Tinifile; ran hou , jiu ke yi dui bian liang myinifile jin xing chuang jian 、 da kai 、 du qu 、 xie ru deng cao zuo le 。
  3、 da kai INI wen jian :inifile:=Tinifile.create('tmp.ini');
  4、 du qu guan jian zi de zhi :
  a:=inifile.Readstring(' jie dian ',' guan jian zi ', que sheng zhi );// string lei xing
  b:=inifile.Readinteger(' jie dian ',' guan jian zi ', que sheng zhi );// integer lei xing
  c:=inifile.Readbool(' jie dian ',' guan jian zi ', que sheng zhi );// boolean lei xing
  qi zhong [ que sheng zhi ] wei gai INI wen jian bu cun zai gai guan jian zi shi fan hui de que sheng zhi 。
  5、 xie ru INI wen jian :
  inifile.writestring(' jie dian ',' guan jian zi ', bian liang huo zi fu chuan zhi );
  inifile.writeinteger(' jie dian ',' guan jian zi ', bian liang huo zheng xing zhi );
  inifile.writebool(' jie dian ',' guan jian zi ', bian liang huo True huo False);
  dang zhe ge INI wen jian de jie dian bu cun zai shi , shang mian de yu ju huan hui zi dong chuang jian gai INI wen jian 。
  6、 shan chu guan jian zi :
  inifile.DeleteKey(' jie dian ',' guan jian zi ');// guan jian zi shan chu
  inifile.EraseSection(' jie dian ');// jie dian shan chu
  7、 jie dian cao zuo :
  inifile.readsection(' jie dian ',TStrings bian liang );// ke jiang zhi ding xiao jie zhong de suo you guan jian zi ming du qu zhi yi ge zi fu chuan lie biao bian liang zhong ;
  inifile.readsections(TStrings bian liang );// ke jiang INI wen jian zhong suo you xiao jie ming du qu zhi yi ge zi fu chuan lie biao bian liang zhong qu 。
  inifile.readsectionvalues(' jie dian ',TStrings bian liang );// ke jiang INI wen jian zhong zhi ding xiao jie de suo you xing ( bao kuo guan jian zi 、=、 zhi ) du qu zhi yi ge zi fu chuan lie biao bian liang zhong qu 。
  8、 shi fang :inifile.distory; huo inifile.free;
  ( wu ) wen jian guan lian
  uses
  registry, shlobj;
  // shi xian guan lian zhu ce
  procedure Tmyzip.regzzz;
  var
  reg: TRegistry;
  begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_CLASSES_ROOT;
  reg.OpenKey('.zzz', true);
  reg.WriteString('', 'myzip');
  reg.CloseKey;
  reg.OpenKey('myzip\shell\open\command', true);
  // yong yu da kai .zzz wen jian de ke zhi xing cheng xu
  reg.WriteString('', '"' + application.ExeName + '" "%1"');
  reg.CloseKey;
  reg.OpenKey('myzip\DefaultIcon',true);
  // qu dang qian ke zhi xing cheng xu de tu biao wei .zzz wen jian de tu biao
  reg.WriteString('',''+application.ExeName+',0');
  reg.Free;
  // li ji shua xin
  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
  end;
  2.3、 jia mi ya suo de shi xian
  1、 sheng cheng INI lin shi jia mi wen jian
  yong yu jia mi de INI de lin shi wen jian ge shi :
  [FILE1]// jie dian , zai ruan jian zhong shi yong FILE1..N ke yi shi xian duo wen jian jia mi
  FILENAME= ya suo wen jian ming
  PASSWORD= jie ya mi ma
  FILESIZE= wen jian da xiao
  FILEDATE= chuang jian ri qi
  ISJM= jie ya shi fou xu yao mi ma
  ru guo shi shi xian duo wen jian 、 wen jian jia de xin xi cun chu , ke yi jiang mi ma guan jian zi cun zai yi ge zong de jie dian xia 。 ben wen zhong jin shi shi xian dui dan ge wen jian de jia mi , suo yi zhi yao shang shu ge shi jiu ke yi le 。
  2、 jiang shu ju wen jian yu yong yu jia mi de INI wen jian de he bing , zhe ke yi cai yong wen jian liu de xing shi shi xian 。
  jia mi hou wen jian jie gou tu :
  tu (1)
  tu (2)
  shang mian liang zhong xing shi , ke yi gen ju shi ji cai yong 。 ben wen cai yong tu (1) de jie gou 。
  3、 dui yu jia mi hou de shu ju , cai yong ZLIB ji shu shi xian ya suo cun chu , sheng cheng xin ya suo xing shi de wen jian 。
  2.4、 wen jian guan lian de shi xian jian 2.2 ( wu )
  2.5、 zi jie ya de shi xian
  1. jian li yi ge zhuan men yong lai zi jie ya de ke zhi xing cheng xu wen jian
  2. jiang 1 zhong jian li de wen jian , sheng cheng zi yuan wen jian
  3. jiang zi yuan wen jian fang dao ben wen zhong zhe ge ya suo gong ju de cheng xu zhong yi qi bian yi 。
  4. tong guo jiang zi yuan wen jian yu ya suo wen jian de he bing , sheng cheng zi jie ya wen jian 。
  zi jie ya wen jian jie gou tu :
  5. zi jie ya shi xian : tong guo jiang zi shen wen jian zhong de jia mi ya suo shu ju de fen jie , ran hou dui fen jie de jia mi ya suo shu ju zai yi ci jie ya bing fen jie chu zhen zheng de shu ju wen jian 。
  2.6 xi tong cheng xu she ji
  zhe shi guan yu zhe ge ruan jian shi xian de gai xin bu fen quan bu dai ma , zai zhe li xiang xi jiang shu zhe ge ruan jian suo you de ji shu xi jie 。
  // wnhoo_zzz.pas
  unit wnhoo_zzz;
  interface
  uses
  Windows,Forms,SysUtils,Classes,zlib,Registry,INIFILES, Dialogs, shlobj;
  type
  pass=string[20];
  type
  Tmyzip = class
  private
  { private declarations here}
  protected
  { protected declarations here }
  public
  procedure regzzz;
  procedure ys_file(infileName, outfileName: string;password:pass;isjm:boolean;ysbz:integer);
  function jy_file(infileName: string;password:pass=''):boolean;
  procedure zjywj(var filename:string);
  constructor Create;
  destructor Destroy; override;
  { public declarations here }
  published
  { published declarations here }
  end;
  implementation
  constructor Tmyzip.Create;
  begin
  inherited Create; // chu shi hua ji cheng xia lai de bu fen
  end;
  //#####################################################
  // yuan wen jian jia mi
  procedure jm_File(vfile:string;var Target:TMemoryStream;password:pass;isjm:boolean);
  {
  vfile: jia mi wen jian
  target: jia mi hou shu chu mu biao liu 》》》
  password: mi ma
  isjm: shi fou jia mi
  -------------------------------------------------------------
  jia mi hou wen jian SIZE= yuan wen jian SIZE+[INI jia mi ya suo xin xi wen jian ] de SIZE+ cun chu [INI jia mi ya suo xin xi wen jian ] de da xiao shu ju lei xing de SIZE
  ---------------------------------------------------------------
  }
  var
  tmpstream,inistream:TFileStream;
  FileSize:integer;
  inifile:TINIFILE;
  filename:string;
  begin
  // da kai xu yao [ jia mi ya suo wen jian ]
  tmpstream:=TFileStream.Create(vFile,fmOpenread or fmShareExclusive);
  try
  // xiang [ lin shi jia mi ya suo wen jian liu ] yi bu xie ru [ yuan wen jian liu ]
  Target.Seek(0,soFromEnd);
  Target.CopyFrom(tmpstream,0);
  // qu de wen jian lu jing , sheng cheng [INI jia mi ya suo xin xi wen jian ]
  filename:=ExtractFilePath(paramstr(0))+'tmp.in_';
  inifile:=TInifile.Create(filename);
  inifile.WriteString('file1','filename',ExtractFileName(vFile));
  inifile.WriteString('file1','password',password);
  inifile.WriteInteger('file1','filesize',Target.Size);
  inifile.WriteDateTime('file1','fileDate',now());
  inifile.WriteBool('file1','isjm',isjm);
  inifile.Free ;
  // du ru [INI jia mi ya suo xin xi wen jian liu ]
  inistream:=TFileStream.Create(filename,fmOpenread or fmShareExclusive);
  try
  // ji xu zai [ lin shi jia mi ya suo wen jian liu ] yi bu jia ru [INI jia mi ya suo xin xi wen jian ]
  inistream.Position :=0;
  Target.Seek(0,sofromend);
  Target.CopyFrom(inistream,0);
  // ji suan dang qian [INI jia mi ya suo xin xi wen jian ] de da xiao
  FileSize:=inistream.Size ;
  // ji xu zai [ lin shi jia mi wen jian yi bu ] jia ru [INI jia mi ya suo xin xi wen jian ] de SIZE xin xi
  Target.WriteBuffer(FileSize,sizeof(FileSize));
  finally
  inistream.Free ;
  deletefile(filename);
  end;
  finally
  tmpstream.Free;
  end;
  end;
  //**************************************************************
  // liu ya suo
  procedure ys_stream(instream, outStream: TStream;ysbz:integer);
  {
  instream: dai ya suo de yi jia mi wen jian liu
  outStream ya suo hou shu chu wen jian liu
  ysbz: ya suo biao zhun
  }
  var
  ys: TCompressionStream;
  begin
  // liu zhi zhen zhi xiang tou bu
  inStream.Position := 0;
  // ya suo biao zhun de xuan ze
  case ysbz of
  1: ys := TCompressionStream.Create(clnone,OutStream);// bu ya suo
  2: ys := TCompressionStream.Create(clFastest,OutStream);// kuai su ya suo
  3: ys := TCompressionStream.Create(cldefault,OutStream);// biao zhun ya suo
  4: ys := TCompressionStream.Create(clmax,OutStream); // zui da ya suo
  else
  ys := TCompressionStream.Create(clFastest,OutStream);
  end;
  try
   // ya suo liu
   ys.CopyFrom(inStream, 0);
  finally
   ys.Free;
  end;
  end;
  //*****************************************************************
  // liu jie ya
  procedure jy_Stream(instream, outStream: TStream);
  {
  instream : yuan ya suo liu wen jian
  outStream: jie ya hou liu wen jian
  }
  var
  jyl: TDeCompressionStream;
  buf: array[1..512] of byte;
  sjread: integer;
  begin
  inStream.Position := 0;
  jyl := TDeCompressionStream.Create(inStream);
  try
   repeat
   // du ru shi ji da xiao
   sjRead := jyl.Read(buf, sizeof(buf));
   if sjread > 0 then
   OutStream.Write(buf, sjRead);
   until (sjRead = 0);
  finally
   jyl.Free;
  end;
  end;
  //**************************************************************
  // shi xian guan lian zhu ce
  procedure Tmyzip.regzzz;
  var
  reg: TRegistry;
  begin
  reg := TRegistry.Create;
  reg.RootKey := HKEY_CLASSES_ROOT;
  reg.OpenKey('.zzz', true);
  reg.WriteString('', 'myzip');
  reg.CloseKey;
  reg.OpenKey('myzip\shell\open\command', true);
  // yong yu da kai .zzz wen jian de ke zhi xing cheng xu
  reg.WriteString('', '"' + application.ExeName + '" "%1"');
  reg.CloseKey;
  reg.OpenKey('myzip\DefaultIcon',true);
  // qu dang qian ke zhi xing cheng xu de tu biao wei .zzz wen jian de tu biao
  reg.WriteString('',''+application.ExeName+',0');
  reg.Free;
  // li ji shua xin
  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
  end;
  // ya suo wen jian
  procedure Tmyzip.ys_file(infileName, outfileName: string;password:pass;isjm:boolean;ysbz:integer);
  {
  infileName:// xu yao ya suo jia mi de wen jian
  outfileName:// ya suo jia mi hou chan sheng de wen jian
  password:// jie ya mi ma
  ysbz:// ya suo biao zhun
  }
  var
  instream:TMemoryStream; // wen jian jia mi hou de lin shi liu
  outStream: TFileStream; // ya suo shu chu wen jian liu
  begin
   // chuang jian [ wen jian jia mi hou de lin shi liu ]
   instream:=TMemoryStream.Create;
   // wen jian jia mi
   jm_file(infileName,instream,password,isjm);
   // chuang jian ya suo shu chu wen jian liu
   outStream := TFileStream.create(outFIleName, fmCreate);
   try
   //[ wen jian jia mi hou de lin shi liu ] ya suo
   ys_stream(instream,OutStream,ysbz);
   finally
   OutStream.free;
   instream.Free ;
   end;
  end;
  // jie ya wen jian
  function Tmyzip.jy_file(infileName: string;password:pass=''):boolean;
  var
  inStream,inistream,filestream_ok: TFileStream;
  {
  instream:// jie ya wen jian ming cheng
  inistream://INI lin shi wen jian liu
  filestream_ok:// jie ya OK de wen jian
  }
  outStream:tmemorystream; // lin shi nei cun liu
  inifile:TINIFILE; // lin shi INI wen jian
  FileSize:integer; // mi ma wen jian de SIZE
  resultvalue:boolean;// fan hui zhi
  begin
  try
  inStream := TFileStream.create(inFIleName, fmOpenRead);
  try
   outStream := tmemorystream.create;
   try
   jy_stream(insTream,OutStream);
   // sheng cheng lin shi INI wen jian
   inistream:=TFileStream.create(ExtractFilePath(paramstr(0))+'tmp.in_', fmCreate);
   try
   // zhi xiang cun chu jie ma xin xi de INTEGER xing bian liang wei zhi
   OutStream.Seek(-sizeof(FileSize),sofromend);
   // du ru bian liang xin xi
   OutStream.ReadBuffer(FileSize,sizeof(FileSize));
   // zhi xiang jie ma xin xi wei zhi
   OutStream.Seek(-(FileSize+sizeof(FileSize)),sofromend);
   // jiang jie ma xin xi du ru INI liu zhong
   inistream.CopyFrom(OutStream,FileSize);
   // shi fang INI wen jian liu
   inistream.Free ;
   // du ru INI wen jian xin xi
   inifile:=TINIFILE.Create(ExtractFilePath(paramstr(0))+'tmp.in_');
   resultvalue:=inifile.ReadBool('file1','isjm',false);
   if resultvalue then
   begin
   if inifile.ReadString ('file1','password','')=trim(password) then
   resultvalue:=true
   else
   resultvalue:=false;
   end
   else
   resultvalue:=true;
   if resultvalue then
   begin
   filestream_ok:=TFileStream.create(ExtractFilePath(paramstr(1))+inifile.ReadString('file1','filename','wnhoo.zzz'),fmCreate);
   try
   OutStream.Position :=0;
   filestream_ok.CopyFrom(OutStream,inifile.ReadInteger('file1','filesize',0));
   finally
   filestream_ok.Free ;
   end;
   end;
   inifile.Free;
   finally
   // shan chu lin shi INI wen jian
   deletefile(ExtractFilePath(paramstr(0))+'tmp.in_');
   end;
   //
   finally
   OutStream.free;
   end;
  finally
   inStream.free;
  end;
  except
  resultvalue:=false ;
  end;
  result:=resultvalue;
  end;
  // zi jie ya chuang jian
  procedure tmyzip.zjywj(var filename:string);
  var
  myRes: TResourceStream;// lin shi cun fang zi jie ya EXE wen jian
  myfile:tfilestream;// yuan wen jian liu
  xfilename:string;// lin shi wen jian ming cheng
  file_ok:tmemorystream; // sheng cheng wen jian de nei cun liu
  filesize:integer; // yuan wen jian da xiao
  begin
  if FileExists(filename) then
  begin
  // chuang jian nei cun liu
  file_ok:=tmemorystream.Create ;
  // shi fang zi yuan wen jian -- zi jie ya EXE wen jian
  myRes := TResourceStream.Create(Hinstance, 'myzjy', Pchar('exefile'));
  // jiang yuan wen jian du ru nei cun
  myfile:=tfilestream.Create(filename,fmOpenRead);
  try
  myres.Position:=0;
  file_ok.CopyFrom(myres,0);
  file_ok.Seek(0,sofromend);
  myfile.Position:=0;
  file_ok.CopyFrom(myfile,0);
  file_ok.Seek(0,sofromend);
  filesize:=myfile.Size;
  file_ok.WriteBuffer(filesize,sizeof(filesize));
  file_ok.Position:=0;
  xfilename:=ChangeFileExt(filename,'.exe') ;
  file_ok.SaveToFile(xfilename);
  finally
  myfile.Free ;
  myres.Free ;
  file_ok.Free ;
  end;
  DeleteFile(filename);
  filename:=xfilename;
  end;
  end;
  //#####################################################
  destructor Tmyzip.Destroy;
  begin
  inherited Destroy;
  end;
  end.
  3 、 jie shu yu
  Delphi de quan xin ke shi hua bian cheng huan jing , wei wo men ti gong le yi zhong fang bian 、 kuai jie de Windows ying yong cheng xu kai fa gong ju 。 dui yu cheng xu kai fa ren yuan lai jiang , shi yong Delphi kai fa ying yong ruan jian , wu yi hui da da di ti gao bian cheng xiao lv 。 zai delphi zhong ke yi hen fang bian de li yong liu shi xian wen jian chu li 、 dong tai nei cun chu li 、 wang luo shu ju chu li deng duo zhong shu ju xing shi , xie qi cheng xu ye hui da da ti gao xiao lv de 。
  shen kao wen xian :
  1、DELPHI xi tong bang zhu
  2、 feng zhi qiang . Delphi zhong ya suo liu he jie ya liu de ying yong
  3、 chen jing tao . tan Delphi bian cheng zhong “ liu ”【原文】【汉音对照
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
yong DELPHI shi xian wen jian jia mi ya suo zuo zhe : e meng yuan (wnhoo) Mail:wnhoo@163.com feng hua xue yue e meng qing yuan [url=http://www.wangchao.net.cn/bbs/pydetail_975679.html][img]http://image.wangchao.net.cn/it/1323638074030.gif[/img][/url] dian ji xia zai ci xiang xi shuo ming wen jian gai shu : zai zhe pian wen jian zhong , jiang shu dui dan ge wen jian de shu ju jia mi 、 shu ju ya suo 、 zi jie ya de shi xian 。 tong yang , ye ke yi shi xian dui duo ge wen jian huo wen jian jia de ya suo , zhi yao shao jia xiu gai bian ke shi xian 。 guan jian zi : jia mi ya suo 、Zlib、 liu 、 zi yuan wen jian yin   yan : zai ri chang zhong , wo men yi ding shi yong guo WINZip、WINRAR zhe yang de chu ming de ya suo ruan jian , jiu shi wo men kai fa ruan jian guo cheng zhong bu mian yao yu dao shu ju jia mi 、 shu ju ya suo de wen ti ! ben wen zhong jiu zhe yi ji shu wen ti zhan kai tan tao , tong shi gan xie ge wei wang you de ji qiao , zai wo mei ci mian dui wen ti yao jie jue de shi hou , shi ni men xin ku di mo suo chu lai de ji qiao zong shi rang wo huo ran kai lang , wen ti ying ren er jie 。 ben pian wen zhang zhu yao shi yun yong DELPH de qiang da de liu chu li fang mian de ji qiao lai shi xian de shu ju jia mi ya suo , bing yong yu shi ji de ruan jian cheng xu kai fa zhong , jiang wo ge ren de xin de 、 kai fa jing yan xie chu lai yu da jia fen xiang 。 1、 xi tong gong neng 1)、 shu ju ya suo shi yong DELPHI ti gong de liang ge liu lei (TComPRessionStream he TDecompressionStream) lai wan cheng shu ju de ya suo he jie ya suo 。 2)、 shu ju jia mi ya suo tong guo Delphi bian cheng zhong “ liu ” de ying yong shi xian shu ju jia mi , zhu yao cai yong Tstream de liang ge pai sheng lei Tfilestream、Tmemorystream lai wan cheng de ; qi zhong shu ju ya suo bu fen cai yong 1) de shi xian fang fa 3)、 shuang ji ya suo wen jian zi dong guan lian jie ya tong guo geng gai zhu ce biao de shi xian kuo zhan ming yu cheng xu wen jian de guan lian , zhu yao cai yong Tregistry; bing qie ,API han shu SHChangeNotify shi xian zhu ce xiao guo de li ji cheng xian 。 4)、 ke sheng cheng zi jie ya wen jian zi jie ya de wen jian shi xian shu ju ya suo 1) yu shu ju jia mi ya suo 2) de zi dong jie ya ; bing qie , tong guo zi yuan wen jian de shi yong shi xian ke zhi xing de zi jie ya wen jian yu shu ju wen jian de he bing , lai wan cheng shu ju de zi jie ya shi xian 。 2、 xi tong shi xian 2.1、 gong zuo yuan li [url=http://www.wangchao.net.cn/bbs/pydetail_975679.html][img]http://image.wangchao.net.cn/it/1323638089110.jpg[/img][/url] 2.2、 guan jian ji shu de jiang shu ( yi )ZLIB 1)、 ji lei TCustomZlibStream: shi lei TCompressionStream he TDecompressionStream lei de ji lei , ta zhu yao you yi ge shu xing : OnProgress, zai lei jin xing ya suo huo jie ya suo de guo cheng zhong hui fa sheng zhe ge de shi jian 。 ge shi :Procedure OnProgress (Sender: TObject); dynamic; 2)、 ya suo lei TCompressionStream: chu le ji cheng le ji lei de OnProgress shu xing wai , you zeng jia le yi ge shu xing :CompressionRate, ta de ding yi ru xia : Property CompressionRate: Single read GetCompressionRate; tong guo zhe ge shu xing , ke yi de dao ya suo bi 。 ta de ji ge chong yao de fang fa ding yi ru xia : Constructor TCompressionStream.Create (CompressionLevel: TCompressionLevel; Dest: TStream); qi zhong :TcompressionLevel( ya suo lei xing ), ta you ru xia ji ge ding yi :    1)、 clNone : bu jin xing shu ju ya suo ;    2)、 clFastest: jin xing kuai su ya suo , xi sheng ya suo xiao lv ;    3)、 clDefault: jin xing zheng chang ya suo ;    4)、 clMax: jin xing zui da hua ya suo , xi sheng su du ; Dest: mu de liu , yong yu cun fang ya suo guo de shu ju 。 Function TCompressionStream.Write (const Buffer; Count: Longint): Longint; qi zhong :Buffer: xu yao ya suo de shu ju ;    Count: xu yao ya suo de shu ju de zi jie shu ; han shu fan hui xie ru liu de zi jie shu 。 zhu yi : ya suo lei TCompressionStream de shu ju zhi neng shi xie ru de , ru guo shi tu cong qi nei bu du qu shu ju , jiang fa sheng yi ge "Error " yi chang 。 xu yao ya suo de shu ju tong guo fang fa Write xie ru liu zhong , zai xie ru de guo cheng zhong jiu bei ya suo , bing bao cun zai you gou zao han shu ti gong de nei cun liu (TmemoryStream) zhong , tong shi chu fa OnProcess shi jian 。 3)、 jie ya suo lei TDecompressionStream : he ya suo lei TcompressionStream xiang fan , ta de shu ju shi zhi neng du chu de , ru guo shi tu wang qi nei bu xie shu ju , jiang fa sheng yi ge "Error " yi chang 。 ta de ji ge chong yao fang fa ding yi ru xia : gou zao han shu :Constructor Create(Source: TStream);    qi zhong :Source shi bao cun zhe ya suo shu ju de liu ; Function Read(var Buffer; Count: Longint): Longint;    shu ju du chu han shu ,Buffer: cun shu ju huan chong qu ;Count: huan chong qu de da xiao ;    han shu fan hui du chu de zi jie shu 。 shu ju zai du chu de guo cheng zhong , shu ju bei jie ya suo , bing chu fa OnProcess shi jian 。 ( er ) liu zai Delphi zhong , suo you liu dui xiang de ji lei wei TStream lei , qi zhong ding yi le suo you liu de gong tong shu xing he fang fa 。 TStream lei zhong ding yi de shu xing ru xia : 1)、Size: ci shu xing yi zi jie fan hui liu zhong shu ju da xiao 。 2)、Position: ci shu xing kong zhi liu zhong cun qu zhi zhen de wei zhi 。 Tstream zhong ding yi de xu fang fa you si ge : 1)、Read: ci fang fa shi xian jiang shu ju cong liu zhong du chu , fan hui zhi wei shi ji du chu de zi jie shu , ta ke yi xiao yu huo deng yu zhi ding de zhi 。 2)、Write: ci fang fa shi xian jiang shu ju xie ru liu zhong , fan hui zhi wei shi ji xie ru liu zhong de zi jie shu 。 3)、Seek: ci fang fa shi xian liu zhong du qu zhi zhen de yi dong , fan hui zhi wei yi dong hou zhi zhen de wei zhi 。 han shu yuan xing wei :Function Seek(Offset:Longint;Origint:Word):Longint;virtual;abstract; shen shu Offset wei pian yi zi jie shu , shen shu Origint zhi chu Offset de shi ji yi yi , qi ke neng de qu zhi ru xia : soFromBeginning:Offset wei zhi zhen ju li shu ju kai shi de wei zhi 。 ci shi Offset bi xu da yu huo zhe deng yu ling 。 soFromCurrent:Offset wei yi dong hou zhi zhen yu dang qian zhi zhen de xiang dui wei zhi 。 soFromEnd:Offset wei yi dong hou zhi zhen ju li shu ju jie shu de wei zhi 。 ci shi Offset bi xu xiao yu huo zhe deng yu ling 。 4)、Setsize: ci fang fa shi xian gai bian shu ju de da xiao 。 ling wai ,TStream lei zhong huan ding yi le ji ge jing tai fang fa : 1)、ReadBuffer: ci fang fa de zuo yong shi cong liu zhong dang qian wei zhi du qu shu ju , gen shang mian de Read xiang tong 。 zhu yi : dang du qu de shu ju zi jie shu yu xu yao du qu de zi jie shu bu xiang tong shi , jiang chan sheng EReadError yi chang 。 2)、WriteBuffer: ci fang fa de zuo yong shi zai dang qian wei zhi xiang liu xie ru shu ju , gen shang mian de Write xiang tong 。 zhu yi : dang xie ru de shu ju zi jie shu yu xu yao xie ru de zi jie shu bu xiang tong shi , jiang chan sheng EWriteError yi chang 。 3)、CopyFrom: ci fang fa de zuo yong shi cong qi ta liu zhong kao bei shu ju liu 。 han shu yuan xing wei :Function CopyFrom(Source:TStream;Count:Longint):Longint; shen shu Source wei ti gong shu ju de liu ,Count wei kao bei de shu ju zi jie shu 。 dang Count da yu 0 shi ,CopyFrom cong Source shen shu de dang qian wei zhi kao bei Count ge zi jie de shu ju ; dang Count deng yu 0 shi ,CopyFrom she zhi Source shen shu de Position shu xing wei 0, ran hou kao bei Source de suo you shu ju ; Tstream chang jian pai sheng lei : TFileStream ( wen jian liu de cun qu ) TStringStream ( chu li nei cun zhong de zi fu chuan lei xing shu ju ) TmemoryStream ( dui yu gong zuo de nei cun qu yu shu ju chu li ) TBlobStream (BLOB lei xing zi duan de shu ju chu li ) TwinSocketStream (socket de du xie chu li ) ToleStream (COM jie kou de shu ju chu li ) TresourceStream ( zi yuan wen jian liu de chu li ) qi zhong zui chang yong de shi TFileStream lei 。 shi yong TFileStream lei lai cun qu wen jian , shou xian yao jian li yi ge shi li 。 sheng ming ru xia : constructor Create(const Filename:string;Mode:Word); Filename wei wen jian ming ( bao kuo lu jing ) Mode wei da kai wen jian de fang shi , ta bao kuo wen jian de da kai mo shi he gong xiang mo shi , qi ke neng de qu zhi he yi yi ru xia : da kai mo shi : fmCreate : yong zhi ding de wen jian ming jian li wen jian , ru guo wen jian yi jing cun zai ze da kai ta 。 fmOpenRead : yi zhi du fang shi da kai zhi ding wen jian fmOpenWrite : yi zhi xie fang shi da kai zhi ding wen jian fmOpenReadWrite: yi xie xie fang shi da kai zhi ding wen jian gong xiang mo shi : fmShareCompat : gong xiang mo shi yu FCBs jian rong fmShareExclusive: bu yuan xu bie de cheng xu yi ren he fang shi da kai gai wen jian fmShareDenyWrite: bu yuan xu bie de cheng xu yi xie fang shi da kai gai wen jian fmShareDenyRead : bu yuan xu bie de cheng xu yi du fang shi da kai gai wen jian fmShareDenyNone : bie de cheng xu ke yi yi ren he fang shi da kai gai wen jian ( san ) zi yuan wen jian 1)、 chuang jian zi yuan wen jian shou xian chuang jian yi ge .Rc de chun wen ben wen jian 。 ge shi : zi yuan biao shi fu guan jian zi zi yuan wen jian ming zi yuan biao shi fu : cheng xu zhong tiao yong zi yuan shi de te shu biao hao ; guan jian zi : biao shi zi yuan wen jian lei xing ; Wave: zi yuan wen jian shi sheng yin wen jian ; RCDATA: JPEG wen jian ; AVI: AVI dong hua ; ICON: tu biao wen jian ; BITMAP: wei tu wen jian ; CURSOR: guang biao wen jian ; EXEFILE : EXE wen jian zi yuan wen jian ming : zi yuan wen jian de zai ci pan shang cun chu de wen jian quan ming li ru : myzjy exefile zjy.exe 2)、 bian yi zi yuan wen jian zai DELPHI de an zhuang mu lu de \Bin xia , shi yong BRCC32.exe bian yi zi yuan wen jian .RC。 dang ran , ye ke yi jiang BRCC32 dan du kao bei dao cheng xu wen dang mu lu shi yong 。 li ru : Brcc32 wnhoo_reg.Rc 3)、 zi yuan wen jian yin yong … implementation {$R *.dfm} {$R wnhoo_reg.Res} … 4)、 tiao yong zi yuan wen jian (1) cun qu zi yuan wen jian zhong de wei tu (Bitmap) Image.Picture.Bitmap.Handle :=LoadBitmap(hInstance,' zi yuan biao shi fu '); zhu : ru guo wei tu mei you zhuang zai cheng gong , cheng xu reng jiu zhi xing , dan shi Image jiang bu zai xian shi tu pian 。 ni ke yi gen ju LoadBitmap han shu de fan hui zhi pan duan shi fou zhuang zai cheng gong , ru guo zhuang zai cheng gong fan hui zhi shi fei 0, ru guo zhuang zai shi bai fan hui zhi shi 0。 ling wai yi ge cun qu xian shi wei tu de fang fa ru xia Image.Picture.Bitmap.LoadFromResourceName(hInstance,' zi yuan biao shi fu '); (2) cun qu zi yuan wen jian zhong de guang biao Screen.Cursors[] shi yi ge guang biao shu zu , shi yong guang biao wen jian wo men ke yi jiang ding zhi de guang biao jia ru dao zhe ge shu xing zhong 。 yin wei mo ren de guang biao zai shu zu zhong suo yin zhi shi 0, suo yi chu fei xiang qu dai mo ren guang biao , zui hao jiang ding zhi de guang biao suo yin zhi she wei 1。 Screen.Cursors[1] :=LoadCursor(hInstance,' zi yuan biao shi fu '); Image.Cursor :=1; (3) cun qu zi yuan wen jian zhong de tu biao jiang tu biao fang zai zi yuan wen jian zhong , ke yi shi xian dong tai gai bian ying yong cheng xu tu biao 。 application.Icon.Handle := LoadIcon(hInstance,' zi yuan biao shi fu '); (4) cun qu zi yuan wen jian zhong de AVI Animate.ResName :='MyAvi' ; // zi yuan biao shi fu hao Animate.Active :=True ; (5) cun qu zi yuan wen jian zhong de JPEG ba jpeg dan yuan jia ru dao uses dan yuan zhong 。 var Fjpg : TJpegImage ; FStream :TResourceStream ; begin Fjpg :=TJpegImage.Create ; //TresourceStream shi yong FStream := TResourceStream.Create (Hinstance,' zi yuan biao shi fu ', zi yuan lei xing ) ; FJpg.LoadFromStream (FStream) ; Image.Picture.Bitmap.Assign (FJpg); (6) cun qu zi yuan wen jian zhong de Wave ba MMSystem jia ru uses dan yuan zhong PlaySound(pchar('mywav'),Hinstance,Snd_ASync or Snd_Memory or snd_Resource) ; ( si )INI wen jian cao zuo (1) INI wen jian de jie gou : ; zhe shi guan yu INI wen jian de zhu shi bu fen [ jie dian ] guan jian zi = zhi ... INI wen jian yuan xu you duo ge jie dian , mei ge jie dian you yuan xu you duo ge guan jian zi , “=” hou mian shi gai guan jian zi de zhi ( lei xing you san zhong : zi fu chuan 、 zheng xing shu zhi he bu er zhi 。 qi zhong zi fu chuan cun zhu zai INI wen jian zhong shi mei you yin hao , bu er zhen zhi yong 1 biao shi , bu er jia zhi yong 0 biao shi )。 zhu shi yi fen hao “;” kai tou 。 (2) INI wen jian de cao zuo 1、 zai Interface de Uses jie zeng jia IniFiles; 2、 zai Var bian liang ding yi bu fen zeng jia yi xing :inifile:Tinifile; ran hou , jiu ke yi dui bian liang myinifile jin xing chuang jian 、 da kai 、 du qu 、 xie ru deng cao zuo le 。 3、 da kai INI wen jian :inifile:=Tinifile.create('tmp.ini'); 4、 du qu guan jian zi de zhi : a:=inifile.Readstring(' jie dian ',' guan jian zi ', que sheng zhi );// string lei xing b:=inifile.Readinteger(' jie dian ',' guan jian zi ', que sheng zhi );// integer lei xing c:=inifile.Readbool(' jie dian ',' guan jian zi ', que sheng zhi );// boolean lei xing qi zhong [ que sheng zhi ] wei gai INI wen jian bu cun zai gai guan jian zi shi fan hui de que sheng zhi 。 5、 xie ru INI wen jian : inifile.writestring(' jie dian ',' guan jian zi ', bian liang huo zi fu chuan zhi ); inifile.writeinteger(' jie dian ',' guan jian zi ', bian liang huo zheng xing zhi ); inifile.writebool(' jie dian ',' guan jian zi ', bian liang huo True huo False); dang zhe ge INI wen jian de jie dian bu cun zai shi , shang mian de yu ju huan hui zi dong chuang jian gai INI wen jian 。 6、 shan chu guan jian zi : inifile.DeleteKey(' jie dian ',' guan jian zi ');// guan jian zi shan chu inifile.EraseSection(' jie dian ');// jie dian shan chu 7、 jie dian cao zuo : inifile.readsection(' jie dian ',TStrings bian liang );// ke jiang zhi ding xiao jie zhong de suo you guan jian zi ming du qu zhi yi ge zi fu chuan lie biao bian liang zhong ; inifile.readsections(TStrings bian liang );// ke jiang INI wen jian zhong suo you xiao jie ming du qu zhi yi ge zi fu chuan lie biao bian liang zhong qu 。 inifile.readsectionvalues(' jie dian ',TStrings bian liang );// ke jiang INI wen jian zhong zhi ding xiao jie de suo you xing ( bao kuo guan jian zi 、=、 zhi ) du qu zhi yi ge zi fu chuan lie biao bian liang zhong qu 。 8、 shi fang :inifile.distory; huo inifile.free; ( wu ) wen jian guan lian uses registry, shlobj; // shi xian guan lian zhu ce procedure Tmyzip.regzzz; var reg: TRegistry; begin reg := TRegistry.Create; reg.RootKey := HKEY_CLASSES_ROOT; reg.OpenKey('.zzz', true); reg.WriteString('', 'myzip'); reg.CloseKey; reg.OpenKey('myzip\shell\open\command', true); // yong yu da kai .zzz wen jian de ke zhi xing cheng xu reg.WriteString('', '"' + application.ExeName + '" "%1"'); reg.CloseKey; reg.OpenKey('myzip\DefaultIcon',true); // qu dang qian ke zhi xing cheng xu de tu biao wei .zzz wen jian de tu biao reg.WriteString('',''+application.ExeName+',0'); reg.Free; // li ji shua xin SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); end; 2.3、 jia mi ya suo de shi xian 1、 sheng cheng INI lin shi jia mi wen jian yong yu jia mi de INI de lin shi wen jian ge shi : [FILE1]// jie dian , zai ruan jian zhong shi yong FILE1..N ke yi shi xian duo wen jian jia mi FILENAME= ya suo wen jian ming PASSWORD= jie ya mi ma FILESIZE= wen jian da xiao FILEDATE= chuang jian ri qi ISJM= jie ya shi fou xu yao mi ma ru guo shi shi xian duo wen jian 、 wen jian jia de xin xi cun chu , ke yi jiang mi ma guan jian zi cun zai yi ge zong de jie dian xia 。 ben wen zhong jin shi shi xian dui dan ge wen jian de jia mi , suo yi zhi yao shang shu ge shi jiu ke yi le 。 2、 jiang shu ju wen jian yu yong yu jia mi de INI wen jian de he bing , zhe ke yi cai yong wen jian liu de xing shi shi xian 。 jia mi hou wen jian jie gou tu : tu (1) tu (2) shang mian liang zhong xing shi , ke yi gen ju shi ji cai yong 。 ben wen cai yong tu (1) de jie gou 。 3、 dui yu jia mi hou de shu ju , cai yong ZLIB ji shu shi xian ya suo cun chu , sheng cheng xin ya suo xing shi de wen jian 。 2.4、 wen jian guan lian de shi xian jian 2.2 ( wu ) 2.5、 zi jie ya de shi xian 1. jian li yi ge zhuan men yong lai zi jie ya de ke zhi xing cheng xu wen jian 2. jiang 1 zhong jian li de wen jian , sheng cheng zi yuan wen jian 3. jiang zi yuan wen jian fang dao ben wen zhong zhe ge ya suo gong ju de cheng xu zhong yi qi bian yi 。 4. tong guo jiang zi yuan wen jian yu ya suo wen jian de he bing , sheng cheng zi jie ya wen jian 。 zi jie ya wen jian jie gou tu : 5. zi jie ya shi xian : tong guo jiang zi shen wen jian zhong de jia mi ya suo shu ju de fen jie , ran hou dui fen jie de jia mi ya suo shu ju zai yi ci jie ya bing fen jie chu zhen zheng de shu ju wen jian 。 2.6 xi tong cheng xu she ji zhe shi guan yu zhe ge ruan jian shi xian de gai xin bu fen quan bu dai ma , zai zhe li xiang xi jiang shu zhe ge ruan jian suo you de ji shu xi jie 。 // wnhoo_zzz.pas unit wnhoo_zzz; interface uses Windows,Forms,SysUtils,Classes,zlib,Registry,INIFILES, Dialogs, shlobj; type pass=string[20]; type Tmyzip = class private { private declarations here} protected { protected declarations here } public procedure regzzz; procedure ys_file(infileName, outfileName: string;password:pass;isjm:boolean;ysbz:integer); function jy_file(infileName: string;password:pass=''):boolean; procedure zjywj(var filename:string); constructor Create; destructor Destroy; override; { public declarations here } published { published declarations here } end; implementation constructor Tmyzip.Create; begin inherited Create; // chu shi hua ji cheng xia lai de bu fen end; //##################################################### // yuan wen jian jia mi procedure jm_File(vfile:string;var Target:TMemoryStream;password:pass;isjm:boolean); { vfile: jia mi wen jian target: jia mi hou shu chu mu biao liu 》》》 password: mi ma isjm: shi fou jia mi ------------------------------------------------------------- jia mi hou wen jian SIZE= yuan wen jian SIZE+[INI jia mi ya suo xin xi wen jian ] de SIZE+ cun chu [INI jia mi ya suo xin xi wen jian ] de da xiao shu ju lei xing de SIZE --------------------------------------------------------------- } var tmpstream,inistream:TFileStream; FileSize:integer; inifile:TINIFILE; filename:string; begin // da kai xu yao [ jia mi ya suo wen jian ] tmpstream:=TFileStream.Create(vFile,fmOpenread or fmShareExclusive); try // xiang [ lin shi jia mi ya suo wen jian liu ] yi bu xie ru [ yuan wen jian liu ] Target.Seek(0,soFromEnd); Target.CopyFrom(tmpstream,0); // qu de wen jian lu jing , sheng cheng [INI jia mi ya suo xin xi wen jian ] filename:=ExtractFilePath(paramstr(0))+'tmp.in_'; inifile:=TInifile.Create(filename); inifile.WriteString('file1','filename',ExtractFileName(vFile)); inifile.WriteString('file1','password',password); inifile.WriteInteger('file1','filesize',Target.Size); inifile.WriteDateTime('file1','fileDate',now()); inifile.WriteBool('file1','isjm',isjm); inifile.Free ; // du ru [INI jia mi ya suo xin xi wen jian liu ] inistream:=TFileStream.Create(filename,fmOpenread or fmShareExclusive); try // ji xu zai [ lin shi jia mi ya suo wen jian liu ] yi bu jia ru [INI jia mi ya suo xin xi wen jian ] inistream.Position :=0; Target.Seek(0,sofromend); Target.CopyFrom(inistream,0); // ji suan dang qian [INI jia mi ya suo xin xi wen jian ] de da xiao FileSize:=inistream.Size ; // ji xu zai [ lin shi jia mi wen jian yi bu ] jia ru [INI jia mi ya suo xin xi wen jian ] de SIZE xin xi Target.WriteBuffer(FileSize,sizeof(FileSize)); finally inistream.Free ; deletefile(filename); end; finally tmpstream.Free; end; end; //************************************************************** // liu ya suo procedure ys_stream(instream, outStream: TStream;ysbz:integer); { instream: dai ya suo de yi jia mi wen jian liu outStream ya suo hou shu chu wen jian liu ysbz: ya suo biao zhun } var ys: TCompressionStream; begin // liu zhi zhen zhi xiang tou bu inStream.Position := 0; // ya suo biao zhun de xuan ze case ysbz of 1: ys := TCompressionStream.Create(clnone,OutStream);// bu ya suo 2: ys := TCompressionStream.Create(clFastest,OutStream);// kuai su ya suo 3: ys := TCompressionStream.Create(cldefault,OutStream);// biao zhun ya suo 4: ys := TCompressionStream.Create(clmax,OutStream); // zui da ya suo else ys := TCompressionStream.Create(clFastest,OutStream); end; try // ya suo liu ys.CopyFrom(inStream, 0); finally ys.Free; end; end; //***************************************************************** // liu jie ya procedure jy_Stream(instream, outStream: TStream); { instream : yuan ya suo liu wen jian outStream: jie ya hou liu wen jian } var jyl: TDeCompressionStream; buf: array[1..512] of byte; sjread: integer; begin inStream.Position := 0; jyl := TDeCompressionStream.Create(inStream); try repeat // du ru shi ji da xiao sjRead := jyl.Read(buf, sizeof(buf)); if sjread > 0 then OutStream.Write(buf, sjRead); until (sjRead = 0); finally jyl.Free; end; end; //************************************************************** // shi xian guan lian zhu ce procedure Tmyzip.regzzz; var reg: TRegistry; begin reg := TRegistry.Create; reg.RootKey := HKEY_CLASSES_ROOT; reg.OpenKey('.zzz', true); reg.WriteString('', 'myzip'); reg.CloseKey; reg.OpenKey('myzip\shell\open\command', true); // yong yu da kai .zzz wen jian de ke zhi xing cheng xu reg.WriteString('', '"' + application.ExeName + '" "%1"'); reg.CloseKey; reg.OpenKey('myzip\DefaultIcon',true); // qu dang qian ke zhi xing cheng xu de tu biao wei .zzz wen jian de tu biao reg.WriteString('',''+application.ExeName+',0'); reg.Free; // li ji shua xin SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); end; // ya suo wen jian procedure Tmyzip.ys_file(infileName, outfileName: string;password:pass;isjm:boolean;ysbz:integer); { infileName:// xu yao ya suo jia mi de wen jian outfileName:// ya suo jia mi hou chan sheng de wen jian password:// jie ya mi ma ysbz:// ya suo biao zhun } var instream:TMemoryStream; // wen jian jia mi hou de lin shi liu outStream: TFileStream; // ya suo shu chu wen jian liu begin // chuang jian [ wen jian jia mi hou de lin shi liu ] instream:=TMemoryStream.Create; // wen jian jia mi jm_file(infileName,instream,password,isjm); // chuang jian ya suo shu chu wen jian liu outStream := TFileStream.create(outFIleName, fmCreate); try //[ wen jian jia mi hou de lin shi liu ] ya suo ys_stream(instream,OutStream,ysbz); finally OutStream.free; instream.Free ; end; end; // jie ya wen jian function Tmyzip.jy_file(infileName: string;password:pass=''):boolean; var inStream,inistream,filestream_ok: TFileStream; { instream:// jie ya wen jian ming cheng inistream://INI lin shi wen jian liu filestream_ok:// jie ya OK de wen jian } outStream:tmemorystream; // lin shi nei cun liu inifile:TINIFILE; // lin shi INI wen jian FileSize:integer; // mi ma wen jian de SIZE resultvalue:boolean;// fan hui zhi begin try inStream := TFileStream.create(inFIleName, fmOpenRead); try outStream := tmemorystream.create; try jy_stream(insTream,OutStream); // sheng cheng lin shi INI wen jian inistream:=TFileStream.create(ExtractFilePath(paramstr(0))+'tmp.in_', fmCreate); try // zhi xiang cun chu jie ma xin xi de INTEGER xing bian liang wei zhi OutStream.Seek(-sizeof(FileSize),sofromend); // du ru bian liang xin xi OutStream.ReadBuffer(FileSize,sizeof(FileSize)); // zhi xiang jie ma xin xi wei zhi OutStream.Seek(-(FileSize+sizeof(FileSize)),sofromend); // jiang jie ma xin xi du ru INI liu zhong inistream.CopyFrom(OutStream,FileSize); // shi fang INI wen jian liu inistream.Free ; // du ru INI wen jian xin xi inifile:=TINIFILE.Create(ExtractFilePath(paramstr(0))+'tmp.in_'); resultvalue:=inifile.ReadBool('file1','isjm',false); if resultvalue then begin if inifile.ReadString ('file1','password','')=trim(password) then resultvalue:=true else resultvalue:=false; end else resultvalue:=true; if resultvalue then begin filestream_ok:=TFileStream.create(ExtractFilePath(paramstr(1))+inifile.ReadString('file1','filename','wnhoo.zzz'),fmCreate); try OutStream.Position :=0; filestream_ok.CopyFrom(OutStream,inifile.ReadInteger('file1','filesize',0)); finally filestream_ok.Free ; end; end; inifile.Free; finally // shan chu lin shi INI wen jian deletefile(ExtractFilePath(paramstr(0))+'tmp.in_'); end; // finally OutStream.free; end; finally inStream.free; end; except resultvalue:=false ; end; result:=resultvalue; end; // zi jie ya chuang jian procedure tmyzip.zjywj(var filename:string); var myRes: TResourceStream;// lin shi cun fang zi jie ya EXE wen jian myfile:tfilestream;// yuan wen jian liu xfilename:string;// lin shi wen jian ming cheng file_ok:tmemorystream; // sheng cheng wen jian de nei cun liu filesize:integer; // yuan wen jian da xiao begin if FileExists(filename) then begin // chuang jian nei cun liu file_ok:=tmemorystream.Create ; // shi fang zi yuan wen jian -- zi jie ya EXE wen jian myRes := TResourceStream.Create(Hinstance, 'myzjy', Pchar('exefile')); // jiang yuan wen jian du ru nei cun myfile:=tfilestream.Create(filename,fmOpenRead); try myres.Position:=0; file_ok.CopyFrom(myres,0); file_ok.Seek(0,sofromend); myfile.Position:=0; file_ok.CopyFrom(myfile,0); file_ok.Seek(0,sofromend); filesize:=myfile.Size; file_ok.WriteBuffer(filesize,sizeof(filesize)); file_ok.Position:=0; xfilename:=ChangeFileExt(filename,'.exe') ; file_ok.SaveToFile(xfilename); finally myfile.Free ; myres.Free ; file_ok.Free ; end; DeleteFile(filename); filename:=xfilename; end; end; //##################################################### destructor Tmyzip.Destroy; begin inherited Destroy; end; end. 3 、 jie shu yu Delphi de quan xin ke shi hua bian cheng huan jing , wei wo men ti gong le yi zhong fang bian 、 kuai jie de Windows ying yong cheng xu kai fa gong ju 。 dui yu cheng xu kai fa ren yuan lai jiang , shi yong Delphi kai fa ying yong ruan jian , wu yi hui da da di ti gao bian cheng xiao lv 。 zai delphi zhong ke yi hen fang bian de li yong liu shi xian wen jian chu li 、 dong tai nei cun chu li 、 wang luo shu ju chu li deng duo zhong shu ju xing shi , xie qi cheng xu ye hui da da ti gao xiao lv de 。 shen kao wen xian : 1、DELPHI xi tong bang zhu 2、 feng zhi qiang . Delphi zhong ya suo liu he jie ya liu de ying yong 3、 chen jing tao . tan Delphi bian cheng zhong “ liu ”
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
上海柏雅居酒店模拍
清晨美丽的风景
梦清园的靓丽女生
妖艳的食人花(7)
且行且攝------"色"影大連
【做股票的朋友看过来-华尔街的铜牛】
端午节后闲逛
捐款赈灾吴川行 花絮
 
>>返回首页<<
 为你推荐
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
©2005- 王朝网络 版权所有