我的应用程序中有一个 API 函数:
<Runtime.InteropServices.DllImport("kernel32.dll", SetLastError:=True, CharSet:=Runtime.InteropServices.CharSet.Ansi, ExactSpelling:=True)>
Private Shared Function GetProcAddress(ByVal hModule As IntPtr, ByVal procName As String) As IntPtr
End Function
我只想知道这个函数的指针'IntPtr'值。我该怎么做?
注意:我会用 C++ 向您展示我想要的东西
void* fnGetProcAddress;
fnGetProcAddress = GetProcAddress;
请您参考如下方法:
好吧,你可以继续使用P/Invoke...
(注意,这是在 C# 中,但很容易转换)
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern IntPtr GetModuleHandle(string moduleName);
var hModule = GetModuleHandle("kernel32.dll");
var procAddress = GetProcAddress(hModule, "GetProcAddress");
