Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I access User Interface CustomerInformation of a custom Installer Setup through code?

Status
Not open for further replies.

WomanPro

Programmer
Nov 1, 2012
180
0
0
GR
I have created a setup project for my application inside the solution that includes myapplication project.
This setup has a specificity. I want to install a trial version of the product and a licenced.
So I did the following:
In the User Inteface of the setup project I added a dialog with two radio buttons under Install Start Welcome.
The radio buttons are FreeTrial and Licenced.
I have created an Installer Class named MyInstaller inside my project in which I override the Install method.

Code:
Imports System.ComponentModel
Imports System.Configuration.Install

Public Class MyInstaller
    Public Class TypeOfSetup
        Public mFreeTrialFlg As Boolean
        Public mLicencedFlg As Boolean
        Public Property FreeTrialFlg() As Boolean
            Get
                Return mFreeTrialFlg
            End Get
            Set(ByVal value As Boolean)
                mFreeTrialFlg = value
            End Set
        End Property
        Public Property LicencedFlg() As Boolean
            Get
                Return mLicencedFlg
            End Get
            Set(ByVal value As Boolean)
                mLicencedFlg = value
            End Set
        End Property
        Public Sub New()
            mLicencedFlg = False
            mFreeTrialFlg = False
        End Sub
    End Class
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Public Overrides Sub Install(stateSaver As IDictionary)
        MyBase.Install(stateSaver)

        My.Settings.FreeTrialStr = Context.Parameters("FREETRIAL")
        My.Settings.LicencedStr = Context.Parameters("LICENCED")
    End Sub
End Class
I store to the application settings some variables about the expiration of trial and the kind of version that is being installed in the machine.
And my main form source code looks like that. That's a simple example of one day trial version that runs successfully with the addition of a simple assembly.

Code:
Public Class Form1
    Public TrialTime As DateTime
    Public Version As New MyInstaller.TypeOfSetup
    Public MyInst As New MyInstaller
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        
        If My.Settings.FreeTrialStr <> " " Then
            Version.FreeTrialFlg = True
            Version.LicencedFlg = False
        ElseIf My.Settings.LicencedStr <> " " Then
            Version.LicencedFlg = True
            Version.FreeTrialFlg = False
        End If

        If Version.FreeTrialFlg Then
            Trial()
        Else

        End If
    End Sub
    Public Sub Trial()
        My.Settings.Checked = False
        If Not My.Settings.Checked Then
            My.Settings.TrialTime = DateTime.Now  'TrialTime
            My.Settings.Checked = True
            My.Settings.ActivatedTrial = True
            My.Settings.LastDateUsed = DateTime.Now
            My.Settings.Expired = False
            MessageBox.Show("First Run...")
        Else
            If (My.Settings.TrialTime.Add(New TimeSpan(1, 0, 0, 0)) > DateTime.Now) And (My.Settings.LastDateUsed > DateTime.Now = False) And
                My.Settings.Expired = False Then
                My.Settings.ActivatedTrial = True
                MessageBox.Show("Trial Active...")
            Else
                If (DateTime.Now <= My.Settings.LastDateUsed Or My.Settings.TrialTime <= DateTime.Now Or My.Settings.Expired) Then
                    MessageBox.Show("Trial Expired...")
                    My.Settings.ActivatedTrial = False
                    My.Settings.Expired = True
                    Me.Close()
                End If
            End If
        End If
    End Sub
End Class
As you will see in jpg I attached, I have added a Customer Information Dialog too in the User Interface of the installer setup project with the red underline.
How can I access the Customer Information through source code in order to be visible only when the user chooses for the radio buttons the licenced version of the product so that to develop that part too?
I was thinking to do something like that in order to avoid anauthorized users but I don't know if all users would have the same licence key as in the youtube video. However, it's the first time I create a custom setup project and I have no idea how to do it, I would appreciate any guidance and suggestions please? Any help will be much appreciated. Thank you so much in advanced.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top