AnnEncryptApply example for C++ Builder
// This example takes a handle to an annotation object that is an encryptor, and does the following
//1. Verifies that it is an encryptor that is associated with a bitmap
//2. changes the key to 123
//3. Applies the encryptor so that it changes state to a decryptor
//4. Prompts the user to continue
//5. Removes the scrambling by applying the decryptor
void TForm1::ExampleAnnEncryptApply (HANNOBJECT hObject )
{
L_INT nObjectType;
L_INT nRet;
nObjectType = LEADAnn1->AnnGetType(hObject);
if (nObjectType != ANNOBJECT_ENCRYPT)
ShowMessage ("This object is not an Encrypt Object.");
LEADAnn1->AnnEncryptOptions->Flags = ANNENCRYPT_ALL;
LEADAnn1->AnnGetEncryptOptions (hObject);
if (LEADAnn1->AnnEncryptOptions->EncryptBitmap == NULL)
{
ShowMessage("The encrypt object is not associated with a bitmap.");
return;
}
if (LEADAnn1->AnnEncryptOptions->Encryptor == false)
ShowMessage("This object is a decryptor.");
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)
LEADAnn1->AnnEncryptApply (hObject, ANNENCRYPTAPPLY_DECRYPTOR);
}