Sharing Resources

Resources are read-only data objects that are bound into an executable file by the Resource Compiler. Resources can be bound into an application's .EXE file, as well as into a library's .DLL file. Windows has built-in support for eight resource types:

Accelerator tables

Bitmaps

Cursors

Dialog box templates

Fonts

Icons

Menu templates

String tables

In addition to using the standard Windows resources, you can create custom resources and install them into an executable file.

A DLL's resources can be shared between applications; this saves memory when multiple applications are running.

Resources that reside in a DLL can be freely used by any application. However, it is important for each application to explicitly request each resource object it needs. For example, if an application uses a menu resource called MainMenu in a library named MENULIB.DLL, it would have to contain code like the following:

HANDLE hLibrary;

HMENU hMenu;

hLibrary = LoadLibrary ("MENULIB.DLL");

hMenu = LoadMenu (hLibrary, “MainMenu”);