Mega Code Archive

 
Categories / Delphi / System
 

Unload any dll (16bit usage)(ver 2 update)

Title: Unload any dll (16bit usage)(ver 2 update) Question: How to unload any 16 bit DLL whether your app loaded it or another. Answer: Here is a cut of working source code I used while developing - but it only works with 16 bit DLL's. procedure TForm1.btnStopClick(Sender: TObject); var H: THandle; begin H:= GetModuleHandle('armdll.dll'); if H=0 then ShowMessage('DLL is not being used') else begin ShowMessage('DLL is used '+IntToStr(GetModuleUsage(H))+' times'); while GetModuleUsage(H) 0 do FreeModule(H); ShowMessage('Module has been released'); end; end;