View Full Version : Bug writing REG_SZ values to the Registry

Frank Freund
12-04-2001, 12:37 PM
I use ISX 3.04 and tried to add REG_SZ values to some of my keys. All works fine until the value-string begins with "#".
These entries produce a "Value XX could not be written for Key YY..." error during installation. I have full access to the registry and importing the according .reg-files works without problem.
As I know, REG_SZ stands for Registry-String-zero, a zero ended string. I don't see a reason why the contents of a STRING should be of interest - and also the Microsoft registry documentation and the API documentation of "RegSetValueEx" don't talk of any limitations.

Scanning the forum didn't helped too, so before wasting time searching a workaround I would be pleased receiving a reply.

Thanks in advance

12-05-2001, 11:21 AM
This actually IS a violation of the Registry as far as the Windows Installer is concerned. If you validate your setup (using the Microsoft Logo Validation), Windows Installer flags a key with a value of # as invalid. That's why you get the runtime error when writing the registry key.

As a workaround, you could try running a reg file through a Custom Action.

Frank Freund
12-05-2001, 02:08 PM
first thanks for your reply! Second the bad news: I still think of a bug - but I'm not sure we are talking of the same thing. Let's explain it more detailed:
I have a registry key "HKLM\SOFTWARE\MyCompany\MyProgram\Setting1\". This key contains a REG_SZ-value named "HeaderFlag" (Value-name) with content "#AB00AA" (value).
As I know this is not against any rules. The only special case is an beginning-# as key-name (not value, as I try), which is used as file-key but not invalid. (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/tref_0xgo.asp )
Doing additional testing I realized that not all of my values are producing errors, some of them are created - but as DWord - ??. As I can see, this happens for all values which could be interpreted in octal-format and match the DWord size - for example "#012AAA" seems to be evaluated as "#012"octal and stored as DWord.
Maybe this helps us both...

Again, thanks in advance


12-05-2001, 05:00 PM
Launch the Msi Help (from Express help menu) and look at "Registry Table" from the Index. The way the Windows Installer distinguishes between a DWORD and a regular string is by adding a # in front of the value. Windows Installer also ONLY allows numeric (Hex numeric which includes A-F as well) values for DWORDS (obviously). So when it sees a # mark in front of a string value, it causes an error (if it contains any letters other than A-F).

Does that make more sense?

Frank Freund
12-06-2001, 10:45 AM
Hello again,

thanks, that helped(*) - NO BUG ;-). I have to add a second leading "#" to my values, than it works. Even I don't know why it generated errors (not just 'converting' to DWord without error), because all values I use are valid Hex-values for DWord range (my max: #FFFFFF) - but I think we should let this aside here and now...
A conclusion? - Would anything argue against a suggestion for improvement which would be to warn if you take REG_SZ values to your installation registry beginning with #, or better just automatically add a second #. By this way you would assure, that the taken REG_SZ value will be written from your setup using the original type and content - and that's what the Registry-Drag&Drop feature gives the impression of.

OK enough for now - thanks for your assistance again

(*) MSI-documentation:
If the value begins with two or more consecutive number signs (#), the value is interpreted and stored as a string, ignoring the first #.

12-07-2001, 12:58 PM
That is a good point. I submited Work Order 1-75HS0 to address this issue. So entering double # actually works without runtime errors?! That's news to me :)

Thanks for the feedback.