Windows Service Style Program

ImDaFrEaK

Well-known member
Joined
Jan 7, 2006
Messages
416
Location
California
Programming Experience
5-10
I have a question. I want my program to work like a windows application so to speak. Basically what i mean is I want the program to run in the background with no user interface until certain conditions happen such as hotkeys being pressed. Then the appropriate form (window) will open.

I tried to do this using form main but the only way I could think to make it lye static was to put an infinite loop. This isn't static and eats processor time. I just want to get the same affect as a windows form. Have the program running but just waiting for something to happen.

I have accomplished this making a defualt form to control them all and just keeping it hidden always. I don't believe this is the propert way to do this so anyone has a better solution I am all ears. Thanks in advance :)
 
The loop is a bad choice. If you want your App to truly run behind the scenes then you should look into creating a windows service. There are lots of tutorials online. If you don't want to go that route, you could put your Sub Main in a module, set your hooks and load forms when needed.

About the hotkeys... Please someone correct me if I'm wrong. Because your form doesn't have focas there is no way to catch the keystrokes. You need to tap into the Windows API and set global hooks on the keystrokes you want to trap.

FYI, these are not very easy tasks to do.

Here's a nice article on hooking the keyboard...
http://www.developer.com/net/net/article.php/2193301
 
Last edited:
to create a windows service using vb.net 2003 u can do

the following..
1.create a project of type"windows service"(u can find

it at the bottom of project template window)
2.override the following events provided by the service
with ur custom code..(Start,Stop,Continue)
3.ones u finished install the service using

"InstallUtil.exe"..
eg:InstallUtil<Ur ProjectPath>\Bin\Urservice.exe
 
Windows service is the wrong choice for me. I have read that Windows Vistas' Windows Services won't support any GUI at all. I have forms, many forms. This is definately a windows application. The thing is I want it to lay dorment until certain events take place.

I have hooked the keyboard as well to use the hotkeys.. For now I have a default form that is totally invisible always and it hosts the rest of the project. But thanks for the help anyways. A windows service also runs at startup and I want this to run seperately for each user on login. Thanks again though. I think a windows service could work but is probably not the right choice for what I am doing.
 
Last edited:
How is this even possible?

I have read that Windows Vista won't support any GUI at all
I bet MS is going to make us buy all kinds of telepathic devices now. :rolleyes:


You could just set the form state to minumized and set the ShowInTaskBar to false. Try playing with me.hide, me.visible. Anything is better than an infinate loop.
 
O yes. Basically I made a form that has no borders and no controls and is not shown in the taskbar then made it's color a transparency color so it never shows anywhere. Then this form is hosting the rest of the application. I definately have strayed from the infinite loop after seeing the results the first time.


O, and lol. To correct my first post I meant that windows vistas' windows services won't support GUI (or so I read).
 
Back
Top