我想动态调用DLL,声明了这两个类型,但编译时总提示函数需要返回值。为什么啊?
我看别的例子都是这样用的啊
Type TStrEncrypt = function StrEncrypt(const sInput: string): string; stdcall;
Type TStrDecrypt = function StrDecrypt(const sInput: string): string; stdcall;
我看别的例子都是这样用的啊
Type TStrEncrypt = function StrEncrypt(const sInput: string): string; stdcall;
Type TStrDecrypt = function StrDecrypt(const sInput: string): string; stdcall;
Type TStrEncrypt = function (const sInput: string): string; stdcall;
Type TStrDecrypt = function (const sInput: string): string; stdcall;
我刚才试了下,如果返回值是string 出错,如果改成返回值是Pchar,就不会错了Type TStrEncrypt = function (const sInput: string): PChar; stdcall;
传入参数是string表面看是不出错的。但这样写好吗?
学习中
String 是DELPHI特有的东西,内存管理的问题 建议用PCHAR
如果一定要用的话就在 uses 的时候首先带上 shareMem 并把 borlandmm.dll 一起发布来管理内存