dll 用SPComm建立的。。返回函数改为了shortstring(20分)

  • 主题发起人 风零落
  • 开始时间

风零落

Unregistered / Unconfirmed
GUEST, unregistred user!
Dll现在的问题是一调用的时候就出现了
Access violation at address 003c2841 in module 'DllCON.dll',Read of address 00000038.
这样的错误。其中DLLCON.DLL是我编写的。请问一般要怎么解决阿。

问,内存怎么分配
 
看看你的部分代码!
 
有可能参数或指针的访问不正确。
 
代码:
procedure Transmit;
var
i,count:integer;
commflg:boolean;
sbuf:array of byte;
begin
commflg:=true;
count:=Length(Send);
setLength(sbuf,count);
for i:=1 to count do
begin
sbuf:=byte(Send);
if not Form1.Comm1.WriteCommData(@sbuf,1) then
begin
commflg:=false;
break;
end;
sleep(2);
end;
if not commflg then
MessageDlg('发送失败!',mterror,[mbyes],0);
end;

procedure ReadData;
var
buffer:pointer;
BufferLength:Word;
begin
SetLength(Receive,BufferLength);
Move(Buffer^,Receive,BufferLength);
end;



Function OpenCom(Comname:shortstring):BOOL;//打开串口
begin
Comm1.StartComm;
Comm1.CommName:=Comname;
end;

Function CloseCom:BOOL;//关闭串口
begin
Comm1.StopComm;
end;

Function SetNetID(BoardID:integer;Address:integer):BOOL;//设置门禁机网络逻辑地址号
begin
bagsize:=chr($04);
s0:=start;
s1:=start;
s2:=chr($4f);
s3:=chr(Address);
s4:=bagsize;
s5:=chr(BoardID);
Send:=s0+s1+s2+s3+s4+s5;
Transmit;

ReadData;
Raddress:=r3;
r0:=copy(Receive,1,1);
r1:=copy(Receive,2,1);
r2:=copy(Receive,3,1);
r3:=copy(Receive,4,1);
bagnumber:=copy(Receive,5,2);
if r0+r1=start+start then
if r2=chr($5f) then
Result:=true
else if r2=chr($7f) then
Result:=false
end;
 

Similar threads

S
回复
0
查看
959
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
顶部