Type Flag
Syntax {$SetPEFlags <integer expression>}
{$SetPEOptFlags <integer expression>}
Scope Local
Microsoft relies on PE (portable
executable) header flags to allow an application to indicate compatiblity with
OS services or request advanced OS services. These directives provide powerful
options for tuning your applications on high-end NT systems.
Warning: There is no error checking or masking of bit values specified by
these directives. If you set the wrong combination of bits, you could corrupt
your executable file.
These directives allow you to set
flag bits in the PE file header Characteristics field and PE file optional
header DLLCharacteristics field, respectively. Most of the Characteristics
flags, set using $SetPEFlags, are specifically for object files and libraries.
DLLCharacteristics, set using $SetPEOptFlags, are flags that describe when to
call a DLL's entry point.
The <integer expression> in
these directives can include Pascal constant identifiers, such as the
IMAGE_FILE_xxxx constants defined in Windows.pas. Multiple constants should be
OR'd together.
You can include these directives
in source code multiple times. The flag values specified by multiple directives
are strictly cumulative: if the first occurrence of the directive sets $03 and
the second occurrence sets $10, the value written to the executable file at
link time will be $13 (plus whatever bits the linker normally sets in the PE
flag fields).
These directives only affect the output file if included in source code prior to linking. This means you should place these directives in a .dpr or .dpk file, not in a regular unit. Like the exe description directive, it's not an error to place these directives in unit source code, but these directives in unit source will not affect the output file (exe or dll) unless the unit source is recompiled at the time the output file is linked.