Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

Am using the below code to INSERT values into MSI Database (Registry table)

C#
private void button2_Click(object sender, EventArgs e)
        {            
            String Name1 = lblDName.Name;
            String Value1 = txtDName.Text;
            
            String Name2 = lblUnisntall.Name
            String Value2 = txtUninstall.Text;

            // query the database
            WindowsInstaller.View view = instDb.OpenView("INSERT INTO Registry (Name, Value) VALUES ('" + Name1 + "', '" + Value1 + "')");

            view.Execute(null);
        }

This code work properly, but after inserting values in MSI database. 
The Value1 and value 2 are created as REG_SZ (String)
but as per my requirement, 
Value1, should be REG_EXPAND_SZ 
Value 2, should be REG_DWORD 

Could you please help me in converting them in my code and then to insert into the MSI database.

Cheers,
Posted
Updated 23-Aug-14 4:59am
v3
Comments
[no name] 23-Aug-14 11:04am    
REG_DWORD is not a string. You need to make your string a Uint32.

1 solution

Maybe you should read the documentation[^] on the Registry table in an MSI.

Quote:
Value
This column is the localizable registry value. The field is Formatted. If the value is attached to one of the following prefixes (i.e. #%value) then the value is interpreted as described in the table. Note that each prefix begins with a number sign (#). If the value begins with two or more consecutive number signs (#), the first # is ignored and value is interpreted and stored as a string.


Prefix

Meaning

#x The value is interpreted and stored as a hexadecimal value (REG_BINARY).
#% The value is interpreted and stored as an expandable string (REG_EXPAND_SZ).
# The value is interpreted and stored as an integer (REG_DWORD).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900