Resource Compiler (RC)

Command-line tool for compiling Windows resources

Resource Compiler (RC.EXE)

The Resource Compiler (RC) is a command-line tool that reads resource script files (.rc) and converts them into binary resource files (.res). These binary files can then be linked into an executable program or dynamic-link library (DLL) by the linker.

Purpose

RC is used to compile resources such as:

Syntax

The basic syntax for RC is:

rc [options] /fo output_file resource_file(s)

Common Options

Here are some of the most commonly used options for the RC tool:

Example Usage

Compiling a simple resource script:

rc /fo MyResources.res /i "c:\myproject\resources" MyProject.rc

This command compiles MyProject.rc, looks for include files in c:\myproject\resources, and outputs the compiled resources to MyResources.res.

Defining a macro during compilation:

rc /d DEBUG_MODE=1 /fo App.res App.rc

Resource Script (.rc) Files

Resource scripts are text files that describe the resources to be included in an application. They use a C-like syntax and can include directives to embed or reference resource files and define resource types.

Common Resource Types in .rc files:

Example of a simple .rc file snippet:


#include <windows.h>

// Icon resource
MAINICON ICON "appicon.ico"

// String table
STRINGTABLE
BEGIN
    IDS_APPNAME "My Wonderful Application"
    IDS_ABOUTBOX "About My Wonderful Application"
END

// Dialog box definition
ABOUT_DIALOG DIALOGEX 0, 0, 200, 100
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "MS Sans Serif"
{
    DEFPUSHBUTTON "OK", IDOK, 140, 80, 50, 14
    LTEXT "My Wonderful Application v1.0", IDC_STATIC_VERSION, 5, 5, 190, 20
}
            
The Resource Compiler (RC) is an integral part of the Windows development toolchain. It ensures that application resources are correctly compiled and embedded, making your applications visually appealing and functional. Always refer to the latest Windows SDK documentation for the most up-to-date information on RC options and syntax.