为什么调用DLL后,程序出错?

netfly 2000-01-05 09:21:00
自己做一个小的DLL,没有dllMain入口,DLL里面只有一个FUNCTION idtobirthday,作用是把身份证号码中的日期以string形式返回:ReSult:=Copy(.....),但是在其他程序调用时,如果没有东西返回,则程序正常,如果有东西返回,则程序在调用完后会出现内存访问错误。
请教了!
...全文
180 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Firing_Sky 2000-01-17
  • 打赏
  • 举报
回复
十有八九是因为你的DLL里封装的函数没有声明为stdcall
tiger 2000-01-05
  • 打赏
  • 举报
回复
在你的程序中加ShareMem单元
-------------------------------
The shared-memory manager

Topic group See also
-------------------------------
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.
kxy 2000-01-05
  • 打赏
  • 举报
回复
barton说的对,是内存的问题.
不妨把你的DLL中函数改成返回BOOL类型,用来判断是否执行成功.
身份证号码中的日期作为一个变参传入.内存在你的主程序中分配和释放,
这样方便一些.
barton 2000-01-05
  • 打赏
  • 举报
回复
没有这么复杂。原因是DLL返回的是String类型,这不行。String是自管理型
类型。你用PChar试试。如果非要用string型也可,用变参。

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧