Share via


Create a Resource-Only DLL

OverviewHow Do IFAQDetailsSample

A resource-only DLL is a DLL that contains nothing but resources, such as icons, bitmaps, strings, and dialog boxes. Using a resource-only DLL is a good way to share the same set of resources among multiple programs.

To create a resource-only DLL, you create a new Win32 DLL (non-MFC) project and add your resources to the project.

  • Click New on the File menu and click the Projects tab. Choose Win32 Dynamic-Link Library as your target type.

  • Create a new resource script that contains the resources (such as a string or a menu) for the DLL and save the .RC file.

  • On the Project menu, select Add To Project then click Files. Use the Insert Files into Project dialog box to insert the new .RC file into the project.

  • On the Project Menu, select Settings. Select the Link tab of the Project Settings dialog, then in the Project Options box, add the /NOENTRY option. /NOENTRY prevents the linker from linking a reference to _main into the DLL; this option is required to create a resource-only DLL.

  • Build the DLL.

The application that uses the resource-only DLL should call LoadLibrary to explicitly link to the DLL. To access the resources, call the generic functions FindResource and LoadResource, which work on any kind of resource, or call one of the following resource-specific functions:

  • FormatMessage

  • LoadAccelerators

  • LoadBitmap

  • LoadCursor

  • LoadIcon

  • LoadMenu

  • LoadString

The application should call FreeLibrary when it is finished using the resources.

What do you want to know more about?