时间: 2021-07-31 作者:daque
---- 在咱们体例delphi运用步调,往往须要供给一个暗号考证框,对运用步调的运用者举行身份核查。即使能有一个通用的暗号考证框,便不妨为咱们的处事俭朴不少的功夫,更能使咱们体例的步调小而快。以次的步调为你供给了如许的一个dll文献。 //文献名为checkpasswordform.dpr; 编写翻译此文献天生checkpasswordform.dll library checkpasswordform; uses xcqcheck in 'xcqcheck.pas' {xcqform}; exports checkpassword name 'checkpassword';//dll进口 begin end. //文献名为xcqcheck.pas unit xcqcheck; interface uses windows, messages, sysutils, classes, graphics, controls, forms, dialogs, stdctrls, mask, menus; type txcqform = class(tform) xcqedit: tmaskedit;//暗号输出框 okbtn: tbutton; procedure okbtnclick(sender: tobject); end; var xcqform: txcqform; check: boolean;//考证输出暗号的精确性 function checkpassword: boolean;export; //本dll文献的要害实行 implementation {$r *.dfm} procedure txcqform.okbtnclick(sender: tobject); begin if xcqedit.text = 'xcq' then check := true; close; end; function checkpassword;export; begin check := false; xcqform := txcqform.create(application); //创造暗号输出框 xcqform.showmodal;//表露暗号输出框; 提防:不许用xcqform.show! result := check;//归来给挪用本dll的运用步调确定 xcqform.free;//开释本dll文献所占资源 end; end. ---- 在挪用之上dll中checkpassword因变量的运用步调中只需介入以次语句在implementation 后,function checkpassword: boolean; external 'checkpasswordform.dll' name 'checkpassword';在须要举行暗号考证的场合介入底下的前提语句就实足实行了暗号考证的功效。 if checkpassword then begin ...//如xcqquery.open; end; ---- 上头的步调不过一个大略的暗号考证框,咱们不妨将暗号以写入备案表或文献的办法生存,动静窜改,更不妨运用算术算法对暗号举行大略的加密等,使要窃密的数据更安定。 ---- 本来,下文中怎样在dll中实行窗口让我走了不少弯道,我感触本法对大师更有意旨,这是制止步调宏大的一种灵验本领,无妨试试。