views:

279

answers:

5

Is it possible to create a windows service in vb6? if yes, how?

A: 

To answer your question, yes it is possible to create a Windows service with VB6. To offer you advice, there are much better tools to use. I did it once as a proof of concept project, but never liked it well enough to try to use it for anything that we used in the company. A co-worker did do this for a production app and it was error prone. After he left we found out just how hard he was working to keep his service running and ended up replacing his app without reviewing his code. So my advice is, if you want to do it as an exercise go ahead, but if you are looking at this for a workable solution you should consider other tools. Here is a link to one way to do it.

Beaner
+3  A: 

I've never tried it, but Desaware offer a commercial package, the NT Service Toolkit that claims to allow you to host a VB6 DLL inside a Windows Service. Desaware was founded (and I think is still owned by) VB6 guru Dan Appleman, which is a good recommendation.

MarkJ
Back in the day... we used the NT Service Toolkit a lot. It was great. I don't recall ever having an issue with it.
Walter
+2  A: 

Microsoft created a control to allow you to create services in VB6.

http://support.microsoft.com/default.aspx/kb/170883

http://support.microsoft.com/kb/175948/EN-US/

Yes, it works, is it the best way to create a service, no, but if VB6 is a requirement (you have a bunch of code you have to re-use), then I can state from experience that it works. We have the original control from the January 1997 MSDN, however you can easily find it on the net if need be ( http://www.google.ca/search?q=ntsvc.ocx+download )

Kris Erickson
Bad code is bad code, and hacks are hacks. This OCX is only as good as the person using it. I've have used it in several servers to replace .Net servers written by contractors that was slow and buggy. Not only did we improve performance by nearly a factor of 10, it doesn't need to be manually restarted weekly the way the bad .Net code did.
Bob Riemersma
A: 

Yes, you can. Just follow the directions in this tutorial:

http://www.vbrad.com/article.aspx?id=92

AngryHacker
+1  A: 

Like gouging your own eyes out with a spoon, it is technically possible but I wouldn't recommend it.

graham.reeds