简体   繁体   中英

In Visual Studio 2012, how can one link resource file(.rc) with c ++ dll

I have to build a c++ .dll, where I need to show a dialog box in some cases to interact with users. So I create a resource file (.rc), integrate corresponding code in the dll project to show the dialog and build the dll project with the resource file in VS2012.

Now the problem is when I load the dll in another test application and call one of the method from dll which uses the resource file to show dialogBox, this method returns

Error 0x715 is ERROR_RESOURCE_NAME_NOT_FOUND.**

The line inside the dll that returns the error is

DialogBox(HInstance, MAKEINTRESOURCE(IDD_INPUTDIALOG), NULL, NotifyUser);

It seems that my resource file (.rc) for DialogBox with id: IDD_INPUTDIALOG is not linked or added in the dll. so it can not find the dialog box resource.

Now if i add a resource file(.rc) in the test application with the same id as the resource file(.rc) in dll, the method call from dll uses the resource file(.rc) in test application , not the one in dll.

So is it the case that resource file is not liked or added in the dll?

Additional Info:

To build the dll with resource file, I use VS2012 and simply add the resource file in the project and build the project as dynamic link library (.dll).

Is it enough to add the resource file in dll, or do I have to set some other flags or linker option to link the resource file (.rc) with dll?

Thanks in advance.

Considering the comment which confirms HInstance==NULL , it means the call is really DialogBox(NULL, MAKEINTRESOURCE(IDD_INPUTDIALOG), NULL, NotifyUser); . This looks for a dialog box in the EXE file of the process. That is the default location. To tell Windows to look elsewhere, you need the correct DLL instance.

To figure out your own instance from inside your DLL, call GetModuleHandle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM