简体   繁体   English

Visual Studio的安装项目

[英]Setup Project for Visual Studio

If I right click the setup project and go to "User Interface". 如果我右键单击安装项目,然后转到“用户界面”。

We will see "Start". 我们将看到“开始”。 if I right click and choose "Add Dialog" 如果我右键单击并选择“添加对话框”

At Add Dialog, Choose "Customer Information" 在“添加”对话框中,选择“客户信息”

If I go to the properties of "Customer Information", there is a tab called "Serial Number Template". 如果我转到“客户信息”的属性,则有一个名为“序列号模板”的选项卡。

It is to check whether the correct number is typed in when the program is installed. 安装程序时检查输入的数字是否正确。

I m not sure how does it work. 我不确定如何运作。

Anyone? 任何人?

Documentation for that particular setting is at http://msdn.microsoft.com/en-us/library/w3xwh311.aspx 该特定设置的文档位于http://msdn.microsoft.com/zh-cn/library/w3xwh311.aspx

A (somewhat old) knowledge base article on validating serial numbers is at http://support.microsoft.com/kb/253683/en-us 一篇有关验证序列号的(较旧的)知识库文章位于http://support.microsoft.com/kb/253683/en-us

I don't really know what your question is. 我真的不知道你的问题是什么。 Yes, the "Serial Number Template" allows you to add a form to your setup program that verifies whether the user has entered a valid serial number and if the installation is authorized to proceed. 是的,“序列号模板”使您可以向安装程序中添加一个表单,以验证用户是否输入了有效的序列号以及安装是否被授权进行。

It provides what is essentially a masked edit control that allows you to define the format of serial numbers that your application accepts. 它提供了实质上是隐藏的编辑控件,使您可以定义应用程序接受的序列号格式。 You specify a template that defines the pattern of characters required for the serial number to be considered valid. 您指定一个模板,该模板定义序列号被视为有效所需的字符模式。 The template is used to arrange these text boxes on the dialog as well as for validation. 该模板用于在对话框上排列这些文本框以及进行验证。 (See the documentation on MSDN.) (请参阅MSDN上的文档 。)

The following characters are accepted as part of the template, and any other characters that you enter are treated as literals: 下列字符被接受为模板的一部分,并且您输入的任何其他字符均被视为文字:

# Requires a digit that will not be included in the validation algorithm. 需要一个不会包含在验证算法中的数字。

% Requires a digit that will be included in the validation algorithm. 要求数字将包含在验证算法中。

? Requires an alphanumeric character that will not be included in the validation algorithm. 需要一个字母数字字符,该字符不会包含在验证算法中。

^ Requires an uppercase or lowercase character. ^需要大写或小写字符。 Numeric digits are not valid here. 此处的数字无效。

< Any characters to the left of this character will not be visible in the dialog box. <该字符左侧的任何字符在对话框中都不可见。

> Any characters to the right of this character will not be visible in the dialog box. >该字符右边的任何字符将在对话框中不可见。 Required as a terminator if the < character is used. 如果使用<字符,则必须作为终止符。

As shown above, specifying digits with a % in the template indicates that they should be checked against the Windows Installer validation algorithm. 如上所示,在模板中指定带有%数字表示应对照Windows Installer验证算法进行检查。 This essentially adds up all of the checked digits and divides them by seven. 这实际上将所有校验位相加并将它们除以7。 If the remainder is zero, the number is valid; 如果余数为零,则该数字有效;否则为零。 otherwise, it is not. 否则,事实并非如此。 This is not a particularly strong security measure, as the algorithm is quite well-known, but it provides an easy way to reduce the chances of a transcription error when the user types in a serial number. 这不是一种特别强大的安全措施,因为该算法是众所周知的,但是它提供了一种简单的方法来减少用户键入序列号时出现抄写错误的机会。

For example, if you used the template <###-%%%%%%% - FOO - %%%> , you would get this dialog: 例如,如果使用模板<###-%%%%%%% - FOO - %%%> ,则会显示以下对话框: 样本安装程序对话框,验证序列号
(shamelessly stolen from Mastering Visual Studio .NET by Griffiths, et. al.) (由Griffiths等人从Mastering Visual Studio .NET中无耻地窃取了)

Above answers did not explain how to customize the serial number verification, after all, it is meaningless if you just enter the serial number but does not validate it. 上面的答案没有说明如何自定义序列号验证,毕竟,仅输入序列号但不验证序列号是没有意义的。

We must add the following text at CustomActionData property of Custom Action: 我们必须在“自定义操作”的CustomActionData属性中添加以下文本:

/ PIDKEY = [PIDKEY] / PIDKEY = [PIDKEY]

You can then use below code to obtain and verify the serial number of input in Custom Action Project: 然后,您可以使用以下代码获取并验证Custom Action Project中输入的序列号:

string serial = Context.Parameters ["PIDKEY"] 字符串序列= Context.Parameters [“ PIDKEY”]

Related links: 相关链接:

http://msdn.microsoft.com/en-US/library/vstudio/8z9h65a3(v=vs.100).aspx http://msdn.microsoft.com/zh-CN/library/vstudio/8z9h65a3(v=vs.100).aspx

http://msdn.microsoft.com/en-US/library/vstudio/aa370826(v=vs.100).aspx http://msdn.microsoft.com/zh-CN/library/vstudio/aa370826(v=vs.100).aspx

How to build a Custom Action Project: 如何构建自定义操作项目:

http://msdn.microsoft.com/en-US/library/vstudio/d9k65z2d(v=vs.100).aspx http://msdn.microsoft.com/zh-CN/library/vstudio/d9k65z2d(v=vs.100).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM