Deciphering the MSI Directory table, part 4
I am seriously fried. This week starts with a ramp up to an executive review and ends with a major deadline. Nothing like a double header to really get your blood flowing. Anyway, I'm just whinging away right now to lower any expectations you might have for this blog entry. I'm going to keep it simple.
I my last blog entry we discussed some common conventions found in the MSI tables. Go back and take a look at convention #5 about foreign keys. I want to talk about how the Directory table uses the foreign key column Directory_Parent to create the directory hierarchy (I promised this would simple). First, let's get an example Directory table that has a few entries in it.
Directory Directory_Parent DefaultDir s72 S72 l255 Directory Directory TARGETDIR SourceDir FirstFolder TARGETDIR One SecondFolder FirstFolder Two ThirdFolder SecondFolder Three SecondThirdFolder SecondFolder ThreeToo
Now let's see how the Windows Installer would interpret that data. Remember the first column simply provides a unique identifier for each directory entry. The second column is a foreign key column and we know that the underscore in the column name means it heavily suggests that it refers to the first column of the Directory table. Thus by process of elimination the last column must be the actual name of the directory. If this is right, we'd have the following directories defined.
TARGETDIR = SourceDir\ FirstFolder = SourceDir\One\ SecondFolder = SourceDir\One\Two\ ThirdFolder = SourceDir\One\Two\Three\ SecondThirdFolder = SourceDir\One\Two\ThreeToo\
If we assume that TARGETDIR and SourceDir are something special and ignore them for the moment then the rest of the directory layout hopefully make a lot of sense. The FirstFolder directory is "One" and has only one child directory, "Two". The SecondFolder directory is "Two" and has two directories in it "Three" and "ThreeToo". "Three" and "ThreeToo" are referred to by the directory identifiers ThirdFolder and SecondThirdFolder respectively.
I'm sure by this point you're thinking, "This stuff is all obvious so get to the good part!" Well, now that I've introduced the necessary basics I think we can dig into some of the more interesting facets of the Directory table.
[to be continued]
Update: I added backslashes to the end of the resolved directories because (as mentioned in the comments) this is the way the Windows Installer sees directories. I was going to cover this fact in a later blog entry but it is wise to be consistent from the beginning.