#RESOURCE metastatement

Purpose

Embed a PowerBASIC Resource (.PBR) file into the compiled EXE or DLL file.

Syntax

#RESOURCE "filespec"

Remarks

This metastatement is used to include a PowerBASIC resource file into your program or DLL. PowerBASIC resource files are created using the PBRES.EXE utility.

To create a .PBR file, you must first create a resource script (.RC) which contains resource commands. A typical resource file to specify an Icon consists of just one line of text:

ICON1 ICON MYICON.ICO

This line of text would be saved as a .RC file, and then compiled into a .RES file with a resource compiler, such as the 32-bit Microsoft resource compiler (RC.EXE). Then, the .RES file would be converted into a PowerBASIC resource (.PBR) with the PBRES.EXE.

Resource files can contain bitmaps, string data, custom binary data, version information, dialogs and a whole lot more. To create more complex resource files, a Resource Editor is highly recommended. PowerBASIC's PB/Win compiler includes a copy of the Microsoft Dialog Editor (DLGEDIT.EXE), and the Microsoft Resource Compiler (RC.EXE).

You can find examples of .RC files in the SAMPLES folder installed with PowerBASIC, and in the Resource Files chapter.

The PowerBASIC IDE can be used to compile a Resource Script (.RC file) into PowerBASIC resource file format (a .PBR file) without resorting to using command-line tools to compile resource files.

Restrictions

You cannot have more than one resource file in a module. If you need more than one, the usual way to accomplish this is to create a separate DLL for each additional resource file. PowerBASIC does not permit more than one #RESOURCE statement per module.

Note: If you are adding an icon resource to a Console mode application (for example, a GUI app that has been "altered" to appear as a console app), please note that Windows 95's "Windows Explorer" will not display icons of console applications in file lists. This behavior was corrected in Windows 98, and later editions of Windows.

PowerBASIC metastatements support Long File Names (LFNs).

See also

Resource Files

Example

#RESOURCE "HELLO.PBR"