Can VB Standard do Windows Services?

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

I have VB standard 2003. Even though it doesn't have a built-in template
for Windows Services, is it possible to build and compile a service? If so,
how would I go about doing it?
 
You should be able to. You need to add a reference to
System.ServiceProcess.dll, and the appropriate Imports statement.

Then you have to create a class that Inherits from
System.ServiceProcess.ServiceBase.

Next you would have a Shared Sub Main similar to this one:

' The main entry point for the process
<MTAThread()> _
Shared Sub Main(ByVal args() As String)
Dim ServicesToRun() As System.ServiceProcess.ServiceBase

ServicesToRun = New System.ServiceProcess.ServiceBase() {New
ServiceClassName}
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End Sub

Finally, override the OnStart, OnStop, etc events to provide your
service with functionality.

There is an article in the MSDN library called "Writing Services
Programatically". Search for that and it tells what to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top