[英]How to register a 64-bit dll (on a 64-bit OS) from a 32-bit application
我目前使用以下函數來注冊處理上下文菜單調用的DLL。
function RegisterLibrary(szLibrary: String): Integer;
var
hLib: THandle;
drs: TDllRegisterServer;
begin
// Attempt to load the library
hLib := LoadLibrary(PChar(szLibrary));
// Handle check
if IsHandle(hLib) then
begin // Get the register function
@drs := GetProcAddress(hLib, LIB_REGISTER);
if Assigned(@drs)
then Result := drs // Make the function call
else Result := GetLastError; // Return last error
// Unload the library
FreeLibrary(hLib);
end else
Result := GetLastError; // Return last error
end;
不幸的是,當嘗試從我的32位應用程序注冊64位dll時,它不起作用。
有沒有辦法從我的32位應用程序(用Delphi編譯)注冊我的64位dll(用free pascal編譯)?
我想我可以調用C:\\ Windows \\ system \\ regsvr32.exe“/ s”filename“但想知道我是否還有其他選擇。
謝謝!
不,32位進程無法加載64位dll。 您必須調用64位進程來為您注冊dll。
您將不得不使用64位進程來執行注冊,因為32位Delphi程序無法將64位DLL加載到其地址空間中。
如果您不想自己編寫代碼,那么您可以查看Inno Setup源代碼。 有一個64位幫助應用程序的Visual Studio項目,單元Helper.pas
具有調用外部幫助程序的代碼,因此您只需使用它包含的HelperRegisterTypeLibrary()
函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.