功能别名

时间:2014-01-08 19:40:24

标签: c# function winapi alias extern

我想从kernel32.dll导入一些函数,但我想使用不同的名称。示例功能:

[DllImport("kernel32.dll")] private static extern bool ReadProcessMemoryProc64 (...);

private static bool BetterReadableAndWriteableName (...) {
    ReadProcessMemoryProc64(...);
}

如果还有其他方式,包装该功能是我实际上不想要的。

2 个答案:

答案 0 :(得分:13)

使用DllImportAttribute的EntryPoint属性。

[DllImport("kernel32.dll", EntryPoint="ReadProcessMemoryProc64")]
private static extern bool BetterReadableAndWriteableName (...);

答案 1 :(得分:4)

[DllImport("kernel32.dll", EntryPoint = "ReadProcessMemoryProc64")] 
private static extern bool MyName(...);