Name
HInstance Variable
Syntax
unit SysInit; var HInstance: LongWord;
Description
The HInstance
variable stores the instance handle
for the module (application, library, or package) that contains the
HInstance
reference.
Tips and Tricks
The most common use for a module’s instance handler is to load resources from the module. A unit can use
HInstance
to load resources that are linked with that unit (using the$R
compiler directive). To load resources that are linked with a different unit (which might reside in a different package), see theFindHInstance
function.To load resources that must be localized (e.g., forms, strings), see
FindResourceHInstance
.The instance handle of the main application is stored in
MainInstance
.Earlier versions of Delphi stored the main instance handle in
HInstance
, requiring a call toFindHInstance
to learn a module’s instance handle. The current release stores the module’s instance handle inHInstance
.
Example
// Use the Image Editor to create a .RES file that // contains the company logo as the resource named LOGO. // The GetLogo procedure sets its Bitmap argument // to the company logo bitmap. {$R 'Logo.res'} procedure GetLogo(Bitmap: TBitmap); begin Bitmap.LoadFromResourceName(HInstance, 'LOGO'); end;
See Also
FindClassHInstance Function, FindHInstance Function, MainInstance Variable |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.