Mega Code Archive

 
Categories / Delphi / Examples
 

Unload dynamic link librarys from memory

Force Windows To Unload Dlls from memory ShellSPY V1.1a is the award winning and powerful monitoring solution that you need! ShellSPY gives you the power to log all keystrokes, windows viewed, applications ran, internet connections made, passwords entered, chat conversations that were made, Monitor all running tasks on your pc Download Now Web Site: Cjpsoftware.com Windows Explorer caches DLLs (Dynamic-Link Libraries) in memory for a period of time after the application using them has been closed. This can be an inefficient use of memory on low memory systems, and may cause problems or delays for programmers developing with Windows DLL files. Open your registry and find the key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer]. Create a new sub-key named 'AlwaysUnloadDLL' and set the default value to equal '1' to disable Windows caching the DLL in memory. Restart Windows for the change to take effect. unit dllobject; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,registry; type TForm1 = class(TForm) CheckBox1: TCheckBox; procedure CheckBox1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure UnloadDLL(Stat: Boolean);stdcall; var path : String; Reg : TRegistry; begin Reg := TRegistry.CReate; try With Reg Do Begin RootKey := HKEY_LOCAL_MACHINE; Path := '\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AlwaysUnloadDLL'; If Not KeyExists(Path) Then OPenKey(Path,true) Else Openkey(Path,False); Case Stat of True: WriteString(#0,'1'); false:WriteString(#0,''); End; End; Finally Reg.CloseKey; Reg.Free; End; End; procedure TForm1.CheckBox1Click(Sender: TObject); begin If checkbox1.checked then Unloaddll(true) Else Unloaddll(False); end; end. If you wish I will create a unit which includes all the code.. Just send me an email..