Ver Mensaje Individual
  #2  
Antiguo 25-03-2014
kbolas kbolas is offline
Registrado
NULL
 
Registrado: mar 2014
Posts: 1
Reputación: 0
kbolas Va por buen camino
Cita:
Empezado por mordaz Ver Mensaje
Buenos dias,

Estoy tratando de traducir el código de ejemplo del SDK del lector biometrico Digital Persona de un ejemplo de Delphi a C++ Builder, pero no logro hacerlo funcionar correctamente.

El código original es el siguiente:

Código Delphi [-]

procedure TForm1.SaveTemplate();
 var
outFile : File of byte;
vrnt: Variant;
vtByteBuf : PByteArray;
aryLow: integer;
aryHigh : integer;
rawDataSize: integer;
loopIndex : integer;
numWritten : integer;
bt : byte;
iTemplate : DPFPShrXLib_TLB.IDPFPTemplateDisp;
begin

try
if SaveDialog.Execute then
      begin
iTemplate := DPFPEnrollment.Template as DPFPShrXLib_TLB.IDPFPTemplateDisp;
vrnt:=iTemplate.Serialize;  //raw data is now stored in this variant

        //Now that you have the variant, try to get raw byte array
        //We are assuming here that you cannot save a variant directly to database field
        //That you need a byte array before saving the data to the database.
        
        aryLow:=VarArrayLowBound(vrnt,1);
        aryHigh:=varArrayHighBound(vrnt,1);
        aryHigh:=aryHigh-aryLow;

        vtByteBuf:=VarArrayLock(vrnt);  //lock down the array
        AssignFile(outFile,saveDialog.FileName);
        Rewrite(outFile);
        for loopIndex := 0 to aryHigh  do
        begin
               //fpData[loopIndex]:=vtByteBuf[loopIndex];
               //bt:=fpData[loopIndex];
               Write(outFile,vtByteBuf[loopIndex]);  //Save directly to file here
        end;
        VarArrayUnlock(vrnt);
      end;
except
on E: Exception do showmessage('Trouble saving data');
end;
        CloseFile(outFile);


end;

Mi codigo en C++ Builder es el siguiente

Código:
void __fastcall TForm1::btnSaveClick(TObject *Sender)
{
  //Guardando la muestra
  OleVariant Ovt;
  IDispatch &pSample=static_cast<IDispatch&>(*DPFPEnrollment->Template);
  IDPFPSample &Muestra=static_cast<IDPFPSample&>(pSample);
  Muestra.Serialize(Ovt);

  //Guardando en archivo
  int aryLow;
  int aryHigh;
  Variant vrnt;
  vrnt=reinterpret_cast <Variant&> (Ovt);
  aryLow=VarArrayLowBound(vrnt,1);
  aryHigh=VarArrayHighBound(vrnt,1);
  aryHigh=aryHigh-aryLow;
  PByteArray vtByteBuf=(PByteArray)VarArrayLock(vrnt);

  ofstream myfile;
  myfile.open ("muestra.bin", ios::out | ios::app | ios::binary);
  for (int loopIndex=0;loopIndex<=aryHigh;loopIndex++){
     myfile<<vtByteBuf[loopIndex];
  }
  VarArrayUnlock(vrnt);
  myfile.close();
}
El código me genera correctamente el archivo "muestra.bin" pero al compararlo en tamaño con uno generado con Delphi existe una diferencia en tamaño considerable. Lo que me hace suponer que no estoy guardando los datos correctamente.

Gracias por su apoyo.
Hola, buenas tardes, sabes que tengo el mismo problema en c++ builder, y no logro hacerlo funcionar. solo me agrega 2 controles de OCX, pero no puedo crear ningun tipo de variable( ej. *DPFPEnrollment->) para utilizar el lector, los controles funciona, si corro la aplicacion, el programa me pide que capture la huella 4 veces, y al termino me dice que todo esta bien, pero no puedo recuperar los datos de la huella que se utilizo, supongo que es por el sdk que no se me registra bien. Estoy usando C++ Builder 4. Alguna sugerencia?

Gracias de Antemano
Responder Con Cita