回 帖 发 新 帖 刷新版面

主题:delphi调用Dll报错,急!

procedure TMainForm.mmiHelpClick(Sender: TObject);
Type
  TCommuConnect_ErrorCodes=Function(x:byte):String;stdcall;
var
  Commu_Code:byte;
  Th:THandle;
  Tf:TCommuConnect_ErrorCodes;
  Tp:TFarproc;
begin
     comBioMed :=CreateOLEObject('BioMed.Instruments');
     Commu_Code :=comBioMed.SetSetting(USB_Communicate);
try
     Th:=LoadLibrary(PChar('ErrorHandling.dll'));
     if Th>0 then
        @Tf:=GetProcAddress(Th,PChar('CommuConnect_ErrorCodes'));
        if Assigned(Tf) then
           begin
           Label1.Caption:=Tf(Commu_Code);
           end;
finally
     FreeLibrary(Th);//单步执行到这是报上述错误
end;
end;
此程序是完成返回一个字符串功能,报‘Access Vilolation at address00404B50 in moudle '我的程序.exe'.Read of address 03BE0B08’错误,但字符还能正常返回来显示。

回复列表 (共2个回复)

沙发

内存分配的问题

板凳

我知道是,我想问程序中那有错误.

我来回复

您尚未登录,请登录后再回复。点此登录或注册