使用dllimport

sag*_*agi 2 c# pinvoke name-decoration

我正在尝试使用DllImport以下代码中的属性:

[DllImport("grfinger.dll",EntryPoint="_grstartenroll@4")]
public static extern int startenroll(int context);
Run Code Online (Sandbox Code Playgroud)

获取我使用dumpbin/export的函数名称.当我运行代码时,我得到以下异常:

Unable to find an entry point name '_grstartenroll@4' in DLL 'grfinger.dll'.

我该如何解决这个错误?

Par*_*ice 5

_grstartenroll @ 4是dll中的装饰函数名称.

这看起来像标准调用约定命名,你可以尝试:

[DllImport("grfinger.dll",EntryPoint="_grstartenroll@4", CallingConvention=CallingConvention.StdCall]
public static extern int startenroll(int context);
Run Code Online (Sandbox Code Playgroud)

否则我会尝试获取未修饰的函数名称,您可以将dumpbin的输出传递给undname,如下所示:

dumpbin/exports grfinger.dll | undname _grstartenroll @ 4

然后在dll导入中使用未修饰的函数名称.