Delphi出现"Invalid pointer operation"异常的解决办法

Delphi使用dll跨进程传递长字符串或动态数组,经常会出现invalid pointer operation的错误提示。


解决方法: 将DLL工程文件和调用的程序工程文件, USE 后第一个位置,添加引用ShareMem单元,使应用程序可以和DLL共享地址空间。

DELPHI 帮助文件解释如下:

On Windows, if a DLL exports routines that pass long strings or dynamic arrays as parameters or function results (whether directly or nested in records or objects), then the DLL and its client applications (or DLLs) must all use the ShareMem unit. The same is true if one application or DLL allocates memory with New or GetMem which is deallocated by a call to Dispose or FreeMem in another module. ShareMem should always be the first unit listed in any program or library uses clause where it occurs.

ShareMem is the interface unit for the BORLANDMM.DLL memory manager, which allows modules to share dynamically allocated memory. BORLANDMM.DLL must be deployed with applications and DLLs that use ShareMem. When an application or DLL uses
ShareMem, its memory manager is replaced by the memory manager in BORLANDMM.DLL.

转载于:https://my.oschina.net/u/2607133/blog/598984

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值