未找到Win32::API perl过程



我正在尝试使用perl代码中的Win32 dll。

use Win32::API;
$Win32::API::DEBUG = 1;
$function = Win32::API->new(
  'mydll.dll', 'int myfunc()',
);
$return = $function->Call();

但我得到以下错误:

Win32::API::new: Loading library 'mydll.dll'
(PM)parse_prototype: got PROC 'myfunc'
(PM)parse_prototype: got PARAMS ''
parse_prototype: IN=[  ]
parse_prototype: OUT='int' PACKING='i' API_TYPE=3
FAILED GetProcAddress for Proc 'myfunc': The specified procedure could not be found.
Can't call method "Call" on an undefined value at .test_dll.pl line 6.

我的dll是使用_cdecl调用约定编译的。这有什么不同吗?我在windows 7 上使用活动的perl 5.14

是否使用__declspec(dllexport)从DLL导出函数?如果是,请改用.def文件。因为__declspec(dllexport)会使DLL的导出描述符中的函数名前面有下划线;如果你的函数是C++,也可以修改函数名。

上次我使用Win32::API时,它不支持__cdecl。您应该将其更改为__stdcall

使用StudPE、PE Explorer或dumpbin/exports查找要使用的函数的真实名称。这样,你就不在乎函数是否被名称修饰了。你知道它的真名。

最新更新