[英]Windows C++: Check if DLL is present and loadable without calling LoadLibrary
Windows 是否有內置方法來檢查 DLL 是否存在並且可以使用 LoadLibrary 加載,而無需實際調用 LoadLibrary?
I want to check for the presence of DLL B, from within a function called during LoadLibrary for DLL A. Calling LoadLibrary from within a LoadLibrary call (nested LoadLibrary calls) can cause a process to hang, so I'm looking for a different way檢查另一個 DLL 是否排隊加載,或者已經加載。
GetModuleHandle
可以檢查 dll 是否已經加載。
雖然您不應該在 DllMain 中調用LoadLibraryEx
,但使用LOAD_LIBRARY_AS_DATAFILE
調用它可能沒問題。 如果你這樣做,你必須砍掉手柄底部的兩個位,並手動檢查 PE header 中的機器值是否與你的過程相同。 不知道datafile文件搜索能不能保證和普通的dll文件搜索算法一樣。
如果您想確保正常的LoadLibrary
可以工作,您必須檢查導入,並且在您知道之前,您已經編寫了自己的 dll 加載程序......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.