在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
技术交流,DH讲解. 在Sysutils.pas有几个函数,以前我也没有看见过,今天看源码的时候无意间发现了. function GDAL: LongWord; type TDVCLAL = array[0..3] of LongWord; PDVCLAL = ^TDVCLAL; var P: Pointer; A1, A2: LongWord; PAL1s, PAL2s: PDVCLAL; ALOK: Boolean; begin P := ALR;//从资源文件获得 if P <> nil then begin A1 := AL1(P^); A2 := AL2(P^); Result := A1; PAL1s := @AL1s; PAL2s := @AL2s; ALOK := ((A1 = PAL1s[0]) and (A2 = PAL2s[0])) or ((A1 = PAL1s[1]) and (A2 = PAL2s[1])) or ((A1 = PAL1s[2]) and (A2 = PAL2s[2])); FreeResource(Integer(P)); if not ALOK then ALV;//抛出异常,说Application is not licensed to use this feature end else Result := AL1s[3]; end; 这个函数全称Get Delphi Access Licences,这个函数去读取资源里面的访问许可,如果不合法就抛出异常,如果合法就返回解密后的AL1。里面用到的两个函数: const AL1s: array[0..3] of LongWord = ($FFFFFFF0, $FFFFEBF0, 0, $FFFFFFFF); AL2s: array[0..3] of LongWord = ($42C3ECEF, $20F7AEB6, $D1C2F74E, $3F6574DE); procedure ALV; begin raise Exception.CreateRes(@SNL); end; function ALR: Pointer; var LibModule: PLibModule; begin if MainInstance <> 0 then Result := Pointer(LoadResource(MainInstance, FindResource(MainInstance, 'DVCLAL', RT_RCDATA))) else begin Result := nil; LibModule := LibModuleList;//这里是一个链表,其实想学习链表的朋友可以来看看 while LibModule <> nil do//遍历链表 begin with LibModule^ do begin Result := Pointer(LoadResource(Instance, FindResource(Instance, 'DVCLAL', RT_RCDATA))); if Result <> nil then Break; end; LibModule := LibModule.Next; end; end; end; 紧接着下面有个函数用到GDAL了,也就是GDAL没有直接被用到: procedure RCS; var P: Pointer; ALOK: Boolean; begin P := ALR; if P <> nil then begin ALOK := (AL1(P^) = AL1s[2]) and (AL2(P^) = AL2s[2]); FreeResource(Integer(P)); end else ALOK := False; if not ALOK then ALV; end; procedure RPR; var AL: LongWord; begin AL := GDAL; if (AL <> AL1s[1]) and (AL <> AL1s[2]) then ALV; end; 函数RCS:检查是否有合法的Delphi Client Server许可,不合法就异常.
从上面看,这两个函数我们平时基本用不着了,也是,这两个函数在自带的VCL里面有.有兴趣的朋友可以自己看一下. OK |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论