-
-
C#获取win32api的问题
-
发表于:
2008-8-23 16:35
5065
-
[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,为什么呢?
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!