仅出于测试目的我在delphi中创建了一个小DLL。代码是:
library MyDll;
uses
SysUtils,
Classes,
Vcl.Dialogs;
function DllMessage(const echo: string): string; export;
begin
//ShowMessage('Hello world from a Delphi DLL') ;
Result := 'Echo: ' + echo;
end;
exports DllMessage;
begin
end
我只想用这个nodejs代码运行一些简单的东西:
var ffi = require('ffi');
console.log("1");
var mylib = ffi.Library('MyDll', {'DllMessage': [ 'string', [ 'string' ] ] });
console.log(2");
var outstring = mylib.DllMessage('abc');
console.log("3" + outstring);
问题是我看到" 1"和" 2"在控制台上没有别的。 请帮忙,任何想法?
提前致谢
答案 0 :(得分:0)
将字符串数据作为缓冲区传递
var message = Buffer.from('abc')
var outstring = mylib.DllMessage(message);
console.log("3" + outstring);