I am using a VC++ 2005 express, which does not have a resource editor. Therefore, I want to know if there's a way to use resources manually? Do I really have to make an .rc files to work with resources? I mean, can't I just import it like how fstream C++ does?
-
The reason you are struggling with the answers is that the question is unclear. Add more details to get better answers. – David Heffernan Jun 14 '11 at 14:28
5 Answers
There are several free resource editors available:
to name but two. For a resource compiler, there is the minimalistic GNU windres.
Couple of options:
- You could download the full Windows SDK, which is free and contains the official C and C++ compilers, as well as the resource compilers.
- If you are a university student, you can download a full version of Visual Studio from MSDNAA.
- If you are a student where MSDNAA is not available, you can still get the full copy from DreanSpark.
- You could purchase the full version of Visual Studio -- I'm assuming this is probably cost prohibitive.
Assuming you go with the Windows SDK route, you write a resource script and pass it to the rc tool.
(Not sure why you're still using 2005 Express though given that 2010 Express is out...)

- 104,103
- 58
- 317
- 552
If you want to do it the hard way, the Windows API provides functions for both reading and writing resources. Have a look at UpdateResource
.

- 277,958
- 43
- 419
- 720
-
The problem is how do I load them externally? Update function only updates resource files inside the module provides that we have a handle to a resource file. How do I create that handle out of file url? – biloon Jun 14 '11 at 13:15
-
@biloon: What kind of resource? If you don't want to embed your content into the application, you usually don't use resources at all, but a collection of loose files. In any case, you get the handle from `BeginUpdateResource`, and you need a local filename, not a URL. – Ben Voigt Jun 14 '11 at 13:17
-
Ok, I kind of get what you mean, but please correct me if my understanding is wrong. The resource files are internal data files and stay within the executable or library. Therefore, during the compile time, I must somehow load it into the executable. However, I do not know how to load them, because UpdateResource requires me to provide it a pointer to the resource file, and I don't know how to obtain that. – biloon Jun 14 '11 at 13:27
A full answer to this question depends on the type of resources you are trying to create. One option for windows and dialog boxes is to ignore resources completely and create what you need with RegisterClassEx, CreateWindow, SetWindowLongPtr and a couple of other functions.
Sometimes this route feels easier than using a resource file if you are creating resizable content.

- 6,761
- 1
- 26
- 35
-
Resizable content needn't be hard if you have an existing framework to handle it: http://stackoverflow.com/questions/138040/how-to-create-a-resizable-cdialog-in-mfc/5739620#5739620 – Mark Ransom Jun 14 '11 at 15:34