AnnEncryptApply example for Delphi
Procedure TForm1.ExampleAnnEncryptApply ( hObject: HANNOBJECT );
var
nObjectType: L_INT;
nRet: L_INT;
begin
nObjectType:= LEADAnn1.AnnGetType(hObject);
if(nObjectType = ANNOBJECT_ENCRYPT) then
begin
ShowMessage('This object is not an encryptor object.');
Exit;
end;
LEADAnn1.AnnEncryptOptions.Flags:= ANNENCRYPT_ALL;
LEADAnn1.AnnGetEncryptOptions (hObject);
if (LEADAnn1.AnnEncryptOptions.EncryptBitmap = NULL) then
begin
ShowMessage('The encrypt object is not associated with a bitmap.');
Exit;
end;
if (LEADAnn1.AnnEncryptOptions.Encryptor = false) then
begin
ShowMessage('This object is a decryptor.');
end;
LEADAnn1.AnnEncryptOptions.Key:= 123;
LEADAnn1.AnnEncryptOptions.Flags:= ANNENCRYPT_KEY;
LEADAnn1.AnnEncryptOptions.SaveDecryptorKey:= true;
LEADAnn1.AnnEncryptOptions.SaveEncryptorKey:= true;
LEADAnn1.AnnEncryptOptions.ClearDecryptorKey:= true;
LEADAnn1.AnnEncryptOptions.ClearEncryptorKey:= true;
LEADAnn1.AnnEncryptOptions.NeverEncrypted:= false;
LEADAnn1.AnnFlags:= 0;
LEADAnn1.AnnSetEncryptOptions(hObject);
LEADAnn1.AnnEncryptApply(hObject, ANNENCRYPTAPPLY_ENCRYPTOR);
nRet:= Application.MessageBox('Encryptor has been applied. Would you like to remove the encryption?','', MB_YESNO);
if (nRet = IDYES) then
begin
LEADAnn1.AnnEncryptApply (hObject, ANNENCRYPTAPPLY_DECRYPTOR);
end;
end;