-
-
C#获取win32api的问题
-
发表于:
2008-8-23 16:35
5027
-
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr LoadLibrary(String lpFileName);
[DllImport("kernel32.dll", EntryPoint = "LoadLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
[DllImport("kernel32.dll", EntryPoint = "FreeLibrary", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern bool FreeLibrary(IntPtr hModule);
private void button1_Click(object sender, EventArgs e)
{
IntPtr farProc = GetProcAddress(LoadLibrary("User32.dll"), "MessageBox");
MessageBox.Show(farProc.ToString());
}
奇怪为什么的不到messagebox的地址呢?
LoadLibrary("User32.dll")是可以正常可以获取的,可GetProcAddress去返回0,为什么呢?
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课