// use reflection to get the dll HINSTANCE
Assembly assembly = Assembly.GetExecutingAssembly();
Module current = assembly.GetModules()[0];
IntPtr module = Marshal.GetHINSTANCE(current);
Assembly assembly = Assembly.GetExecutingAssembly();
Module current = assembly.GetModules()[0];
IntPtr module = Marshal.GetHINSTANCE(current);
博客展示了在.NET中使用反射获取DLL句柄的代码。通过Assembly.GetExecutingAssembly()获取当前程序集,再用assembly.GetModules()[0]获取模块,最后使用Marshal.GetHINSTANCE(current)得到模块的句柄。

被折叠的 条评论
为什么被折叠?



