Pure resource DLL is a DLL that only contains resources (tags, bitmaps, strings, and dialogs. When pure resource DLL is used Program A good way to share the same group of resources between them. It is also a good way to provide its resources for localized applications in multiple languages. To create a pure resource DLL, create a new Win32 DLL (non-MFC) project and add the resource to this project.
In the "Create Project" dialog box, select "Win32 project" and specify the DLL project type in the "Win32 Project Wizard.
Create a new resource script that contains resources (such as strings or menus) for the DLL and save the. RC file. If the. RC file contains a bitmap, open it in notepad, you can see the following section:
Dib_bkgd_hf bitmap "bkgd _ **. BMP"
Dib_bkgd_gt bitmap "bkgd _ ***. BMP"
Dib_bkgd_bf bitmap "bkgd _ *****. BMP"
These are the declarations for bitmap. Just add the corresponding bitmap to this field.
In"Project"Click Add existing item on the menu, and insert the new. RC file in the project.
Specify/NoentryLinker Options. /Noentry prevents the linker from linking _ main references to the DLL. This option is required to create a pure resource DLL.
Generate DLL.
Applications that use pure resource dll should callLoadlibraryComeExplicitly link to DLL. To access resources, call the general functionFindresourceAndLoadresourceThese two functions are valid for any type of resources or call one of the following resource-specific functions:
Formatmessage
Loadaccelerators
Loadbitmap
Loadcursor
Loadicon
Loadmenu
Loadstring
After resources are used, the application should callFreelibrary.
The following section describes how to dynamically load and display BMP in a resource.
Hmodule = loadlibrary ("extenddll. dll ");
HDC m_hdcmem;
M_hdcmem = createcompatibledc (HDC );
Bitmap bm;
Rect;
Hbitmap = loadbitmap (hmodule, "dib_bkgd_hf"); // makeintresource (idb_bitmap1)
// Hbitmap = (hbitmap) LoadImage (hmodule, "dib_bkgd_hf", image_bitmap, 0, 0, lr_defaultsize );
GetObject (hbitmap, sizeof bitmap, & BM );
SelectObject (m_hdcmem, hbitmap );
Getclientrect (hwnd, & rect );
//: Setstretchbltmode (HDC, coloroncolor );
//: Stretchblt (HDC, rect. left, rect. top, rect. right, rect. bottom, m_hdcmem, 0, 0, BM. bmwidth, BM. bmheight, srccopy );
Bitblt (HDC, BM. bmwidth, BM. bmheight, m_hdcmem, srccopy );
Releasedc (hwnd, m_hdcmem );
Freelibrary (hmodule );