Formatted Fields & BitFlags

Formatted Fields

When tables are directly edited within an MSI, variables may be used to ensure that the database remains dynamic.  These formatted fields are nearly always enclosed in square brackets ([ ])

Formatted fields are often used when dealing with directory listings.   The table below is an example of a standard directory table.

 

The “Directory” entry within the table must be unique and can be used to reference that absolute directory from anywhere else in the MSI.  Sometimes, when dealing with legacy applications, we need to identify the full path to a directory. 

[#LaunchPhotoshop] will be automatically resolved to the full path of the directory

[!LaunchPhotoshop] will be automatically resolved  to the full short-path (8x3 notation) of the directory

BitFlags

A number of columns within a Windows Installer database will contain numeric values that are “attributes” of how something will behave.  I used to refer to these values as property values before I was given a major dressing down by a geek friend as to the difference between an object property and what is correctly called a bitflag. 

 

The illustration above shows the component table.  In the illustration all of the components have bitflags set of the numeric 24.

A bitflag is a binary register where every “bit” represents a separate switch.  Just like a light switch, every character can either be on or off and each switch in the series has a different meaning.

With the example above, we know that the bitflag value for attributes of the components we can see is 24.

 

When the decimal value of “24” is converted to a Binary we end up with the value of 11000.

 

Using the light switch as a concept, three switches are off (0 value) while two are on (1 value).  Note that binary values work from right to left… our first switch is at the right furthermost position.

 

To interpret what our bitflag means we can consult MSDN where a table is displayed for the different binary flags.

http://msdn.microsoft.com/en-us/library/aa368007(v=vs.85).asp

 

Binary Representations

 

0x01

00000001

1

0x02

00000010

2

0x04

00000100

4

0x08

00001000

8

0x10

00010000

16

0x20

00100000

32

0x40

01000000

64

0x80

10000000

128

 

The table shows Hexadecimal, Binary and Decimal representations of the same number.  Our Bitflag values are binary representations so we are most interested in the middle column. 

If we compare the bitflag value of 24 for the attribute of the component table we will see two particular switches are on.

 

0x01

00000001

1

0x02

00000010

2

0x04

00000100

4

0x08

00001000

8

0x10

00010000

16

0x20

00100000

32

0x40

01000000

64

0x80

10000000

128

 

11000

26

 

We can compare the bitflag values that make up our numeric attribute of 26 directly with Microsoft’s published information to discover:

msidbComponentAttributesSharedDllRefCount

8

0x0008

If this bit is set, the installer increments the reference count in the shared DLL registry of the component's key file.

msidbComponentAttributesPermanent

16

0x0010

If this bit is set, the installer does not remove the component during an uninstall.

 

A complete list of all bitflag representations for all MSI tables is available online.