views:

657

answers:

2

**C Newbie Alert** How does one set the "Description" property of an executable? By this I mean the value displayed when you right-click an executable in Windows Explorer and it shows "Description:" with what seems to be just the name of the executable without the file extension.

I'm running GCC 3.4.5 (mingw-vista special r3) on Windows XP.

I have googled the heck out of this to no avail, but I have a feeling I might have to use a resource file with windres... am I on the right track at least?

I actually have been setting a custom name with -o, but I actually want a different one altogether.

+4  A: 

That information is taken from a Version Info resource. Windows executables can contain resource files embedded in them. Normally, with Microsoft Visual Studio, you create a resource script (.rc file), and the Visual Studio resource compiler will compile it into the executable for you. VS also contains a nice visual resource editor for editing the various types of resources (string tables, icons, bitmaps, cursors, menus, dialog boxes, version info, etc.).

With GCC, you'll have to create the resource script yourself. See MSDN for more info on the VERSIONINFO resource type. Once you've created a valid resource script, you can use windres to compile it into an object file (.o). This page has a good example of how to do that. Finally, once you have an object file, you just link it in with the rest of your object files as usual.

Adam Rosenfield
Just what I was looking for, thanks.
Wayne Koorts
+5  A: 

Yes, you need a resource file.

  1. For info about writing your own .rc resource file (including your FileDescription field), see: MSDN: VERSIONINFO Resource

  2. To link a resource file using gcc, see: "Setting icons [or any resource for Windows programs with gcc":

The Windows versions of gcc (MinGW, Cygwin) come with a tool called "windres". This will compile resource files into object files for you to include at the linking stage. As a simple example, to compile the file 'chocolate-doom-res.rc':

windres chocolate-doom-res.rc chocolate-doom-res.o

This gives you a '.o' that you can conveniently drop into your build, eg.

gcc other.o files.o etc.o chocolate-doom-res.o -o chocolate-doom.exe
cpeterso
Thanks cpeterso, this answer does the trick also, but unfortunately Adam R's one came up first so I have to give that one as accepted. Have upvoted yours though.
Wayne Koorts