long 能转换为intPtr 类型吗?谁来解释一下哈
我的程序是这样的:
//创建线程钩子
string a = Process.GetCurrentProcess().MainModule.ModuleName;
long moduleName = Win32API.GetModuleHandle(a);
IntPtr b = new IntPtr( moduleName); //这句话出错,错误信息是:算术运算导致溢出。
hHook = Win32API.SetWindowsHookEx(WH_KEYBOARD, KeyBoardProcedure, b, 0);
Win32API中GetModuleHandle()定义如下:
[DllImport("kernel32")]
public static extern long GetModuleHandle(string lpModuleName);
我在网上查的GetModuleHandle的返回值是long类型的,这个例子也是书上的。
呵呵,谁能解释一下哈。