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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the best way to achieve auto running?

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
0
0
AU
I have in mind an application that will mainly act as monitoring terminal for occasional errors that might be generated at about 20 other computers (each running another of my apps!).(Mainly like "File not found")

It is also will be used intermittently for sending data to these computers

The problem is if this new program is only started when the operator wants to send some files or data, it won't always see errors as they happen. Some days it might not even be started so errors could go unnoticed for days.

By putting it in the RUN part of the registry of the control computer I could have it start invisibly every time the monitoring computer is rebooted and the form only appear if a fault is received or data is required to be sent. I can handle this part of it OK

What would be the minimum code required to check if the app was in the RUN part of the registry and add it if it is not every time my app starts (in case someone has erased from the registry it the day before - like Tinkerbell)
And to delete one if more than two entries are accidentally added?
I was hoping not to have to use an OCX not normally supplied with VB6 or Windows and it will have to run on XP or Vista.
Would it perhaps be better to treat it as a service or put in in the RUN of the registry which should be enough anyway?

I would also like it to appear as an icon on the bottom right hand side of the screen so people could open it to send data or check for errors. How do you do that?
When they close it, the app will always stay hidden running in the background.
 
Search for Run Once or Run At Startup for examples on how to put your program in the startup portion of the registry. Once you know how to put it in there you will also know how to read from there to see if it is there. Then search on Shell Notify Icon for how to put your application into the systray.

See...


for registry entries on running at startup.

Good Luck
 
What do you want to happen if the user/operator happens to log out?
 
vb5prgrmr:
Cant seem to work out the guts of just how do add an entry to Run without disturbing what is there. Any suggestions?

Strongm: Not essential but it would be better if the app stayed running after a log out and later reported if there had been a message to the next user that logged in.

By the way many different users could use the computer between boot-ups so it would have to be seen by any user.

Does this mean it should be a 'service' as per your previous posts?
 
Ted, this link has some useful information regarding the adding of registry keys using the API's, as long as you know the path you want to add to and use a unique key you shouldn't affect anything else (though it's generally a good idea to back up your registry before you delve into editing it).

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before posting.

 
>it would be better if the app stayed running after a log out ... Does this mean it should be a 'service' as per your previous posts?

Yep
 
That's my problem.
I cant work out to do this.
Plenty of examples in other languages but I can find one in vb6.
 
I understand how the registry run and services are used and how to normally modify registry with the tools including regedit but what I wanted to know is how to do this from WITHIN my vb6 app on app startup without any user intervention.
I didn't want to use any other exe program if possible.

Are there any examples how this this done to make it clear what variables go where?

Any references I can find so far just talk about "use such and such" but they don't seem to tell me how! (obviously written by someone who knows how and expects everyone else to do the same)

Similar problem exists in all cities where the people designing freeway exits know the layout of the area like the back of their hand and cant understand why a stranger has a crash because they go the wrong way!
 
>Are there any examples how this this done

I'm pretty sure GhostWolf's link about NTSVC.OCX shows how to get a VB service to register itself. The example code happens to require "/install" as a parameter to the application to get this to work, but that's pretty easy to change. Sure, it requires the OCX, but I believe it is about the easiest way to proceed here.


Warning - whilst versions of Windows prior to Vista will allow a VB service created with NTSVC.OCX to interact with the desktop (i.e. have a GUI), Vista and later will not. One way to deal with that is to also have a seperate, normal application representing the services GUI that is launched from the All Users startup folder with which your service communicates (e.g via winsock, with which you are intimately familiar)
 
Does this OCX have the full approval by Microsoft?
I am nervous about installing someone else ocx as I have been caught out before by unexpected effects on other things and things like memory leaks (even MS still have them)

I have seen code that does it in C without OCXs so I was hoping to do the same in VB6.
 
It's my understanding that M$ originally coded it, but you had to compile it yourself in order to use it; they no longer provide it or support it.

There are API calls you can do in VB6 to achieve the same functionality, though. I'll post a link as soon as I can find the snippets I downloaded...

 
Shucks, looks like I can't be as helpful as I'd hoped. I found the source, but the URLs he referenced - both his own and MSDN links - are no longer valid, (guess that happens after almost ten years!).
 
It was written by Microsoft (well, by an employee in Microsoft Consulting Services), and used to ship with the MSDN disks, including source code. It's no longer available (and MS eventually completely withdrew their support even for the idea of running VB applicatons as services as you can see if you compare the current KB175948 with the original KB175948 from 1997.) And they've completely expunged the article "NT Service: An OLE Control for Creating Windows NT Services in Visual Basic"

Fortunately I have a copy of that article on my April 2001 MSDN CDs ... here you go. Note that the NTService control referenced is actually NTSVC.OCX

And here's a copy of the original release of the OCX which includes the source code.
 
Now we are getting there!

Thanks a lot to both of you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top