home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD174683232001.psc / frmSCMsgBox.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-03-23  |  8.6 KB  |  213 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmSCMsgBox 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Form1"
  6.    ClientHeight    =   1005
  7.    ClientLeft      =   3750
  8.    ClientTop       =   8205
  9.    ClientWidth     =   5655
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   1005
  14.    ScaleWidth      =   5655
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.Timer tmrMain 
  17.       Enabled         =   0   'False
  18.       Interval        =   1000
  19.       Left            =   4050
  20.       Top             =   480
  21.    End
  22.    Begin VB.Timer tmrAnimation 
  23.       Enabled         =   0   'False
  24.       Interval        =   1000
  25.       Left            =   4560
  26.       Top             =   465
  27.    End
  28.    Begin MSComctlLib.ImageList imglstTimerAni 
  29.       Left            =   5055
  30.       Top             =   375
  31.       _ExtentX        =   1005
  32.       _ExtentY        =   1005
  33.       BackColor       =   -2147483643
  34.       ImageWidth      =   32
  35.       ImageHeight     =   32
  36.       MaskColor       =   12632256
  37.       _Version        =   393216
  38.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  39.          NumListImages   =   12
  40.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  41.             Picture         =   "frmSCMsgBox.frx":0000
  42.             Key             =   ""
  43.          EndProperty
  44.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  45.             Picture         =   "frmSCMsgBox.frx":031A
  46.             Key             =   ""
  47.          EndProperty
  48.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  49.             Picture         =   "frmSCMsgBox.frx":0634
  50.             Key             =   ""
  51.          EndProperty
  52.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  53.             Picture         =   "frmSCMsgBox.frx":094E
  54.             Key             =   ""
  55.          EndProperty
  56.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  57.             Picture         =   "frmSCMsgBox.frx":0C68
  58.             Key             =   ""
  59.          EndProperty
  60.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  61.             Picture         =   "frmSCMsgBox.frx":0F82
  62.             Key             =   ""
  63.          EndProperty
  64.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  65.             Picture         =   "frmSCMsgBox.frx":129C
  66.             Key             =   ""
  67.          EndProperty
  68.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  69.             Picture         =   "frmSCMsgBox.frx":15B6
  70.             Key             =   ""
  71.          EndProperty
  72.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  73.             Picture         =   "frmSCMsgBox.frx":18D0
  74.             Key             =   ""
  75.          EndProperty
  76.          BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  77.             Picture         =   "frmSCMsgBox.frx":1BEA
  78.             Key             =   ""
  79.          EndProperty
  80.          BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  81.             Picture         =   "frmSCMsgBox.frx":1F04
  82.             Key             =   ""
  83.          EndProperty
  84.          BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  85.             Picture         =   "frmSCMsgBox.frx":221E
  86.             Key             =   ""
  87.          EndProperty
  88.       EndProperty
  89.    End
  90.    Begin VB.Image imgTimerIcons 
  91.       Height          =   480
  92.       Left            =   90
  93.       Top             =   285
  94.       Width           =   480
  95.    End
  96.    Begin VB.Label lblMessage 
  97.       Caption         =   "Label1"
  98.       BeginProperty Font 
  99.          Name            =   "MS Sans Serif"
  100.          Size            =   12
  101.          Charset         =   0
  102.          Weight          =   400
  103.          Underline       =   0   'False
  104.          Italic          =   0   'False
  105.          Strikethrough   =   0   'False
  106.       EndProperty
  107.       Height          =   660
  108.       Left            =   660
  109.       TabIndex        =   0
  110.       Top             =   180
  111.       Width           =   4875
  112.    End
  113. Attribute VB_Name = "frmSCMsgBox"
  114. Attribute VB_GlobalNameSpace = False
  115. Attribute VB_Creatable = False
  116. Attribute VB_PredeclaredId = True
  117. Attribute VB_Exposed = False
  118. Dim iCurrentImage As Integer
  119. Dim lTimerCounter As Long
  120. Dim lCheckPoint As Long
  121. Private Sub Form_Load()
  122.     Call AlwaysOnTop(Me.hwnd)
  123.         
  124.     tmrMain.Enabled = True
  125.     tmrMain.Interval = SERVICE_CONTROL_WAITTIME
  126.     tmrAnimation.Enabled = False
  127.     tmrAnimation.Interval = 500
  128.     lblMessage.Caption = SERVICE_CONTROL_MSGBOX_MESSAGE
  129.     Me.Caption = SERVICE_CONTROL_MSGBOX_TITLE
  130.     imgTimerIcons.Picture = imglstTimerAni.ListImages(1).Picture
  131.     iCurrentImage = 1
  132.     lTimerCounter = 0
  133.     lCheckPoint = 0
  134.     tmrAnimation.Enabled = True
  135. End Sub
  136. Private Sub tmrAnimation_Timer()
  137.     If iCurrentImage < 12 Then
  138.         iCurrentImage = iCurrentImage + 1
  139.     Else
  140.         iCurrentImage = 1
  141.     End If
  142.         
  143.     imgTimerIcons.Picture = imglstTimerAni.ListImages(iCurrentImage).Picture
  144. End Sub
  145. Private Sub tmrMain_Timer()
  146.     Dim CurrentStatus As SERVICE_STATUS
  147.     Dim liCurrentItem As ListItem
  148.     lTimerCounter = lTimerCounter + 1
  149.     CurrentStatus = ServiceStatus(SERVICE_CONTROL_MACHINENAME, SERVICE_CONTROL_SERVICENAME)
  150.     If CurrentStatus.dwCurrentState = SERVICE_CONTROL_STATUS_WANTED Then
  151.         tmrMain.Enabled = False
  152.         
  153.         Set liCurrentItem = frmMain.lvServices.ListItems(UCase(SERVICE_CONTROL_SERVICENAME))
  154.         Select Case CurrentStatus.dwCurrentState
  155.             Case SERVICE_STOPPED
  156.                 liCurrentItem.SubItems(1) = ""
  157.                 liCurrentItem.ForeColor = vbRed
  158.             Case SERVICE_RUNNING
  159.                 liCurrentItem.SubItems(1) = "Started"
  160.                 liCurrentItem.ForeColor = vbBlack
  161.             Case SERVICE_PAUSED
  162.                 liCurrentItem.SubItems(1) = "Paused"
  163.                 liCurrentItem.ForeColor = vbGreen
  164.         End Select
  165.         
  166.         If CurrentStatus.dwWaitHint > 0 Then
  167.             MsgBox CurrentStatus.dwWaitHint
  168.         End If
  169.         
  170.         colServices(liCurrentItem.Key).CurrentStatus = CurrentStatus.dwCurrentState
  171.         colServices(liCurrentItem.Key).ControlsAccepted = CurrentStatus.dwControlsAccepted
  172.         
  173.         Set liCurrentItem = Nothing
  174.         Unload Me
  175.     Else
  176.         If lCheckPoint > 0 And lCheckPoint = CurrentStatus.dwCheckPoint Then
  177.             'check point failed to increment... this could be a potential problem
  178.             MsgBox "I was unable to perform the selected action on the service."
  179.             tmrMain.Enabled = False
  180.             Unload Me
  181.         End If
  182.         
  183.         If CurrentStatus.dwWaitHint > 0 Then
  184.             'Wait hint gives us a hint at how long the service needs.  Change the
  185.             'timer interval to this time.
  186.             tmrMain.Interval = CurrentStatus.dwWaitHint
  187.             lCheckPoint = CurrentStatus.dwCheckPoint
  188.         End If
  189.         
  190.         If CurrentStatus.dwWin32ExitCode > 0 Or CurrentStatus.dwServiceSpecificExitCode > 0 Then
  191.             'An error occurred while performing an action on the service
  192.             If CurrentStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR Then
  193.                 'The error is service specific and will be specified by dwServiceSpecificExitCode
  194.                 MsgBox CurrentStatus.dwServiceSpecificExitCode, vbOKOnly + vbCritical, "Service Specific Error"
  195.             Else
  196.                 MsgBox CurrentStatus.dwWin32ExitCode, vbOKOnly + vbCritical, "Error performing an action on the service"
  197.             End If
  198.         End If
  199.         
  200.         Debug.Print "WAIT HINT:               " & CStr(CurrentStatus.dwWaitHint)
  201.         Debug.Print "Check Point:             " & CStr(CurrentStatus.dwCheckPoint)
  202.         Debug.Print "Error Code:              " & CStr(CurrentStatus.dwWin32ExitCode)
  203.         Debug.Print "Service Specific Error:  " & CStr(CurrentStatus.dwServiceSpecificExitCode)
  204.         Debug.Print "Current State:           " & CStr(CurrentStatus.dwCurrentState)
  205.         
  206.         'Microsoft documentation states:  If the amount of time specified by dwWaitHint
  207.         'passes, and dwCheckPoint has not been incremented, or dwCurrentState has not
  208.         'changed, the service control manager or service control program can assume
  209.         'that an error has occurred.
  210.     End If
  211.     Set liCurrentItem = Nothing
  212. End Sub
  213.