March 2000
Intermediate to advanced
576 pages
18h 13m
English
AddModuleUnloadProc Procedure
procedure AddModuleUnloadProc(Proc: TModuleUnloadProc); procedureYourProcedure(HInstance: THandle); begin ... end; AddModuleUnloadProc(YourProcedure);
Delphi keeps a list of packages that
comprise an application. When Delphi unloads a package, it calls a
series of unload procedures, passing the package DLL’s instance
handle to each one. You can add your own unload procedure to the head
of the list by passing its address to
AddModuleUnloadProc. When the application exits,
Delphi calls the module unload procedures for the application,
too.
AddModuleUnloadProc is a real procedure.
// The graphics server manages graphical resources. // When the application loads a graphical resource, the server // checks the color depth of the resource and if it is higher // than the color depth of the display, it makes a new copy of // the graphical object at the display's color depth, and returns // the new graphical object. Using a high-quality renderer // gives better results than letting Windows do the color matching. // // When a module is unloaded, free all of its resources. type PResource = ^TResource; TResource = record Module: THandle; Resource: TGraphicsObject; case Boolean of True: (Name: PChar;); False: (ID: LongInt;); end; var List: TList; procedure ByeBye(HInstance: THandle); var I: Integer; Resource: PResource; begin for I := List.Count-1 downto 0 do begin Resource := List[I]; if Resource.Module = HInstance then begin List.Delete(I); ...
Read now
Unlock full access