///
/// win32 dll 函数动态封装调用
///
///
/// bool flag = false;
/// // 构造时导致 dll 被加载, 借助 using 块, 在离开时释放 dll
/// using (CDCWrapper wrapper = new CDCWrapper())
/// {
/// flag = wrapper.GetLastVerFile(163, "192.168.0.135", "", 0, "ccir", "1B2M2Y8AsgTpgAmY7PhCfg==", "d://1.dwg");
/// MessageBox.Show(flag.ToString());// 这个提示的时候 dll 还在内存中
/// }
/// MessageBox.Show(flag.ToString());// 这个提示时, dll 已经被卸载出内存了
///
class CDCWrapper : IDisposable
{
public CDCWrapper()
{
loadLibray();
}
/// win32 dll 函数动态封装调用
///
///
/// bool flag = false;
/// // 构造时导致 dll 被加载, 借助 using 块, 在离开时释放 dll
/// using (CDCWrapper wrapper = new CDCWrapper())
/// {
/// flag = wrapper.GetLastVerFile(163, "192.168.0.135", "", 0, "ccir", "1B2M2Y8AsgTpgAmY7PhCfg==", "d://1.dwg");
/// MessageBox.Show(flag.ToString());// 这个提示的时候 dll 还在内存中
/// }
/// MessageBox.Show(flag.ToString());// 这个提示时, dll 已经被卸载出内存了
///
class CDCWrapper : IDisposable
{
public CDCWrapper()
{
loadLibray();
}
#region public function wrappers
public bool GetLastVerFile(int nFileId, string strServerIP,
public bool GetLastVerFile(int nFileId, string strServerIP,

这篇博客介绍了如何在 C# 中动态加载、调用和释放 Win32 DLL 文件。通过 CDCWrapper 类,作者展示了如何使用 `LoadLibrary`、`GetProcAddress` 和 `FreeLibrary` 方法来操作 DLL,并且提供了一个示例,展示了如何封装 DLL 函数并确保在适当的时候释放 DLL。示例中,DLL 的一个函数 `GetLastVerFile` 被调用来获取文件的最新版本。
1885

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



