R
risingsoft
Unregistered / Unconfirmed
GUEST, unregistred user!
自己编写的ActiveX控件出了点问题,请指教~!:
其他公司提供的DLL,里面有一读卡函数
原型:
int ReadCard(int ReadType=9, int RecordId=1, char* DataBuffer);
我在Delphi里定义为
const
DllName='DBLib2.dll';
Function ReadCard(ReadType:Integer;
RecordId:Integer;
DataBufferChar):Integer;{stdcall;}stdcall;external DllName;
然后建立一类进行封装
TLnHisObj = class(TObject)
private
fDataBuffer: PChar;
public
constructor Create;
Function VbReadCard():Integer;
end;
constructor TLnHisObj.Create;
begin
inherited;
GetMem(fDataBuffer,1024);
end;
function TLnHisObj.VbReadCard: Integer;
begin
result := ReadCard(9, 1, fDataBuffer);
end;
然后创建一ActiveForm控件进行包装
TLnHis = class(TActiveForm, ILnHis)
procedure ActiveFormCreate(Sender: TObject);
private
FEvents: ILnHisEvents;
fLnHisObj : TLnHisObj;
procedure BeforeFree;
protected
function VbReadCard: Integer;
safecall;
end;
procedure TLnHis.ActiveFormCreate(Sender: TObject);
begin
fLnHisObj := TLnHisObj.Create;
end;
procedure TLnHis.BeforeFree;
begin
fLnHisObj.free;
end;
function TLnHis.VbReadCard: Integer;
begin
Result := fLnHisObj.VbReadCard;
end
编译OCX,注册,在HTM里测试时,执行VbReadCard就报错,内存错误,看不懂哪里出错了?
把fDataBuffer改为一维固定1024长度Char数组也不行。可是我做了另一个EXE,测试TLnHisObj类的实例对象的读卡VbReadCard函数是成功的,郁闷了!!请大家指点~!!
其他公司提供的DLL,里面有一读卡函数
原型:
int ReadCard(int ReadType=9, int RecordId=1, char* DataBuffer);
我在Delphi里定义为
const
DllName='DBLib2.dll';
Function ReadCard(ReadType:Integer;
RecordId:Integer;
DataBufferChar):Integer;{stdcall;}stdcall;external DllName;
然后建立一类进行封装
TLnHisObj = class(TObject)
private
fDataBuffer: PChar;
public
constructor Create;
Function VbReadCard():Integer;
end;
constructor TLnHisObj.Create;
begin
inherited;
GetMem(fDataBuffer,1024);
end;
function TLnHisObj.VbReadCard: Integer;
begin
result := ReadCard(9, 1, fDataBuffer);
end;
然后创建一ActiveForm控件进行包装
TLnHis = class(TActiveForm, ILnHis)
procedure ActiveFormCreate(Sender: TObject);
private
FEvents: ILnHisEvents;
fLnHisObj : TLnHisObj;
procedure BeforeFree;
protected
function VbReadCard: Integer;
safecall;
end;
procedure TLnHis.ActiveFormCreate(Sender: TObject);
begin
fLnHisObj := TLnHisObj.Create;
end;
procedure TLnHis.BeforeFree;
begin
fLnHisObj.free;
end;
function TLnHis.VbReadCard: Integer;
begin
Result := fLnHisObj.VbReadCard;
end
编译OCX,注册,在HTM里测试时,执行VbReadCard就报错,内存错误,看不懂哪里出错了?
把fDataBuffer改为一维固定1024长度Char数组也不行。可是我做了另一个EXE,测试TLnHisObj类的实例对象的读卡VbReadCard函数是成功的,郁闷了!!请大家指点~!!