home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmStartup
- BorderStyle = 3 'Fixed Dialog
- Caption = "Service"
- ClientHeight = 4650
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4185
- Icon = "frmStartup.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 4650
- ScaleWidth = 4185
- ShowInTaskbar = 0 'False
- StartUpPosition = 1 'CenterOwner
- Begin VB.Frame Frame2
- Caption = "Log On As:"
- Height = 2535
- Left = 120
- TabIndex = 6
- Top = 2040
- Width = 3975
- Begin VB.TextBox txtConfirmPassword
- Height = 285
- IMEMode = 3 'DISABLE
- Left = 1560
- PasswordChar = "*"
- TabIndex = 14
- Top = 2040
- Width = 2175
- End
- Begin VB.TextBox txtPassword
- Height = 285
- IMEMode = 3 'DISABLE
- Left = 1560
- PasswordChar = "*"
- TabIndex = 12
- Top = 1560
- Width = 2175
- End
- Begin VB.TextBox txtAccountName
- Height = 285
- Left = 1560
- TabIndex = 10
- Top = 1080
- Width = 2175
- End
- Begin VB.CheckBox chkInteract
- Caption = "A&llow Service to Interact with Desktop"
- Height = 195
- Left = 480
- TabIndex = 8
- Top = 720
- Width = 3135
- End
- Begin VB.OptionButton optThisAccount
- Caption = "&This Account:"
- Height = 255
- Left = 120
- TabIndex = 9
- Top = 1080
- Width = 1455
- End
- Begin VB.OptionButton optSystemAccount
- Caption = "&System Account"
- Height = 255
- Left = 120
- TabIndex = 7
- Top = 360
- Width = 1455
- End
- Begin VB.Label lblPassword2
- Caption = "Password:"
- Height = 255
- Left = 480
- TabIndex = 13
- Top = 2160
- Width = 975
- End
- Begin VB.Label lblConfirm
- Caption = "&Confirm"
- Height = 255
- Left = 480
- TabIndex = 17
- Top = 1920
- Width = 855
- End
- Begin VB.Label lblPassword
- Caption = "&Password:"
- Height = 255
- Left = 480
- TabIndex = 11
- Top = 1560
- Width = 855
- End
- End
- Begin VB.CommandButton cmdCancel
- Cancel = -1 'True
- Caption = "Cancel"
- Height = 375
- Left = 3000
- TabIndex = 16
- Top = 1080
- Width = 1095
- End
- Begin VB.CommandButton cmdOK
- Caption = "OK"
- Default = -1 'True
- Height = 375
- Left = 3000
- TabIndex = 15
- Top = 600
- Width = 1095
- End
- Begin VB.Frame Frame1
- Caption = "Startup Type"
- Height = 1335
- Left = 120
- TabIndex = 2
- Top = 480
- Width = 2655
- Begin VB.OptionButton optDisabled
- Caption = "&Disabled"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 960
- Width = 1695
- End
- Begin VB.OptionButton optManual
- Caption = "&Manual"
- Height = 255
- Left = 120
- TabIndex = 4
- Top = 600
- Width = 1695
- End
- Begin VB.OptionButton optAutomatic
- Caption = "&Automatic"
- Height = 255
- Left = 120
- TabIndex = 3
- Top = 240
- Width = 1695
- End
- End
- Begin VB.Label lblServiceName
- Caption = "Service Name"
- Height = 255
- Left = 1080
- TabIndex = 1
- Top = 120
- Width = 3495
- End
- Begin VB.Label Label1
- Caption = "Service:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 735
- End
- Attribute VB_Name = "frmStartup"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '****************************************************************************************************
- ' Copyright (c) Key Technology Pty Ltd 1999, All Rights Reserved.
- ' Web site: http://www.keytech.com.au Email: info@keytech.com.au
- '****************************************************************************************************
- Option Explicit
- Private mServiceName As String
- Private mConfigurationChanged As Boolean
- Private mAllowServiceToInteract As Boolean
- Private mAccountName As String
- Private mPassword As String
- Private mPasswordChanged As Boolean
- Private Sub optSystemAccount_Click()
- chkInteract.Enabled = True
- If mAllowServiceToInteract Then chkInteract = vbChecked
- mAccountName = txtAccountName
- txtAccountName.Enabled = False
- lblPassword.Enabled = False
- lblConfirm.Enabled = False
- lblPassword2.Enabled = False
- txtPassword.Enabled = False
- txtConfirmPassword.Enabled = False
- txtAccountName = ""
- txtPassword = ""
- txtConfirmPassword = ""
- End Sub
- Private Sub optThisAccount_Click()
- mAllowServiceToInteract = (chkInteract = vbChecked)
- chkInteract.Enabled = False
- chkInteract = vbUnchecked
- txtAccountName.Enabled = True
- txtAccountName = mAccountName
- lblPassword.Enabled = True
- lblConfirm.Enabled = True
- lblPassword2.Enabled = True
- txtPassword.Enabled = True
- txtConfirmPassword.Enabled = True
- txtPassword = Space(14)
- txtConfirmPassword = txtPassword
- mPasswordChanged = False
- End Sub
- Private Sub txtPassword_Change()
- mPasswordChanged = True
- End Sub
- Private Sub txtConfirmPassword_Change()
- mPasswordChanged = True
- End Sub
- Private Sub cmdCancel_Click()
- Unload Me
- End Sub
- Private Sub cmdOK_Click()
- On Error GoTo ErrorHandler
- ' If a password has been specified make sure it's been confirmed
- If optThisAccount And mPasswordChanged Then
- If Len(txtPassword) <> 0 Or Len(txtConfirmPassword) <> 0 Then
- If txtPassword <> txtConfirmPassword Then
- MsgBox "The passwords mismatch. Please re-enter.", vbExclamation
-
- txtPassword = ""
- txtConfirmPassword = ""
- txtPassword.SetFocus
-
- Exit Sub
- End If
- End If
- End If
- ' Open the service manager
- Dim ServiceManager As New ServiceManager
- ServiceManager.ComputerName = frmMain.ComputerName
- ServiceManager.AccessMode = WriteAccess
- ' Get the configuration object for the selected service
- Dim ServiceName As String
- Dim ServiceConfiguration As ServiceConfiguration
- ServiceName = frmMain.SelectedServiceName
- Set ServiceConfiguration = ServiceManager.Configuration(ServiceName)
- ' Update the service type - if an interactive process set to use the
- ' localsystem account otherwise the type cannot be changed
- Dim ServiceType As ServiceType
- ServiceType = ServiceConfiguration.ServiceType
- ServiceType = ServiceType And Not InteractiveProcess
- If optSystemAccount And chkInteract = vbChecked Then
- ServiceType = ServiceType Or InteractiveProcess
- End If
- If ServiceType And InteractiveProcess Then
- ServiceConfiguration.AccountName = "LocalSystem"
- End If
- ServiceConfiguration.ServiceType = ServiceType
- ' Update the start type
- Dim StartType As StartType
- If optAutomatic Then StartType = AutoStart
- If optManual Then StartType = DemandStart
- If optDisabled Then StartType = Disabled
- ServiceConfiguration.StartType = StartType
- ' Update the log on account
- Dim AccountName As String
- If optSystemAccount Then
- AccountName = "LocalSystem"
- Else
- AccountName = txtAccountName
- End If
- If AccountName <> "LocalSystem" Then
- If InStr(1, AccountName, "\") = 0 Then
- AccountName = ".\" & AccountName
- End If
- End If
- ServiceConfiguration.AccountName = AccountName
- ' Update the log on account and password
- If optThisAccount And mPasswordChanged Then
- ServiceConfiguration.Password = txtPassword
- End If
-
- mConfigurationChanged = True
- Unload Me
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Private Sub Form_Load()
- On Error GoTo ErrorHandler
- ' Get the configuration object for the selected service
- Dim ServiceName As String
- Dim ServiceManager As New ServiceManager
- Dim ServiceConfiguration As ServiceConfiguration
- ServiceName = frmMain.SelectedServiceName
- ServiceManager.ComputerName = frmMain.ComputerName
- Set ServiceConfiguration = ServiceManager.Configuration(ServiceName)
- ' Display the service display name
- lblServiceName = ServiceConfiguration.DisplayName
- ' Display startup type
- Select Case ServiceConfiguration.StartType
- Case AutoStart
- optAutomatic = True
-
- Case Disabled
- optDisabled = True
-
- Case Else
- optManual = True
- End Select
- ' If a shared process then must be local system account
- If (ServiceConfiguration.ServiceType And Not InteractiveProcess) = Win32ShareProcess Then
- optSystemAccount.Enabled = False
- optThisAccount.Enabled = False
-
- mAccountName = "LocalSystem"
- Else
- mAccountName = ServiceConfiguration.AccountName
- End If
-
- ' Display log on account
- If mAccountName = "LocalSystem" Then
- optSystemAccount = True
-
- If ServiceConfiguration.ServiceType And InteractiveProcess Then
- mAllowServiceToInteract = True
- End If
-
- optSystemAccount_Click
- Else
- optThisAccount = True
-
- optThisAccount_Click
- End If
- Exit Sub
- ErrorHandler:
- MsgBox Err.Description, vbExclamation
- End Sub
- Public Property Let ServiceName(ByVal NewValue As String)
- mServiceName = NewValue
- End Property
- Public Property Get ConfigurationChanged() As Boolean
- ConfigurationChanged = mConfigurationChanged
- End Property
-