问题
Can anyone show me a simple example how this component is used.Thanks
回答1:
In your application (the one you want to protect by embedding a CRC), drop an OgProtectExe
component. Use the Object Inspector
to add a handler for it's single event (OnChecked
, if I remember correctly). The handler should contain something like this:
procedure TForm1.OgProtectExe1Checked(Sender: TObject; Status: TExeStatus);
begin
if (Status <> exeSuccess) then // CRC changed
// Handle modified executable
end;
Possible TExeStatus
values are:
exeSuccess - CRC is OK
exeSizeError - File size has changed
exeIntegrityError - CRC doesn't match
exeNotStamped - Executable not stamped
Build your application as usual. Use StampExe
(from the OnGuard examples\Delphi
folder) to stamp your executable with the CRC (or write your own app that calls the OgProExe
unit's ProtectExe
function to stamp it).
ProtectExe
takes two parameters - the full path and filename of the executable to protect, and a boolean that indicates whether or not it should remove it's special marker after protecting. You should pass True
unless you want to have the ability to unprotect the executable afterwards.
uses
OgProExe;
...
if ProtectExe(YourExeName, EraseMarker) then // executable stamped
来源:https://stackoverflow.com/questions/10261227/using-ogprotectexe-from-tponguard