我試圖加載安裝與在C打印機驅動程序DLL:\ WINDOWS \ SYSTEM32 \文件夾下面的代碼:LoadLibraryW()無法加載DLL在System32中
LoadLibraryW(L"C:\\Windows\\System32\\MagAPI.dll");
GetLastError()
正在報告「找不到指定的模塊」。如果我將DLL移到System32文件夾的外部(例如C:\ SomeFolder \ MagAPI.dll),那麼它將加載正常,所以它看起來不像是DLL本身的問題。是否有一些奇怪的Windows安全功能可能會阻止我的應用程序加載它?這是我能想到的唯一的事情,但我找不到任何明確的答案。
下面是從ShowSnaps輸出的調試,這顯示了它的失敗:
1a8c:1fd4 @ 19006756 - LdrLoadDll - ENTER: DLL name: C:\Windows\system32\MagAPI.dll DLL path: C:\Windows\system32;C:\Windows\system;C:\Windows;.;<otherstuff>
1a8c:1fd4 @ 19006756 - LdrpLoadDll - ENTER: DLL name: C:\Windows\system32\MagAPI.dll DLL path: C:\Windows\system32;C:\Windows\system;C:\Windows;.;<otherstuff>
1a8c:1fd4 @ 19006756 - LdrpLoadDll - INFO: Loading DLL C:\Windows\system32\MagAPI.dll from path C:\Windows\system32;C:\Windows\system;C:\Windows;.;<otherstuff>
1a8c:1fd4 @ 19006756 - LdrpFindOrMapDll - ENTER: DLL name: C:\Windows\system32\MagAPI.dll DLL path: C:\Windows\system32;C:\Windows\system;C:\Windows;.;<otherstuff>
1a8c:1fd4 @ 19006756 - LdrpSearchPath - ENTER: DLL name: C:\Windows\system32\MagAPI.dll DLL path: C:\Windows\system32;C:\Windows\system;C:\Windows;.;<otherstuff>
1a8c:1fd4 @ 19006756 - LdrpResolveFileName - ENTER: DLL name: C:\Windows\system32\MagAPI.dll
1a8c:1fd4 @ 19006756 - LdrpResolveFileName - RETURN: Status: 0xc0000135
1a8c:1fd4 @ 19006756 - LdrpSearchPath - RETURN: Status: 0xc0000135
1a8c:1fd4 @ 19006756 - LdrpFindOrMapDll - RETURN: Status: 0xc0000135
1a8c:1fd4 @ 19006756 - LdrpLoadDll - RETURN: Status: 0xc0000135
1a8c:1fd4 @ 19006756 - LdrLoadDll - RETURN: Status: 0xc0000135
你在什麼版本的Windows?您可能需要管理員權限才能查看System32的內容。你可以做的快速測試是右鍵單擊並以管理員身份運行你的應用程序(win vista及以上,我認爲),如果它的工作,那就是問題所在。 –
@JesusRamos我已經證實,該DLL在該文件夾中的確切路徑,如果這就是你問的。 – Shenjoku
不,我要求您確認它是否是權限問題。有時從代碼訪問System32需要正在運行的應用程序的管理權限,即使只是讀取文件。 –