Hi all,
I have heard this words lot of times here..
"Make application as SERVICE" or
"Run the application as a SERVICE"
What does it means? How it can be done? And can anyone tell me its benifits and drawbacks?
Thanks in advance...
Anita.
Printable View
Hi all,
I have heard this words lot of times here..
"Make application as SERVICE" or
"Run the application as a SERVICE"
What does it means? How it can be done? And can anyone tell me its benifits and drawbacks?
Thanks in advance...
Anita.
not sure if there is any difference, but stuff like norton anti virus run as service..
ummmmmm..........i believe somthing to do with server of Client-Server...I am not sure
Really?Quote:
Originally posted by Dinz
ummmmmm..........i believe somthing to do with server of Client-Server...I am not sure
Is it related with client-server?
can anyone tell?
Anita
Hi anita,
When you go through Start->Settings-> ControlPanel -> Services. You can see a list of services running on your system and their status(Whether running or stopped) and startup(whether started automatically or manually). If iam not wrong you want to make your Vb application(not various boy friends) to be added to this list. :)
I havent got anything as "services" in Start->Settings-> ControlPanelQuote:
Originally posted by ravi_sekhar
Hi anita,
When you go through Start->Settings-> ControlPanel -> Services. You can see a list of services running on your system and their status(Whether running or stopped) and startup(whether started automatically or manually). If iam not wrong you want to make your Vb application(not various boy friends) to be added to this list. :)
do u mean "task manager"
Anita...
No baby, you are wrong. Search cooly in your control panel. It is there in win2000 and winnt. what OS do you use?? I am not getting your problem exactly.......
This helped me make my first service.
http://www.vbforums.com/showthread.p...ices+are+tough
Its sorta a template.
Check out the down load
Seahag
Oh, there is nothing like "services" in control pannel..Quote:
Originally posted by ravi_sekhar
No baby, you are wrong. Search cooly in your control panel. It is there in win2000 and winnt. what OS do you use?? I am not getting your problem exactly.......
i'm using win2000
Well I'm pretty sure that you should be able to find this key in your registry at least.
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices
In my registry that's where my ZoneAlarm TrueVector entry sits. and unless I'm totally off on this, the RunServices key has loading priority over the Run key which will make other software load at startup. Understandably this would be crucial requirement to any firewall or Anti Virus software.
The firewall has to be able to stop any Trojans or virus from attempting to establish a connection on execution. Obviously it ain't loaded when that happens it wouldn’t help you much ;)
Any way you probably know all this but If you are just wanting to add your app to this list, just find any code on this forum that will let you create a key in the registry and modify it to point to this key instead.
Here's what the registry entry for TrueVector looks like on my Win98 system BTW:
"C:\WINDOWS\SYSTEM\ZONELABS\VSMON.EXE -service"
If you were reffering to a way to hide your app from task manager's list by running it as a service, this might be what you need then..
hope this helps!VB Code:
Public Declare Function GetCurrentProcessId Lib "kernel32" () As Long Public Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessId As Long, ByVal dwType As Long) As Long Public Const RSP_SIMPLE_SERVICE = 1 Public Const RSP_UNREGISTER_SERVICE = 0 Public Sub MakeMeService() 'To hide your application from the Task Manager Dim pid As Long Dim regserv As Long pid = GetCurrentProcessId() regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE) End Sub Public Sub UnMakeMeService() 'To restore your application to the Task Manager Dim pid As Long Dim regserv As Long pid = GetCurrentProcessId() regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE) End Sub
Try opening "Administrative tools" under "Control Panel", U may find Services there.
Here is some more tools for you
VB Code:
Option Explicit Private Const SERVICE_WIN32_OWN_PROCESS = &H10& Private Const SERVICE_WIN32_SHARE_PROCESS = &H20& Private Const SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS + _ SERVICE_WIN32_SHARE_PROCESS Private Const SERVICE_ACCEPT_STOP = &H1 Private Const SERVICE_ACCEPT_PAUSE_CONTINUE = &H2 Private Const SERVICE_ACCEPT_SHUTDOWN = &H4 Private Const SC_MANAGER_CONNECT = &H1 Private Const SC_MANAGER_CREATE_SERVICE = &H2 Private Const SC_MANAGER_ENUMERATE_SERVICE = &H4 Private Const SC_MANAGER_LOCK = &H8 Private Const SC_MANAGER_QUERY_LOCK_STATUS = &H10 Private Const SC_MANAGER_MODIFY_BOOT_CONFIG = &H20 Public Const STANDARD_RIGHTS_REQUIRED = &HF0000 Private Const SERVICE_QUERY_CONFIG = &H1 Private Const SERVICE_CHANGE_CONFIG = &H2 Private Const SERVICE_QUERY_STATUS = &H4 Private Const SERVICE_ENUMERATE_DEPENDENTS = &H8 Private Const SERVICE_START = &H10 Private Const SERVICE_STOP = &H20 Private Const SERVICE_PAUSE_CONTINUE = &H40 Private Const SERVICE_INTERROGATE = &H80 Private Const SERVICE_USER_DEFINED_CONTROL = &H100 Private Const SERVICE_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or _ SERVICE_QUERY_CONFIG Or _ SERVICE_CHANGE_CONFIG Or _ SERVICE_QUERY_STATUS Or _ SERVICE_ENUMERATE_DEPENDENTS Or _ SERVICE_START Or _ SERVICE_STOP Or _ SERVICE_PAUSE_CONTINUE Or _ SERVICE_INTERROGATE Or _ SERVICE_USER_DEFINED_CONTROL) Private Const SERVICE_DEMAND_START As Long = &H3 Private Const SERVICE_ERROR_NORMAL As Long = &H1 ' Private Enum SERVICE_CONTROL Private Const SERVICE_CONTROL_STOP = &H1 Private Const SERVICE_CONTROL_PAUSE = &H2 Private Const SERVICE_CONTROL_CONTINUE = &H3 Private Const SERVICE_CONTROL_INTERROGATE = &H4 Private Const SERVICE_CONTROL_SHUTDOWN = &H5 ' End Enum ' Private Enum SERVICE_STATE Private Const SERVICE_STOPPED = &H1 Private Const SERVICE_START_PENDING = &H2 Private Const SERVICE_STOP_PENDING = &H3 Private Const SERVICE_RUNNING = &H4 Private Const SERVICE_CONTINUE_PENDING = &H5 Private Const SERVICE_PAUSE_PENDING = &H6 Private Const SERVICE_PAUSED = &H7 ' End Enum Private Type SERVICE_TABLE_ENTRY lpServiceName As String lpServiceProc As Long lpServiceNameNull As Long lpServiceProcNull As Long End Type 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 StartServiceCtrlDispatcher Lib "advapi32.dll" Alias "StartServiceCtrlDispatcherA" (lpServiceStartTable As SERVICE_TABLE_ENTRY) As Long Private Declare Function RegisterServiceCtrlHandler Lib "advapi32.dll" Alias "RegisterServiceCtrlHandlerA" (ByVal lpServiceName As String, ByVal lpHandlerProc As Long) As Long Private Declare Function SetServiceStatus Lib "advapi32.dll" (ByVal hServiceStatus As Long, lpServiceStatus As SERVICE_STATUS) As Long Private Declare Function OpenSCManager Lib "advapi32.dll" Alias "OpenSCManagerA" (ByVal lpMachineName As String, ByVal lpDatabaseName As String, ByVal dwDesiredAccess As Long) 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, ByVal lpdwTagId As String, ByVal lpDependencies As String, ByVal lp As String, ByVal lpPassword As String) As Long Private Declare Function DeleteService Lib "advapi32.dll" (ByVal hService As Long) As Long Declare Function CloseServiceHandle _ Lib "advapi32.dll" (ByVal hSCObject As Long) As Long Declare Function OpenService _ Lib "advapi32.dll" Alias "OpenServiceA" _ (ByVal hSCManager As Long, ByVal lpServiceName As String, _ ByVal dwDesiredAccess As Long) As Long '** Change SERVICE_NAME as needed Private Const SERVICE_NAME As String = "MyService" Private hServiceStatus As Long Private ServiceStatus As SERVICE_STATUS Public Sub Main() Dim hSCManager As Long Dim hService As Long Dim ServiceTableEntry As SERVICE_TABLE_ENTRY Dim b As Boolean Dim cmd As String cmd = Trim(LCase(Command())) Select Case cmd Case "install" 'Install service on machine hSCManager = OpenSCManager(vbNullString, vbNullString, _ SC_MANAGER_CREATE_SERVICE) hService = CreateService(hSCManager, SERVICE_NAME, _ SERVICE_NAME, SERVICE_ALL_ACCESS, _ SERVICE_WIN32_OWN_PROCESS, _ SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, _ App.Path & "\" & App.EXEName, vbNullString, _ vbNullString, vbNullString, vbNullString, _ vbNullString) CloseServiceHandle hService CloseServiceHandle hSCManager Case "uninstall" 'Remove service from machine hSCManager = OpenSCManager(vbNullString, vbNullString, _ SC_MANAGER_CREATE_SERVICE) hService = OpenService(hSCManager, SERVICE_NAME, _ SERVICE_ALL_ACCESS) DeleteService hService CloseServiceHandle hService CloseServiceHandle hSCManager Case Else 'Start the service ServiceTableEntry.lpServiceName = SERVICE_NAME ServiceTableEntry.lpServiceProc = FncPtr(AddressOf ServiceMain) b = StartServiceCtrlDispatcher(ServiceTableEntry) End Select End Sub Public Sub ServiceMain(ByVal dwArgc As Long, ByVal lpszArgv As Long) Dim b As Boolean 'Set initial state ServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS ServiceStatus.dwCurrentState = SERVICE_START_PENDING ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP _ Or SERVICE_ACCEPT_PAUSE_CONTINUE _ Or SERVICE_ACCEPT_SHUTDOWN ServiceStatus.dwWin32ExitCode = 0 ServiceStatus.dwServiceSpecificExitCode = 0 ServiceStatus.dwCheckPoint = 0 ServiceStatus.dwWaitHint = 0 hServiceStatus = RegisterServiceCtrlHandler(SERVICE_NAME, AddressOf Handler) ServiceStatus.dwCurrentState = SERVICE_START_PENDING b = SetServiceStatus(hServiceStatus, ServiceStatus) '** Do Initialization Here ServiceStatus.dwCurrentState = SERVICE_RUNNING b = SetServiceStatus(hServiceStatus, ServiceStatus) '** Perform tasks -- if none exit ''** If an error occurs, the following should be used for shutting ''** down: '' SetServerStatus SERVICE_STOP_PENDING '' Clean up '' SetServerStatus SERVICE_STOPPED End Sub Public Sub Handler(ByVal fdwControl As Long) Dim b As Boolean Select Case fdwControl Case SERVICE_CONTROL_PAUSE '** Do whatever it takes to pause here. ServiceStatus.dwCurrentState = SERVICE_PAUSED Case SERVICE_CONTROL_CONTINUE '** Do whatever it takes to continue here. ServiceStatus.dwCurrentState = SERVICE_RUNNING Case SERVICE_CONTROL_STOP ServiceStatus.dwWin32ExitCode = 0 ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING ServiceStatus.dwCheckPoint = 0 ServiceStatus.dwWaitHint = 0 'Might want a time estimate b = SetServiceStatus(hServiceStatus, ServiceStatus) '** Do whatever it takes to stop here. ServiceStatus.dwCurrentState = SERVICE_STOPPED Case SERVICE_CONTROL_INTERROGATE 'Fall through to send current status. Case Else End Select 'Send current status. b = SetServiceStatus(hServiceStatus, ServiceStatus) End Sub Public Function FncPtr(ByVal fnp As Long) As Long FncPtr = fnp End Function
Hi,
Benefit is no need to start manually.When windows
starts , it starts atomatically.
In control panel u can find serives on win2k and NT.