home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{5DA62B65-0D48-11D2-A6E3-00400541EFEE}#1.0#0"; "SvcIt.ocx"
- Begin VB.Form Main
- Caption = "Service-It Sample Beep Service"
- ClientHeight = 1380
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4230
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 1380
- ScaleWidth = 4230
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton CmdAdmin
- Caption = "&Admin..."
- Height = 345
- Left = 2910
- TabIndex = 4
- Top = 780
- Width = 1155
- End
- Begin VB.Timer Timer1
- Interval = 1000
- Left = 780
- Top = 720
- End
- Begin VB.TextBox State
- Height = 315
- Left = 1320
- TabIndex = 3
- Top = 120
- Width = 2745
- End
- Begin VB.CommandButton LogEventBtn
- Caption = "LogEvent"
- Height = 345
- Left = 1320
- TabIndex = 1
- Top = 780
- Width = 1245
- End
- Begin SVCITLib.SvcIt MyService
- Height = 480
- Left = 210
- TabIndex = 0
- ToolTipText = "Right-Click here to debug"
- Top = 690
- Width = 480
- _Version = 65536
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 0
- ServiceName = "BeepService"
- DisplayName = ""
- Dependencies = ""
- MachineName = ""
- ServiceExe = ""
- PauseContinue = -1 'True
- Priority = 1
- End
- Begin VB.Label Label1
- Caption = "Service state:"
- Height = 255
- Left = 150
- TabIndex = 2
- Top = 180
- Width = 1095
- End
- Attribute VB_Name = "Main"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub CmdAdmin_Click()
- Admin.Show 1
- End Sub
- Private Sub Form_Load()
- MyService.PauseContinue = True
- If (Not MyService.IsService) Then
- ' Enable the admin button only if we have admin rights
- CmdAdmin.Enabled = MyService.IsAdmin
- ' Simulate a service start to avoid right-clicking on the control :-)
- ' MyService.Start ""
- Else
- CmdAdmin.Enabled = False
- End If
- End Sub
- Private Sub LogEventBtn_Click()
- MyService.LogEvent "Error message!", 1
- End Sub
- Private Sub MyService_Continue()
- State.Text = "Started"
- End Sub
- Private Sub MyService_Control(ByVal Code As Long)
- State.Text = "Control(" + LTrim$(Str$(Code)) + ")"
- End Sub
- Private Sub MyService_Pause()
- State.Text = "Paused"
- End Sub
- Private Sub MyService_Start(ByVal sParams As String)
- State.Text = "Started Params=" + sParams
- Rem If your initialization process fails, you
- Rem can abort the service startup by calling the
- Rem Abort(Error, SpecificError) method
- Rem followed by the End Statement
- Rem Example:
- Rem MyService.Abort 0, 1
- Rem End
- MyService.LogEvent "The service was successfully started.", 4
- End Sub
- Private Sub MyService_Stop()
- State.Text = "Stopped"
- MyService.LogEvent "The service stop.", 4
- End Sub
- Private Sub Timer1_Timer()
- If MyService.IsRunning() Then
- Beep
- End If
- End Sub
-