主题: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’错误,但字符还能正常返回来显示。
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’错误,但字符还能正常返回来显示。