动态调用Dll

虎滴小猪猪 2009-02-20 05:49:52
我想动态调用DLL,声明了这两个类型,但编译时总提示函数需要返回值。为什么啊?
我看别的例子都是这样用的啊
Type TStrEncrypt = function StrEncrypt(const sInput: string): string; stdcall;
Type TStrDecrypt = function StrDecrypt(const sInput: string): string; stdcall;
...全文
87 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
虎滴小猪猪 2009-02-23
  • 打赏
  • 举报
回复
谢谢。结贴
wwwzxl 2009-02-21
  • 打赏
  • 举报
回复
用PChar
frankie_24 2009-02-20
  • 打赏
  • 举报
回复
还有shareMem 一定要放在单元引用第一位!
starluck 2009-02-20
  • 打赏
  • 举报
回复

如果一定要用的话就在 uses 的时候首先带上 shareMem

并把 borlandmm.dll 一起发布来管理内存
starluck 2009-02-20
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 ljfwyh 的回复:]
DLL文件里的函数在声明时,传入和返回的参数可以是string吗?
我刚才试了下,如果返回值是string 出错,如果改成返回值是Pchar,就不会错了

Delphi(Pascal) code
Type TStrEncrypt = function (const sInput: string): PChar; stdcall;




传入参数是string表面看是不出错的。但这样写好吗?
学习中。。。。。。
[/Quote]

String 是DELPHI特有的东西,内存管理的问题 建议用PCHAR
preserve 2009-02-20
  • 打赏
  • 举报
回复
要用string的要引用sharemem单元
Seamour 2009-02-20
  • 打赏
  • 举报
回复
可以是,也有办法解决,但不推荐用string,主要原因是dll程序不应该使用某种语言特有的数据类型
虎滴小猪猪 2009-02-20
  • 打赏
  • 举报
回复
DLL文件里的函数在声明时,传入和返回的参数可以是string吗?
我刚才试了下,如果返回值是string 出错,如果改成返回值是Pchar,就不会错了

Type TStrEncrypt = function (const sInput: string): PChar; stdcall;


传入参数是string表面看是不出错的。但这样写好吗?
学习中。。。。。。
虎滴小猪猪 2009-02-20
  • 打赏
  • 举报
回复
返回值是string行吗?
sanguomi 2009-02-20
  • 打赏
  • 举报
回复

Type TStrEncrypt = function (const sInput: string): string; stdcall;
Type TStrDecrypt = function (const sInput: string): string; stdcall;

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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