|
-
Aug 13th, 2012, 05:18 PM
#4
Re: VB6 Run As A Service (Windows 7)
Historically there were two main ways to do this.
One was a "quick and dirty" approach with some severe limitations, using a utility called srvany that came from one of the Resource Kits (NT 4.0? Win2k?). This is a wrapper process that becomes the actual Service but kicks off a VB6, etc. EXE as a child process in the Service context.
The other was a C++ OCX called ntsvc.ocx that could be added to the main Form of a carefully-written VB6 program. It provides the necessary Service Manager and related interfaces a Service must support. Microsoft never offered it except as C++ source because it was unsupported. There are precompiled versions of the code around, some strictly VB5-oriented and some better-bahaved modified versions for VB6. There are also some creaky/broken versions out there.
Using these two Microsoft approaches (or several 3rd party approaches) your programs need to be carefully crafted to operate properly as a Service. In the post-XP world even more care is required because modern versions of Windows lock down a lot more things. Look up "Windows Service Hardening."
This isn't something the shadetree coder will be able to pick up and run with from sample code snippets. It is fairly exotic and requires very good understanding of how VB6 really works, Apartment Threading details, etc. There are many things that have to be dealt with in order for such a program to be reliable. There are also special deployment considerations.
Often you don't really need a Service anyway.
Sometimes you can get by fine with a regular program that is auto-run via the Startup folder. If you insist you can also use the various auto-run registry keys.
Modern Windows versions also have an enhanced Scheduler that can be used to run a program on logon or even on boot (with nobody logging on).
The last scenario is really the only one that normally needs a Service anyway: a program that always runs after booting.
The real question is: Why do you think you want a Service? This might be rephrased as: What are you actually trying to accomplish?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|