将Reg_SZ值转换为REG_EXPAND_SZ和REG_DWORD值 [英] Converting Reg_SZ values to REG_EXPAND_SZ and REG_DWORD values
问题描述
Hello Guys,
使用以下代码将值插入MSI数据库(注册表)
private void button2_Click(对象发件人,EventArgs e)
{
字符串 Name1 = lblDName.Name;
String Value1 = txtDName.Text;
字符串 Name2 = lblUnisntall.Name
字符串 Value2 = txtUninstall 。文本;
// 查询数据库
WindowsInstaller.View view = instDb.OpenView( INSERT INTO Registry(Name,Value)VALUES(' + Name1 + ',' + Value1 + < span class =code-string>'));
view.Execute( null );
}
此代码正常工作,但在 MSI数据库中插入值后。
创建了Value1和值 2 as REG_SZ( String )
但 符合我的要求,
Value1,应该是REG_EXPAND_SZ
值 2 ,应该是REG_DWORD
你能帮我吗在中将转换为我的代码,然后将插入 MSI数据库。
干杯,
也许你应该阅读文档 [ ^ ]在MSI的注册表中。
Quote:值
此列是可本地化的注册表值。该字段为格式化。 如果该值附加到以下前缀之一(即#%value),则按表中所述解释该值。请注意,每个前缀都以数字符号(#)开头。如果值以两个或多个连续数字符号(#)开头,则忽略第一个#并解释值并将其存储为字符串。
前缀
含义
#x该值被解释并存储为十六进制值(REG_BINARY)。
#%该值被解释并存储为可扩展字符串(REG_EXPAND_SZ)。
#该值被解释并存储为整数(REG_DWORD)。
Hello Guys,
Am using the below code to INSERT values into MSI Database (Registry table)
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,
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).
这篇关于将Reg_SZ值转换为REG_EXPAND_SZ和REG_DWORD值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!