Creating a resource-only DLL

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. It's also a good way to provide an application with resources localized for multiple languages. For more information, see Localized resources in MFC applications: Satellite DLLs.

Create a resource-only DLL

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

  1. Select Win32 Project in the New Project dialog box. Enter the project and solution names, and choose OK.

  2. In the Win32 Application Wizard, select Application Settings. Choose an Application type of DLL. Under Additional options, select Empty project. Choose Finish to create your project.

  3. Create a new resource script that contains the resources for the DLL (such as a string or a menu). Save the .rc file.

  4. On the Project menu, select Add Existing Item, and then insert the new .rc file into the project.

  5. Specify the /NOENTRY linker option. /NOENTRY prevents the linker from linking a reference to _main into the DLL; this option is required to create a resource-only DLL.

  6. Build the DLL.

  1. Select Windows Desktop Wizard in the New Project dialog box and choose Next. In the Configure your new project page, enter the project and solution names, and choose Create.

  2. In the Windows Desktop Project dialog box, select an Application type of Dynamic Link Library. Under Additional options, select Empty project. Choose OK to create your project.

  3. Create a new resource script that contains the resources for the DLL (such as a string or a menu). Save the .rc file.

  4. On the Project menu, select Add Existing Item, and then insert the new .rc file into the project.

  5. Specify the /NOENTRY linker option. /NOENTRY prevents the linker from linking a reference to _main into the DLL; this option is required to create a resource-only DLL.

  6. Build the DLL.

Use a resource-only DLL

The application that uses the resource-only DLL should call LoadLibraryEx or a related function 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's finished using the resources.

See also

Working with Resource Files
Create C/C++ DLLs in Visual Studio