Ver Mensaje Individual
  #4  
Antiguo 28-12-2016
shoulder shoulder is offline
Miembro
 
Registrado: abr 2008
Posts: 441
Reputación: 17
shoulder Va por buen camino
secureblackbox

Gracias, pregunte en el foro de Secureblackbox no saben porque el delphi me esta reteniendo en algun lugar de memoria la clave de la tarjeta, aunque cierre el form de firmado y no cierre el prg principal, como dije anteriormente no me queda a lo que entiendo mucho que probar en cuanto al "close sin intervension del usuario" les paso resumido el ejemplo que trae secureblackbox que aplico y agregue algunas lineas de comando.

Código Delphi [-]
procedure TfrmMain.btnOKClick(Sender: TObject);
var
  TempPath : string;
  Success : boolean;
  F, CertF : TFileStream;
  Index : integer;
  Sig : TElPDFSignature;
  CertFormat : TSBCertFileFormat;
  Cert : TElX509Certificate;
  SimpleFont: TElPDFSimpleFont;
begin
  // creating a temporary file copy
  TempPath := GenerateTempFilename;
  if not CopyFile(PChar(editSource.Text), PChar(TempPath), false) then
  begin
    MessageDlg('Failed to create a temporary file', mtError, [mbOk], 0);
    Exit;
  end;
  // opening the temporary file
  Success := false;
  F := TFileStream.Create(TempPath, fmOpenReadWrite or fmShareDenyWrite);
  try
    try
      // opening the document
      Document.Open(F);
      try
        // checking if the document is already encrypted
        if Document.Encrypted then
        begin
          MessageDlg('Cannot sign the encrypted document', mtError, [mbOk], 0);
          Exit;
        end;
        // adding the signature and setting up property values
        Index := Document.AddSignature;
       Sig := Document.Signatures[Index];
       Sig.Handler := PublicKeyHandler;
       Sig.AuthorName := {$ifndef UNICODE}MultiByteToUTF8{$endif}(editAuthorName.Text);
       Sig.SigningTime := LocalTimeToUTCTime(Now);


       Sig.WidgetProps.HideDefaultText := true;
       Sig.WidgetProps.AutoPos:= false;
       Sig.WidgetProps.AutoSize:= false;
       Sig.WidgetProps.AutoFontSize := False;
       Sig.WidgetProps.OffsetX:= strtoint(edit1.Text);
       Sig.WidgetProps.OffsetY:= strtoint(edit2.Text);     
       Sig.WidgetProps.BackgroundStyle   := pbsCustom;
       Sig.WidgetProps.CustomText.Add('.......i.', 55, 41, 8);
       sig.Page := 1;
       sig.WidgetProps.Print := true;

            // retrieving signing certificate
        CertStorage.Clear;
        PublicKeyHandler.SignatureType := pstPKCS7SHA1;
        Cert := WinCertStorage.Certificates[comboCertificate.ItemIndex];
        CertStorage.Add(Cert);
          PublicKeyHandler.SignatureType := pstPKCS7SHA1;

        PublicKeyHandler.CertStorage := CertStorage;
        PublicKeyHandler.CustomName := 'Adobe.PPKMS';



        // allowing to save the document
        Success := true;
      finally
        // closing the document
        Document.Close(Success);
      end;
    finally
      FreeAndNil(F);
    end;
  except
    on E : Exception do
    begin
      MessageDlg('Error: ' + E.Message, mtError, [mbOk], 0);
      Success := false;
    end;
  end;
  // if signing process succeeded, moving the temporary file to the place
  // of destination file
  if Success then
  begin
    if not CopyFile(PChar(TempPath), PChar(editDest.Text), false) then
      MessageDlg('Failed to save temporary file', mtError, [mbOk], 0)
    else
      MessageDlg('Signing process successfully finished', mtInformation, [mbOk], 0);
  end
  (*
  else
    MessageDlg('Signing failed', mtError, [mbOk], 0)
  *);
  // deleting temporary file
  DeleteFile(TempPath);
  Close();
end;
Responder Con Cita