DLL问题,十万火急啊(100分)

H

hooyu

Unregistered / Unconfirmed
GUEST, unregistred user!
以下函数在单元中定义调用一切正常,转到DLL中出错如下:
GETANYIFUNC 在 0000:64636227 的模块
<未知> 中导致无效页错误。
Registers:
EAX=00e71cac CS=0167 EIP=64636227 EFLGS=00010246
EBX=00e71cac SS=016f ESP=008500e4 EBP=00850104
ECX=00850188 DS=016f ESI=81735c08 FS=6617
EDX=bff768d5 ES=016f EDI=0085027c GS=0000
Bytes at CS:EIP:

Stack dump:
bff768c9 0085027c 00e71cac 008501b0 00850188 00850568 bff768d5 00e71cac 00850198 bff882eb 0085027c 00e71cac 008501b0 00850188 64636227 008502f0

函数内容如下://字符替换

function ZiFuChuanTiHuan(const S, Srch, Replace: string): string;stdcall;
var
I: Integer;
Source: string;
begin
Source := S;
Result := '';
repeat
I := Pos(Srch, Source);
if I > 0 then begin
Result := Result + Copy(Source, 1, I - 1) + Replace;
Source := Copy(Source, I + Length(Srch), MaxInt);
end
else Result := Result + Source;
until I <= 0;

end;
 
刚刚回答过这个问题,再说一遍吧:
在动态连接库之间传递参数最好不要用string,否则必须引用sharemem单元,而且在调用端和Dll
端都要引用,并且必须是第一个,比如uses Sharemem,windows.....,这里Sharemem必须是
第一个!!

如果不用string ,可以用pchar类型来代替.

另外调用方式最后用stdcall方式.


问题讨论没有结束 ...
 
www说的没错,就是Sharemem引用问题;
 
把string都改为pchar就没有问题了
 
把string改widestring就可以了
 
多人接受答案了。
 
顶部