I've converted the following from "RFIDAPI.dll" C function to Delphi:
bool SAAT_YTagSelect( void *pHandle,
unsigned char nOpEnable,
unsigned char nMatchType,
unsigned char *MatchData,
unsigned char nLenth )
to
function SAAT_YTagSelect( pHandle: Pointer;
nOpEnable,
nMatchType,
MatchData,
nLenth: PAnsichar): Boolean; stdcall;
I am trying to call the function and I am getting an Access Violation. Apparently I am not assigning the correct value to the nOpEnable 1Byte variable.
Variable nOpEnable Buzzer or LED enable(1byte):
1: enable 0: disable 7 6 5 4 3 led buzzer N/A N/A N/A N/A N/A 1 1
procedure TForm5.Button4Click(Sender: TObject);
var
hp: Pointer;
b: array[0..7] of AnsiChar;
begin
b[0] := '1';
b[1] := '1';
b[2] := '0';
b[3] := '0';
b[4] := '0';
b[5] := '0';
b[6] := '0';
b[7] := '0';
if SAAT_YTagSelect(hp, b, '0x01', '84500080', '8') then
StatusBar1.Panels[1].Text := 'Tag Selected';
end;
char *is a pointer to an 8-bit character in C, so it can be translated asPAnsiChar. ThePin that name stands for pointer. So you would normally translatechartoAnsiChar, not toPAnsiChar(big difference!). But char can also by a byte, in C, especially if it is used asunsigned char. So the correct translation ofunsigned charis, most of the time,Byte.