Results 1 to 11 of 11

Thread: Windows Service: GUI to Control Service...

  1. #1

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551

    Windows Service: GUI to Control Service...

    hey guys,

    With VB.NET, making windows services seems to be extremely easy! However, I'm in need of more than the basic windows service.... I really need to make a gui for my windows service, but i'm not sure what the proper way to do this is....


    let me first explain my program. It is basically a tcp/ip server (for a business messaging program i've made). I started making the server program in a normal windows application project, and then i recently decided i should change it into a windows service.

    So, in my program, i currently have a nice form that handles the gui. This form displays information on the status of the application (number of connected users, uptime, server notifications, etc). and it also controls options on the server in realtime (like IP Connection Masking, maximum connections, etc.).


    This leads me to how to make the GUI... what is the proper way? Should i make a whole different application apart from the service? (doing this only seems to allow the application to start/stop/pause windows services, not actually interact with them in any more detail)...


    My guess is i need to add a windows form to the windows service project. If i do this, how do i implement the form? i really don't know how to do this... any help is appreciated... i haven't been able to find any good reading on this problem specifically..

    thanks guys!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I don't know if this is the best solution or not but you could remote an object from the service so that any applications could connect to it that way and handle the UI.

  3. #3
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    For the last few services I created, I just created a separate applications the "service administrator/manager utility". I found that it was just easier to work with that way and I could provided updates to the GUI or service, without having to edit the other, etc.

    You can't have GUIs (forms, message boxes, etc.) in your service, unless you check "allow service to interact with desktop" for that service.
    -Shurijo

  4. #4

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551
    Ok,

    So i will probably need to make a seperate program for my service. This is ok with me, my only question now then is how exactly do i interact with the windows service. Like i said, I need to be able to pull and push information to the service.

    The only logical thing i can think of right now is to interact via updating the settings XML file or something like that. Please share your thoughts on this idea:

    All server settings are stored in an XML file. I could have the Windows Service setup a file watcher on that Settings file, so that whenever the Settings file is changed, the service reloads all of the server settings from the settings file. Then, from the Admin Utitlity, it would be as simple as changing settings in that Settings file whenever Something needs to be changed.

    To Get information from the windows service i could do something similar. I could have a ServerStatus XML File, that whenever something changes in the server, the server status file is changed. On the Admin Utility i would then setup a file watcher on the status file. Whenever the status file changes, the file watcher will catch it and the admin utility will be updated from the status file.

    Obviously, this solution would work, and I think it would work just fine. The only thing i don't like about it is the second part of it. Using XML files in this manner is not the fastest solution. And the server status could be VERY frequently updated, so writing to and reading from an XML file every second or more often could be a bad thing. Can anyone suggest a better way to do this part of it? Perhaps some kind of IPC? I'm not sure if remoting is right for this or not, but I'm not sure i want to use remoting for this either :/

    Thanks so much for the help granted already, and whatever else you guys may contribute

  5. #5
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    (doing this only seems to allow the application to start/stop/pause windows services, not actually interact with them in any more detail)...

    How do you check for a service runing and restart and stop the service?

    Thanks

  6. #6
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    Originally posted by cgj

    How do you check for a service runing and restart and stop the service?

    Thanks
    http://www.vbforums.com/showthread.p...hreadid=246890
    -Shurijo

  7. #7
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    i have one problem,
    System.ServiceProcess
    is not working try it,

  8. #8
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    Works fine for me. Make sure you have it referenced and imported properly.

    Right click on References (in solution explorer),
    then choose "Add reference",
    then choose "System.ServiceProcesses".
    Next insert "Imports System.ServiceProcess" at the top of your class/module, etc.
    -Shurijo

  9. #9
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    Thanks Shurijo
    It works

    do you know how to check the status?
    thanks

  10. #10

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551
    I'd still like a bit more info on how i should attempt my situation. I've concluded that i can send the service information via Custom Command that Windows Services use.

    So now my only problem is sending stats of the service back to the Admin utility. Again, I don't think remoting is the best solution here, but rather i would think some kind of Inter-Process Communication would be appropriate. Anybody have ideas?

  11. #11
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Redth,

    I want to do the same thing with my service. How did all this end up?

    TIA,
    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width