Thread: How to Create Resource DLL

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    10

    How to Create Resource DLL

    Hellow;

    How to create the Resource DLL, for example, load from program ICON, Bitmap, StringTable, etc.

    Using Dev-C++ compiler version 4.9.9.0, SO XP Professional. And how calling from the program?????

    Bye

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Create the typlical win32 program with:

    Code:
    #define WIN32_LEAN_AND_MEAN
    #include <windows.h>
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    {
        MessageBox( NULL,
                    "This program contains image and sound resources.\nPlease run WarkExec.exe to view resources.",
                    "WarkData",
                    MB_OK | MB_ICONSTOP );
        return 0;
    }
    Or something like that.

    Then just put your resources in your RC file.

    And to get the resources from somthing you need have the instance, and to do that:

    Code:
    HINSTANCE hRc = LoadLibrary("WarkData.dll");
    Simple as that.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    10
    Hello:

    Thanks very much Cool-August.


    I to find in the forum, following links, hot to create DLL Resource:

    http://msdn.microsoft.com/library/de...ml/ch21-02.asp

    Good-Bye.....

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    10
    Hellow:

    Problem, Not load the icon from recursos.dll.

    Code:
    static HWND lblIcon;
    /* Load DLL */
    static HINSTANCE libreria;
    Code:
    case WM_CREATE:
                // Load recursos.dll
                if ((libreria = LoadLibrary (TEXT ("recursos.dll"))) == NULL)
              {
                   MessageBox (hwnd, TEXT ("No se puede cargar = recursos.dll."),
                               "Error dll", 0) ;
                   return -1 ;
              }
    :
    :
    lblIcon = CreateWindowEx(
                            0,"static","",WS_CHILD|WS_VISIBLE|SS_ICON|WS_BORDER,250,35,30,30,hwnd,
                            (HMENU)0,inst,NULL);
                SendMessage(lblIcon,WM_SETICON,ICON_SMALL,
                            (LPARAM)(HICON)LoadIcon(libreria,MAKEINTRESOURCE(1)));
    The recursos.dll file :

    File dllmain.cpp :

    Code:
    #include <windows.h>
    //
    BOOL APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                           DWORD reason        /* Reason this function is being called. */ ,
                           LPVOID reserved     /* Not used. */ )
    {
        /* Returns TRUE on success, FALSE on failure */
        return TRUE;
    }
    File rcDLL.rc :

    Code:
    #include <windows.h>
    //#include "dll.h"
    /* ---------- ICONO ------------- */
    /*-- Number     TipResource     Details --*/
    1       ICON DISCARDABLE      "rc/logo.ico"
    /*--------- Version DLL -------------------*/
    100 VERSIONINFO
    FILEVERSION 1,0,0,0
    PRODUCTVERSION 1,0,0,0
    FILEOS 0x4
    FILETYPE 0x0
    {
    BLOCK "StringFileInfo"
    {
    	BLOCK "000004E4"
    	{
    		VALUE "CompanyName", "Consultor Forestal"
    		VALUE "FileDescription", "Rsource DLL"
    		VALUE "InternalName", "recursos.dll"
    		VALUE "LegalTrademarks", "Consultor"
    		VALUE "OriginalFilename", "recursos.dll"
    		VALUE "ProductName", "Procesos de Aserrio"
    		VALUE "FileVersion", "1,1,0,0"
    		VALUE "ProductVersion", "1,1,0,0"
    		VALUE "PrivateBuild", "Creado por Alejandro Ramírez en Dev-C++ v.4.9.9.0"
    	}
    }
    Good.

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Send a STM_SETIMAGE message to associate an icon with a static control with the SS_ICON style and not WM_SETICON as you have done.

    You should also consider breaking your code up into smaller individual statements, at least while you are debugging, so that you can test the return values of api functions like LoadIcon (or LoadImage) and use GetLastError to give you information about problems as they arise.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Create a DLL
    By cosmo1996 in forum C Programming
    Replies: 0
    Last Post: 08-27-2007, 09:29 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Calling a DLL
    By jamez05 in forum C++ Programming
    Replies: 1
    Last Post: 01-05-2006, 11:13 AM
  4. Replies: 1
    Last Post: 09-18-2005, 09:06 PM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM