Aquí os dejo el código, la primera función es solo para pasar el array of char a String, la segunda función es la que creo que buscais:
Código Delphi
[-]
function tfrmentradassalidascaja.ArrayToString(const a: array of Char): string;
begin
if Length(a)>0 then
SetString(Result, PChar(@a[0]), Length(a))
else
Result := '';
end;
procedure tfrmentradassalidascaja.enviadatafono(Sender: TObject);
type
TIniTpvpcLatente = Function(cComercio,cTerminal,cClaveFirma,cConfPuerto,cVersion: string) : integer;stdcall;
TOperPinPad = function(cImporte, cFactura, cTipoOper :string; var cXmlResp :array of Char; iTamMaxResp : integer) : integer;stdcall;
var
DLLHandle: THandle;
IniTpvpcLatente: TIniTpvpcLatente;
OperPinPad: TOperPinPad;
respuesta: integer;
strrespuesta, codcomercio,terminal,firma,importe,venta: string;
Str2: array[0..29999] of Char;
begin
codcomercio:='45465464';
firma:='assadfsadfasdfsadfsadf';
terminal:='1';
importe:='20.50';
venta:='Fact1001';
DLLHandle := LoadLibrary('dllTpvpcLatente.dll');
try
if DLLHandle <= 0 then
begin
ShowMessage('Error, conector dllTpvcLatente.dll no encontrado');
exit;
end;
@IniTpvpcLatente := GetProcAddress(DLLHandle, 'fnDllIniTpvpcLatente');
@OperPinPad := GetProcAddress(DLLHandle, PChar('fnDllOperPinPad'));
if Assigned(IniTpvpcLatente) then
begin
respuesta:=IniTpvpcLatente(codcomercio,terminal,firma,'','');
if respuesta < 0 then
begin
showmessage('Error de comunicación con el Datafono/Tpv/PinPad, código de error: ' + inttostr(respuesta));
Exit;
end;
strrespuesta:='';
respuesta:=OperPinPad(importe,venta,'PAGO',Str2,30000);
if respuesta < 0 then
begin
showmessage('Error al enviar la orden al Datafono/Tpv/PinPad, código de error: ' + inttostr(respuesta));
Exit;
end;
strrespuesta:=ArrayToString(Str2);
if pos('Autorizada',strrespuesta)> 0 then
begin
showmessage('Operación Aceptada');
end
else
begin
showmessage('Operación Denegada');
exit;
end;
end
else
begin
ShowMessage('Error, procedimiento/Funcion no encontrado');
end;
except
on E : Exception do
begin
ShowMessage('Exception class name = '+E.ClassName);
ShowMessage('Exception message = '+E.Message);
end;
end;
end;