开发者

Setup Project for Visual Studio

开发者 https://www.devze.com 2023-01-26 01:38 出处:网络
If I right click the setup project and go to \"User Interface\". We will see \"Start\". if I right click and choose \"Add Dialog\"

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开发者_JAVA百科 in when the program is installed.

I m not sure how does it work.

Anyone?


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.)

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. This essentially adds up all of the checked digits and divides them by seven. 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:

Setup Project for Visual Studio


(shamelessly stolen from Mastering Visual Studio .NET by Griffiths, et. al.)


Documentation for that particular setting is at http://msdn.microsoft.com/en-us/library/w3xwh311.aspx

A (somewhat old) knowledge base article on validating serial numbers is at http://support.microsoft.com/kb/253683/en-us


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:

/ PIDKEY = [PIDKEY]

You can then use below code to obtain and verify the serial number of input in Custom Action Project:

string serial = Context.Parameters ["PIDKEY"]

Related links:

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

http://msdn.microsoft.com/en-US/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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号