PowerTCP WebServer for ActiveX

from $499.00
Available Platforms

PowerTCP WebServer for ActiveX Features

NT Service ActiveX Control

The NT Service control is used to turn any application into an NT Service. Features include:

 

  • Easily turn any server applications built using PowerTCP products into services.
  • Applications built with the Service Control target server-side applications that always run in the background, even when a user is not logged into the system.
  • With the Service control you can respond to all service events, including Start, Stop, Pause, and Resume. The Message event is included to support user messages sent from external applications. The Log method is included for logging event messages.
  • Convenient Install and Uninstall methods provide a way for your application to install and uninstall itself as a service. The Abort method allows your service to abort and stop itself while running.

 

 

Interface Members

 

Public Properties
Params Contains the parameters passed to your service. This property may be read when the State property is serviceRunning.
State Determine what state the service is in. The State event fires to signal that this property has changed.
Public Methods
Abort Abort and stop a running service.
About Show the About Box.
Connect Connect the service to the operating system’s Service Control Manager (SCM). Call this method as soon as possible after your application starts.
Install Install the application as a service.
Log Enter an event in the Windows Event Log.
Uninstall Uninstall a service.
Public Events
Error Fires when an error occurs. This event fires before the error is reported back to the container's error object
Message Fires when an application sends the service a user message. This can be used any way you wish, as it has no special meaning to the operating system.
State Fires to indicate the State property has changed value.

 

 

Code Example

How easy is the NT Service control to use? Check out the following Service VB example below, which demonstrates creating an echo service with the Server control.

 

Private Sub Form_Load()
On Error GoTo OnError ' use intrinsic error handling

'Connect to the Service Control Manager
Service1.Connect
Exit Sub

OnError: ' Any error jumps here
Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub

Private Sub Service1_State()
On Error GoTo OnError ' use intrinsic error handling
Dim I As Integer
Select Case Service1.State
Case serviceRunning
' service is now running, beep to the world!
Beep

' Start the Echo Server
Server1.Listen 7

Case servicePaused
' service is now going to sleep, stop listening for new connections
Server1.Close

Case serviceResumed
' service is now waking up from sleep, resume listening!
Server1.Listen 7

Case serviceStopped
' service is now stopping, log a message to Windows event log
Service1.Log serviceInformation, serviceInfoEvent, “Stopping”

' stop listening for new connections
Server1.Close

' shut down all active connections
For I = 1 To Server1.Children.Count
Server1.Children(I).Close
Next
End Select
Exit Sub

OnError: ' Any error jumps here
Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub