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 address.....’错误,但字符还能正常返回来显示。
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 address.....’错误,但字符还能正常返回来显示。
解决方案 »
- databridge access violation ...read of address ...
- 怎样给fastreport rich文本对象赋值?
- 打印问题???急啊,元旦都不能休息!!!!!
- 问个高难度的问题
- 如何得到一个大字符串中的子串?
- 水晶报表9.2自己说支持到d6,怎么弄到Delphi7上去呀,高人指点!!!
- 请教几个fastreport的问题,主要是主从表的
- 麻烦一下,如何实现用户自定义热键呀?
- 各位高手请进,下面是我面试中的一条题。
- 一个比较容易的问题!!!(看看你会不会?)
- 求一SQL语语
- 调试出现"access violation at address 00000000",如何解决!
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters.
在DLL中使用String类型:
1、在你的DLL项目源文件中第一个引用ShareMem单元;
2、你必须在你的应用程序项目源文件中第一个引用SHAREMEM单元;
TCommuConnect_ErrorCodes=Function(x:byte):String;stdcall;改成:
TCommuConnect_ErrorCodes=Function(x:byte):PChar;stdcall; //返回值类型改为PChar试一下吧