大家帮我看看这是怎么回事,关于Sharemem(100分)

  • 主题发起人 主题发起人 SmallGhost
  • 开始时间 开始时间
S

SmallGhost

Unregistered / Unconfirmed
GUEST, unregistred user!
我再程序启动的时候动态加载了一个DLL,在Uses中包含了Sharemem单元,可是在执行程序
中LoadLibrary后马上调用FreeLibrary函数就会提示一个下列错误:
project HY.exe raised too many consecutive exceptions: 'access violation at 0x00000000;read of address 0x00000000'.process stopped.use step or run to continue.

装载部分的代码如下:
m_hHandle := LoadLibrary(PChar(arg_szFile));
if m_hHandle <> 0 then
begin
FreeLibrary(m_hHandle)
// 就在这里提示上述错误
end;
在DLL中没有作任何代码,在工程创建后就在uses中加入了Sharemem单元,代码如下:
library Project1;

{ Important note about DLL memory management: ShareMem must be the
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. }

uses
Sharemem, // 就是这里错,如果我把它去掉,就不会提示错误
SysUtils,
Classes;

{$R *.res}

begin
end.

真是不知道为什么呀!
 
你加载这个单元用意是什么?如果非必要,最好都用pchar来代替string在你的DLL需引用的参数中,这样就没必要加这个单元了
 
没必要加这个单元
 
我在DLL中有下列代码,不知道需不需Sharemem单元?
unit Main;

interface

uses Windows,CommonResource,Forms;

function Init(var arg_rCommonRes:RCommonResource) : Integer;stdcall;

exports
Init;

implementation

function Init(var arg_rCommonRes:RCommonResource) : Integer;stdcall;
begin
Result := -3;
end;

end.

RCommonResource的定义如下:
type
RCommonResource = record
r_iImageList : TList;
r_strExecPath : string
// 执行程序的目录
r_strIniConfig : string;
end;
 
你上面写的是什么啊?那么多的英语,是不是毕业论文啊,要不要我用金山快译给你译一下啊!金山专门给我给了一个,你要不要啊?要的话就给我分好了!
 
樓上的真是幽默
 
呵呵,我做好了我的翻译网站,是金山的更新产品,金山万语通,有空去看看
www.帮你翻译.com
 
察看 HY.dpr 中的 uses 段,是否也加了Sharemem,并且Sharemem是否是第一个uses的
单元。
其实很多东西子要自己注意看看就应该明白。
borland 已经告诉你:

{ Important note about DLL memory management: ShareMem must be the
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. }

你还贴出来了,为什么就不能自己看一下呢?
 

Similar threads

I
回复
0
查看
639
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
751
import
I
后退
顶部