Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Windows Service in VB6 2

Status
Not open for further replies.

r3g

Programmer
Apr 29, 2003
5
AU
hi,

not sure if this has been addressed in this forum, but does anyone know how to write a service for windows 2000 server in vb 6? i've seen a lot of articles about writing services in VB.net but that doesn't apply to me.

or is it possible to turn an existing VB EXE application into a windows service?

Thanks
 
Use the Microsoft NT Service Control
NTSVC.ocx

Sample Code:
Private Sub Form_Load()

Dim strDisplayName As String

On Error GoTo Err_Load

strDisplayName = NTService1.DisplayName

If Command = "-install" Then
' Enable interaction with desktop.
NTService1.Interactive = True

If NTService1.Install Then
MsgBox strDisplayName & " installed successfully"
Else
MsgBox strDisplayName & " failed to install"
End If
End
ElseIf Command = "-uninstall" Then
If NTService1.Uninstall Then
MsgBox strDisplayName & " uninstalled successfully"
Else
MsgBox strDisplayName & " failed to uninstall"
End If
End
ElseIf Command = "-debug" Then
NTService1.Debug = True

ElseIf Command <> &quot;&quot; Then
MsgBox &quot;Invalid command option&quot;
End
End If

' Connect service to Windows NT services controller.
NTService1.StartService

Err_Load:
' Error starting service

End Sub

Private Sub NTService1_Start(Success As Boolean)

Success = True
Timer1.Enabled = True

End Sub

Good luck - hope this helps you
:)

The pen is mightier than the sword - and quite frankly . . easier to write with
 
Been covered many times here ... do a search.

Short summary:
1. Can be done via API calls, but not for the faint of heart.

2. Can be done via the MS NTSvc.ocx (as detailed by theBitchie above). But the control is unsupported, and your boss might not like that.

3. Use Desaware's NT Service toolkit -- a commercial product for which support is available.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top