Option Explicit
Private Type SERVICE_STATUS
dwServiceType As Long
dwCurrentState As Long
dwControlsAccepted As Long
dwWin32ExitCode As Long
dwServiceSpecificExitCode As Long
dwCheckPoint As Long
dwWaitHint As Long
End Type
Private Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" _
(Byval lpMachineName As String, Byval lpDatabaseName As String, Byval _
dwDesiredAccess As Long) As Long
Declare Function ControlService Lib "advapi32.dll" (Byval hService As Long, _
Byval dwControl As Long, lpServiceStatus As SERVICE_STATUS) As Long
Private Declare Function CreateService Lib "advapi32.dll" Alias "CreateServiceA" _
(Byval hSCManager As Long, Byval lpServiceName As String, Byval _
lpDisplayName As String, Byval dwDesiredAccess As Long, Byval _
dwServiceType As Long, Byval dwStartType As Long, Byval _
dwErrorControl As Long, Byval lpBinaryPathName As String, Byval _
lpLoadOrderGroup As String, lpdwTagId As Long, Byval lpDependencies As _
String, Byval lpServiceStartName As String, Byval lpPassword _
As String) As Long
Declare Function OpenService Lib "advapi32.dll" Alias "OpenServiceA" (Byval _
hSCManager As Long, Byval lpServiceName As String, Byval _
dwDesiredAccess As Long) As Long
Declare Function QueryServiceStatus Lib "advapi32.dll" (Byval hService As Long, _
lpServiceStatus As SERVICE_STATUS) As Long
Private Declare Function CloseServiceHandle Lib "advapi32.dll" (Byval _
hSCObject As Long) As Long
Public Function Install_SVC(strServiceFileName As String, strServiceName As _
String, strDisplayName As String, bolInteractive As Boolean, bolAutoStart As _
Boolean, Optional GroupName As String = "", Optional strMachineName As _
Variant, Optional strAccount As Variant, Optional strAccountPassword As _
Variant) As Boolean
On Error Resume Next
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)
hSCM = OpenSCManager(strMachineName, vbnullString, &H2)
If hSCM = 0 Then Exit Function '// gagal membuat
'// Install service
hSVC = CreateService(hSCM, strServiceName, strDisplayName, 983551, _
lngInteractive, lngAutoStart, 0, strServiceFileName, GroupName, _
vbnull, vbnullString, strAccount, strAccountPassword)
If hSVC 0 Then Install_SVC = True
Call CloseServiceHandle(hSVC)
Call CloseServiceHandle(hSCM)
'StartService
End Function
September 20, 2009
Disqus Comments
Trending
Label
Antivirus
Automotives
bb themes
blackberry
blackberry themes
blackberry unlock
Blogging
C++
Cosmetic Edits XP
Dota
facebook blackberry
Freewarez
Game Cheat
Headline News
Linux
Lowongan Kerja
Make Money Online
Mobiles
News
PC Games
Php
Phreaking
Recipes
Registry Edit XP
SEO
System Performance Edits for Windows XP
themes
Tips
Tutorials
VBA
Visual Basic
Web Development
Web-Based Game
Whatsapp
Windows
XP Full Tips