Advertisement
ASP_Volume2 Windows System Services #33064

Install Windows NT Service

Install a Windows NT service on a local or remote server. Configure how the service is installed. Requires Windows NT and administrator rights.

AI

Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kod źródłowy
original-source
Public Function Install_SVC(strServiceFileName As String, strServiceName As String, strDisplayName As String, bolInteractive As Boolean, bolAutoStart As Boolean, Optional strMachineName As Variant, Optional strAccount As Variant, Optional strAccountPassword As Variant) As Boolean
 Dim hSCM As Long
 Dim hSVC As Long
 Dim lngInteractive As Long
 Dim lngAutoStart As Long
 Dim pSTATUS As SERVICE_STATUS
 If bolInteractive = True Then lngInteractive = (&H100 Or &H10) Else lngInteractive = &H10
 If bolAutoStart = True Then lngAutoStart = &H2 Else lngAutoStart = &H3
 If IsMissing(strMachineName) = True Then strMachineName = vbNullString Else strMachineName = CStr(strMachineName)
 If IsMissing(strAccount) = True Then strAccount = vbNullString Else strAccount = CStr(strAccount)
 If IsMissing(strAccountPassword) = True Then strAccountPassword = vbNullString Else strAccountPassword = CStr(strAccountPassword)
 
 '// Open the service manager
 hSCM = OpenSCManager(strMachineName, vbNullString, &H2)
 If hSCM = 0 Then Exit Function '// error opening
 '// Install the service
 hSVC = CreateService(hSCM, _
 strServiceName, _
 strDisplayName, _
 983551, _
 lngInteractive, _
 lngAutoStart, _
 0, _
 strServiceFileName, _
 vbNull, _
 vbNull, _
 vbNullString, _
 strAccount, _
 strAccountPassword)
 
 If hSVC <> 0 Then Install_SVC = True
 
 Call CloseServiceHandle(hSVC)
 Call CloseServiceHandle(hSCM)
End Function
Oryginalne komentarze (3)
Odzyskane z Wayback Machine