Add resource to EXE

Started by Zlatko Vid, March 27, 2023, 10:34:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Zlatko Vid

Hi Charles
( and thanks Theo on new place!)

I found on PowerBasic forum something about $VERSIONINFO by Patrice Terrier
i don't kknow for this before
so there a way that we have something similar in OxygenBasic
I mean in  first place to add MANIFEST on that way
thanks :

QuoteFrom Bob Zale himself (to the formal Beta Team)

#RESOURCE metastatement <Improved>

Embed PowerBASIC Resource Data into a compiled application.

#RESOURCE FILE, ResID, "filespec.DLL"
#RESOURCE ICON, ResID, "filespec.ICO"
#RESOURCE STRING, ResID, "YourWideText"$$ [,LangID]
#RESOURCE TYPELIB, 1, "filespec.TLB"
#RESOURCE WAVE, ResID, "filespec.WAV"

#RESOURCE RES, "filespec.RES"
#RESOURCE PBR, "filespec.PBR"

This metastatement is used to include PowerBASIC Resource data into
your program or DLL. Resource data may consist of Bitmaps, Icons,
Strings, COM Type Libraries, Version Information, and more. You can
even embed custom binary data for your personal, specialized needs.

Resource data can be a very valuable tool. While you can certainly
load bitmaps and icons from separate files, wouldn't it be better to
just embed them in your application? When you need the bitmap, it's
always right there for your use! You don't have to deal with scads
of files. Now it's all at your fingertips.

The parameter ResID is a unique identifier which you create to
reference this item. It can be a number or an alphanumeric label.
If a number, it must be an integral value from 0 to 65535. If a
label, it must begin with a letter, and consist of letters and
numbers. Alphanumeric labels are not case sensitive. The filespec
parameter must always be expressed as a string literal which tells
the location of the resource data.

With most programming languages, creation and embedding of resource
data is a cumbersome process. First you create a resource script
(an .RC file) with a text editor. Then you save the .RC file. Now,
compile the .RC file with a resource compiler to get a .RES file.
Next, you convert it to a linkable file using Microsoft's CVTRES.EXE
or another converter program like PBRES.EXE. Finally, you link it
into your .EXE or .DLL with a compiler or linker program. What if
you find you need to make a tiny change? Do it all over again, from
the beginning. Even older versions of PowerBASIC suffered from this

Isn't there a better way? Yes, PowerBASIC now handles the entire
process in a single line of code. Need an an embedded bitmap?

#RESOURCE BITMAP, 123, "MyPicture.BMP"

PowerBASIC finds your bitmap in the file MyPicture.BMP and embeds
it in your executable. When you need to use it, you can reference
it by the ID you chose for it (123). The ID can be an integral
numeric value or a text name of your choice. So, to display the
bitmap on a graphic window, it's as simple as:

GRAPHIC RENDER "#123", (100,100)-(160,140)

String Resources
The String resource contains string data which is always created
and stored as Wide Unicode characters. It is retrieved at run-time
with the RESOURCE$ function. Due to the manner in which Windows
stores string resources in a string table, the ResID must be numeric.

The string data must be from 1 to 127 characters in length, and may
not contain any embedded nuls (CHR$(0)). The string data may be
specified as a quoted wide string literal ("MyText"$$), or as a
wide string literal expression. A string literal expression can be
constructed from combinations of wide string equates or wide quoted
string literals, the CHR$ function, SPACE$ function, and the STRING$
function when used with numeric parameters.

VersionInfo Resources
The VersionInfo resource contains information about the file, such
as its version number, its intended operating system, its original
file name, and much more. This resource is intended to be used with
the Version Information API functions, so that Windows Explorer, and
other programs, can display the relevant information about your EXE
or DLL. The VERSIONINFO resource cannot be embedded in a Static
Link Library (SLL).

The VersionInfo resource is unique in that it requires several
#RESOURCE metastatements which are interpreted as a complete block.
They must be placed consecutively in the correct sequence in order
be processed correctly.

1- The block begins with the VersionInfo metastatement which
marks the beginning of the version block.

#RESOURCE VersionInfo

2- Next, you may choose to add one or more of the numeric
version metastatements which embed numeric values.

#RESOURCE FileFlags FlagValue&
#RESOURCE FileVersion HiNum1&, LoNum1&, HiNum2&, LoNum2&
#RESOURCE ProductVersion HiNum1&, LoNum1&, HiNum2&, LoNum2&

3- Next, the mandatory StringInfo metastatement is added, to
identify the Language ID and CharSet to be used. Each of these
parameters must be passed as a 4-digit HEX value in a string
literal. The parameter must not contain the "&H" prefix used
with numeric hex numbers.

#RESOURCE StringInfo "LangID", "CharSet"

4- Finally, you will add one or more of the string version
metastatements, to provide extensive information about the file.
The first string literal parameter chooses one of the following
predefined names. The second string literal parameter adds your
personal choice of information about the file.

#RESOURCE Version$ "Comments", "Additional info"
#RESOURCE Version$ "CompanyName", "PowerBASIC Inc."
#RESOURCE Version$ "FileDescription", "Presented to users"
#RESOURCE Version$ "FileVersion", "Readable VerNum 1.02"
#RESOURCE Version$ "InternalName", "Private"
#RESOURCE Version$ "LegalCopyright", "Copyright 2010 PB Inc"
#RESOURCE Version$ "LegalTrademarks", "xx is a..."
#RESOURCE Version$ "OriginalFilename", "Original name w/o path"
#RESOURCE Version$ "PrivateBuild", "Private info"
#RESOURCE Version$ "ProductName", "Product distributed with"
#RESOURCE Version$ "ProductVersion", "Version distributed with"
#RESOURCE Version$ "SpecialBuild", "Special info"

FileFlags Flagvalue
%VS_FF_DEBUG File contains debugging information or is compiled
with debugging features enabled.

%VS_FF_PATCHED File has been modified and is not identical to the
original shipping file of the same version number.

%VS_FF_PRERELEASE File is a development version, not a commercially
released product.

%VS_FF_PRIVATEBUILD File was not built using standard release
procedures. If this value is given, you must
include a PrivateBuild string item.

%VS_FF_SPECIALBUILD File was built by the original company using
standard release procedures, but is a variation of
the standard file of the same version number. If
this value is given, uou must include a
SpecialBuild string item.

LangID (HEX values)
0401 Arabic 0415 Polish
0402 Bulgarian 0416 Portuguese (Brazil)
0403 Catalan 0417 Rhaeto-Romanic
0404 Traditional Chinese 0418 Romanian
0405 Czech 0419 Russian
0406 Danish 041A Croato-Serbian (Latin)
0407 German 041B Slovak
0408 Greek 041C Albanian
0409 U.S. English 041D Swedish
040A Castilian Spanish 041E Thai
040B Finnish 041F Turkish
040C French 0420 Urdu
040D Hebrew 0421 Bahasa
040E Hungarian 0804 Simplified Chinese
040F Icelandic 0807 Swiss German
0410 Italian 0809 U.K. English
0411 Japanese 080A Spanish (Mexico)
0412 Korean 080C Belgian French
0413 Dutch 0816 Portuguese (Portugal)
0414 Norwegian - Bokmal 081A Serbo-Croatian (Cyrillic)
0810 Swiss Italian 0C0C Canadian French
0813 Belgian Dutch 100C Swiss French
0814 Norwegian - Nynorsk

CharSet (HEX values)
0000 7-bit ASCII 04E3 Cyrillic
03A4 Japan (Shift JIS X-0208) 04E4 Multilingual
03B5 Korea (Shift KSC 5601) 04E5 Greek
03B6 Taiwan (Big5) 04E6 Turkish
04B0 Unicode 04E7 Hebrew
04E2 Latin-2 (Eastern Europe) 04E8 Arabic

RES/PBR Resources
The second group of syntax examples show how you can embed resources
which have been pre-compiled used a resource compiler. Standard
resource compilers output a binary resource with a .RES extension.
PowerBASIC will embed this resource just as it is given in the file.
This form will always be supported to support resource forms which
are typically not needed for most PowerBASIC programs, or which
usually require the use of a resource editor.

The final example, using a .PBR file, will only be supported for a
limited period of time. This is the form created by the PowerBASIC
PBRES utility in older versions of the compiler. It is recommended
that you change to the .RES version soon, as it is more efficient,
and needs less effort from the programmer. It should be noted that
prior versions of PowerBASIC allowed the descriptor "PBR" to be
omitted. While this option will be supported for a limited period
of time, we recommend that you always insert "PBR" for clarity.

See also
Patrice Terrier

Charles Pegge

Hi Aurel,

Direct resourcing is on my list, but my brain is short of space at present.

Zlatko Vid

OK Charles
Nothing to important ..i was come over this when i see similar thing in QB64
which looks like this :

$VERSIONINFO: Comments = This is my comment!