DELPHI 求解DLL 返回 PCAHR 变量 问题
发布网友
发布时间:2023-07-18 16:06
我来回答
共2个回答
热心网友
时间:2024-12-04 18:23
如果你的function SRPL是在DLL中定义的,这样写肯定错了,不能使用string,除非在程序中添加ShareMem 并附带一个BORLNDMM.DLL文件,在新建立的DLL文件的unit中有说明的:
{ 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 proceres 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. }
不想这么复杂,把string全部改成PCHAR就可以很简单的解决了。
热心网友
时间:2024-12-04 18:23
我看到有两点问题,你修正一下看能不能解决。
1。对资源的请求 stralloc应该放到try..finally..end结构的外面去。在这个程序里看起来问题不大。
2。 对Buffer请求的空间大小应该是你传输数据大小+1,不要忘了后面还有一个#0需要保存。