如果你的dll需要传递动态数组, 就必须加上sharemem单元,
具体请看下面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.
具体请看下面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.
谢谢Tiger的回答,
你贴的那段文章我似乎在help中看过。依你的建议,我应该如何修改我的程序呢?
Function a:PChar;能不能修改成Procedure a(out return: PChar)来避开
"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), "中function result的限制?这我可以试一下,但是动态数组我又该用什么替代,最好是在VC++中能用char*[]来引用?
char*[]是不是很类似Array of PChar???
由于Delphi本身的问题,在模块间或是DLL间传递复杂变量类型
会使接收方无法正常接收.
采用PChar而不是String在模块间传递字符串,因为String在Delphi中也是复杂类型.