Skip to main content
gamedev.net
🔒 Locked

Loading Resources From DLLs Help

Started by FWGaming Dec 7, 2005 at 10:35 PM 3 replies 600+ views
Original Post
FWGaming
FWGaming
Okay, I created a resource-only DLL and I am trying to make an application that can load an image from it, such as a bitmap or icon. Here is my DLL code:

#include "stdafx.h"

#ifdef _MANAGED
#pragma managed(push, off)
#endif

BOOL APIENTRY DllMain(HMODULE hModule,
    DWORD ul_reason_for_call, LPVOID lpReserved)
    {
    return TRUE;
    }

#ifdef _MANAGED
#pragma managed(pop)
#endif



Then Here is the Resource file include with it:

ICON_MAIN ICON "icon.ico"



This all compiles perfectly to a DLL. Then I can't seem to figure out how to load it into my project correctly. Here is the code I use to load the icon image:

const char* pFileName="resdll.dll";
HMODULE hinstdll = LoadLibrary(pFileName);
HICON myicon = LoadIcon(hinstdll,ICON_MAIN);
FreeLibrary(hinstdll);



The program compiles without error if I remove the LoadIcon line, so that is my problem I suppose. When I try to compile I get the error: "error C2065: 'ICON_MAIN' : undeclared identifier" How can I fix this? [Edited by - FWGaming on December 7, 2005 11:02:33 PM]
moeron
moeron
where do you define ICON_MAIN? Make sure its included in the file where your trying to call that LoadIcon line. Is it in your "stdafx.h" ?

[edit]
Ok I see you have it in your resource.h, but are you sure thats being included correctly?
[/edit]
moe.ron
FWGaming
FWGaming
Well, the way I included it is how I show here... So I am not sure if it is right or not, but can someone help plz.
SKREAMZ
SKREAMZ
you have to define ICON_MAIN in your program too not just you dll
Blaaaaa Blaaaa Blaa errrrr!!!! Bla?
FWGaming
FWGaming
Ok well now I get it to compile but the program doesn't successfully load the icon... why is this? i don't get any errors but I tried using it as the window's small icon and it doesn't display my icon, just some other default.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.