home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / ntsetact / frmnewsc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-02-27  |  4.4 KB  |  142 lines

  1. VERSION 5.00
  2. Begin VB.Form FrmNewService 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "New Service"
  5.    ClientHeight    =   2955
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4680
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   2955
  13.    ScaleWidth      =   4680
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.CommandButton btnCancel 
  17.       Caption         =   "Cancel"
  18.       Height          =   375
  19.       Left            =   1920
  20.       TabIndex        =   11
  21.       Top             =   2460
  22.       Width           =   1275
  23.    End
  24.    Begin VB.CommandButton btnCreate 
  25.       Caption         =   "Create"
  26.       Height          =   375
  27.       Left            =   3300
  28.       TabIndex        =   10
  29.       Top             =   2460
  30.       Width           =   1275
  31.    End
  32.    Begin VB.Frame Frame1 
  33.       Caption         =   "Startup type"
  34.       Height          =   855
  35.       Left            =   60
  36.       TabIndex        =   6
  37.       Top             =   1440
  38.       Width           =   4515
  39.       Begin VB.OptionButton rbnDisabled 
  40.          Caption         =   "Disabled"
  41.          Height          =   195
  42.          Left            =   3120
  43.          TabIndex        =   9
  44.          Top             =   360
  45.          Width           =   1155
  46.       End
  47.       Begin VB.OptionButton rbnManual 
  48.          Caption         =   "Manual"
  49.          Height          =   195
  50.          Left            =   1620
  51.          TabIndex        =   8
  52.          Top             =   360
  53.          Width           =   1155
  54.       End
  55.       Begin VB.OptionButton rbnAutomatic 
  56.          Caption         =   "Automatic"
  57.          Height          =   195
  58.          Left            =   180
  59.          TabIndex        =   7
  60.          Top             =   360
  61.          Value           =   -1  'True
  62.          Width           =   1155
  63.       End
  64.    End
  65.    Begin VB.TextBox edtFileName 
  66.       Height          =   375
  67.       Left            =   1380
  68.       TabIndex        =   5
  69.       Top             =   900
  70.       Width           =   3255
  71.    End
  72.    Begin VB.TextBox edtDisplayName 
  73.       Height          =   375
  74.       Left            =   1380
  75.       TabIndex        =   3
  76.       Top             =   480
  77.       Width           =   3255
  78.    End
  79.    Begin VB.TextBox edtServiceName 
  80.       Height          =   375
  81.       Left            =   1380
  82.       TabIndex        =   1
  83.       Top             =   60
  84.       Width           =   3255
  85.    End
  86.    Begin VB.Label Label3 
  87.       Caption         =   "Binary file name"
  88.       Height          =   255
  89.       Left            =   120
  90.       TabIndex        =   4
  91.       Top             =   1020
  92.       Width           =   1155
  93.    End
  94.    Begin VB.Label Label2 
  95.       Caption         =   "Display name"
  96.       Height          =   255
  97.       Left            =   120
  98.       TabIndex        =   2
  99.       Top             =   540
  100.       Width           =   1155
  101.    End
  102.    Begin VB.Label Label1 
  103.       Caption         =   "Service name"
  104.       Height          =   255
  105.       Left            =   120
  106.       TabIndex        =   0
  107.       Top             =   120
  108.       Width           =   1155
  109.    End
  110. Attribute VB_Name = "FrmNewService"
  111. Attribute VB_GlobalNameSpace = False
  112. Attribute VB_Creatable = False
  113. Attribute VB_PredeclaredId = True
  114. Attribute VB_Exposed = False
  115. Private Sub btnCancel_Click()
  116.   Unload FrmNewService
  117. End Sub
  118. Private Sub btnCreate_Click()
  119.   On Error GoTo ErrorHandler
  120.   Set NTService = FrmServiceManager.NTServiceX
  121.   NTService.ManagerAccess = M_CONNECT + M_CREATE_SERVICE
  122.   NTService.ServiceType = WIN32_OWN_PROCESS
  123.   NTService.ErrorControl = ERROR_NORMAL
  124.   NTService.ServiceName = edtServiceName.Text
  125.   NTService.DisplayName = edtDisplayName.Text
  126.   NTService.BinaryPathName = edtFileName.Text
  127.   NTService.ServiceStartName = "LocalSystem"
  128.   If rbnAutomatic.Value = True Then NTService.StartType = AUTO_START
  129.   If rbnManual.Value = True Then NTService.StartType = DEMAND_START
  130.   If rbnDisabled.Value = True Then NTService.StartType = DISABLED
  131.   NTService.ActiveManager = True
  132.   MsgBox ("The service has been created successefuly.")
  133.   NTService.Createservice
  134. ExitProc:
  135.   NTService.ActiveManager = False
  136.   Unload FrmNewService
  137.   Exit Sub
  138. ErrorHandler:
  139.   MsgBox (Err.Description)
  140.   Resume ExitProc
  141. End Sub
  142.