Delphi-functions you don't know

Source: Internet
Author: User

Technical Exchange, DH explanation.

There are several functions in sysutils. Pas, which I have never seen before. I accidentally discovered when I read the source code today.

 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; // obtain from resource file If P <> Nil   Then    Begin A1: = al1 (P ^); A2: = Al (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; // throw an exception saying application is not licensed to use this feature End    Else Result: = al1s [3]; End ;

The full name of this function is get Delphi access licences. This function reads the access permission from the resource. If it is invalid, an exception is thrown. If it is legal, the decrypted al1 is returned. The following two functions are used:

 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; // This Is A linked list. If you want to learn the linked list, you can check it out. While Libmodule <> Nil   Do // records      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 ;

Then there is a function that uses gdal, that is, gdal is not directly used:

 Procedure RCS;VaR P: pointer; Alok: Boolean; Begin P: = ALR; If P <> Nil   Then    Begin Alok: = (al1 (P ^) = al1s [2]) And (Al2O3 (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 ;

Function RCS: checks whether a valid Delphi client server license is available. If the permission is invalid, an exception occurs.

Function RPR: Check whether a valid Delphi pro license is available. If the permission is invalid, an exception occurs.

From the above, we usually don't need these two functions. They are also in the built-in VCL. If you are interested, please take a look.

OK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.