szhcracker请进,其他也来看看,delphi调用c++dll的数据类型转换后运行报错(200)

C

cx139

Unregistered / Unconfirmed
GUEST, unregistred user!
读数据操作BOOL ReadData(HANDLE hHandle, WORD wUID, BYTE btBlockIndex, WORD wOffset, BYTE *pData, WORD wLen))参数: hHandle 设备句柄 wUID 信息卡的ID btBlockIndex 块索引,取值1,2,3,4 btOffset 偏移量,取值范围0-1024 pData[out] 用于接收返回的数据缓存区 wLen 指定读入的数据长度,限制:wLen+btOffset小于1024返回: TRUE 成功 FALSE 失败说明: 读如数据时,应用软件从某个数据块中指定位置进行读取,每次最多可读取1k字节的数据。以下是我自己转换的**********************************delphi接口声明function WriteBlock(hHandle:HWND;
wUID:WordBool;
btBlockIndex:Byte;
pData:Byte;
wLen:Word ):Boolean;stdcall;external 'RfidFunc.dll';function ReadData(hHandle:pointer;
wUID:WordBool;
btBlockIndex:Byte;
wOffset:Word;
pData:Byte;
wLen:Word ):Boolean;stdcall;external 'RfidFunc.dll';procedure TfrmMain.btnWriteUClick(Sender: TObject);var btIndex, pDate : Byte;
wlen : Word;
begin
{function WriteBlock(hHandle: HWND;
wUID: WordBool;
btBlockIndex: Byte;
pData: Byte;
wLen: WordBool): Boolean;
cdecl;
external 'RfidFunc.dll';} btIndex := 0;
pDate := 111 ;
wlen := 100;
if WriteBlock(UMonHandle,UMonID,btIndex,pDate,wlen) then
begin
edt2.Text := '写入成功!';
end else
begin
edt2.Text := '写入失败!';
end;
// WriteBlock(UMonHandle,UMonID,btIndex,pDate,wlen);
end;
procedure TfrmMain.btnReadUClick(Sender: TObject);var btIndex, pDate : Byte;
wlen, wOffset : Word;
begin
{function ReadData(hHandle: HWND;
wUID: WordBool;
btBlockIndex: Byte;
wOffset: Word;
pData: Byte;
wLen: Word): Boolean;
cdecl;
external 'RfidFunc.dll';} btIndex := 0;
pDate := StrToInt('174') ;
wlen := 100;
wOffset := 0;
if ReadData(UMonHandle,UMonID,btIndex,wOffset,pDate,wlen) then
begin
edt3.Text := '写入成功!';
end else
begin
edt3.Text := '写入失败!';
end;
end;
执行后返回“写入错误”
 
Y

yuxiaoxue

Unregistered / Unconfirmed
GUEST, unregistred user!
function ReadData(hHandle :Cardinal;
wUID :Word;
btBlockIndex :Byte;
wOffset :Word;
pData :pByte;
wLen :Word):boolean;其他的自己完成
 
C

cx139

Unregistered / Unconfirmed
GUEST, unregistred user!
我上午改为function ReadData(hHandle :hwnd;
wUID :Wordbool;
btBlockIndex :Byte;
wOffset :Word;
pData :pByte;
wLen :Word):boolean;编译通过,但是对指针不熟悉,请问如何将pDate的数据转换为string?
 
Y

yuxiaoxue

Unregistered / Unconfirmed
GUEST, unregistred user!
pData[out] 用于接收返回的数据缓存区wLen 指定读入的数据长度,限制:wLen+btOffset小于1024需要知道pData缓存区的格式才可以分析
 
C

cx139

Unregistered / Unconfirmed
GUEST, unregistred user!
自己已经解决,读取时候不成功原因是事先没有给字符串分配内存。
 
顶部