DLL卸载本身 [英] DLL unloading itself

查看:120
本文介绍了DLL卸载本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DLL内部的函数是否可以卸载DLL?我需要这样做,所以我可以确保DLL没有被使用,然后写入DLL的文件。

Is it possible for a function that is inside a DLL to unload the DLL? I need to do this so I can make sure the DLL is not in use, then write to the DLL's file.

推荐答案

我不要以为会奏效使用外部的句柄调用FreeLibrary(LoadLibrary将从DLL外部的区域调用),因为代码在不再有效的内存位置运行。

I don't think it will work. Calling FreeLibrary with a handle from the outside (LoadLibrary would have been called from an area outside the DLL) as the code runs in a memory location that will not be valid anymore.

即使这样可能,它闻起来像一个糟糕的设计。也许你想做一些更新或一样。说明一下你期望的结果。从内部卸载DLL是不行的。

Even if this is possible, it smells like a bad design. Maybe you want to make some updater or alike. Explain a bit more what is the result you expect. Unloading a DLL from within itself is not the way to go.

这篇关于DLL卸载本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆