CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Join Date
    Aug 2002
    Posts
    63

    Lightbulb windows service application

    can somebody let me know how to create a windows service application in visualbasic 6.0

  2. #2
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    It is more than well explained there, providing a usefull OCX and sample

    http://msdn.microsoft.com/library/de...n_ntsrvocx.asp

    Edit: Correct link : http://msdn.microsoft.com/archive/de...n_ntsrvocx.asp
    Last edited by JeffB; June 14th, 2004 at 11:15 PM.

  3. #3
    Join Date
    Aug 2002
    Posts
    63
    Originally posted by JeffB
    It is more than well explained there, providing a usefull OCX and sample

    http://msdn.microsoft.com/library/de...n_ntsrvocx.asp
    Thanks Jeff,But i wanted some code where i could start coding in vb 6.0,i want to know if i have to reference any dll to code or what ???

  4. #4
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    actually, if you use the OCX I provide you, you will have to add this OCX and use it to code, the code will be much simpler than to use API, if you don't want to use it, you don't need to add any references, except that you will have to use the APIS, StartService, OpenSCManager, StopService, GetServiceDisplayName, OpenService, etc.. Each time you use a API, you need to add the API declarations and some time, a structure used with the API (that case, there is a SERVICE_STATUS structure you may need). There is no object provided with VisualBasic to create a service, the OCX I show you is the one Microsoft Distribute, but you can find other on the market (Desaware NT Service ToolKit), but they cost money.

    for more informations on API:

    http://www.vbapi.com
    http://www.allapi.net

    JeffB

  5. #5
    Join Date
    Aug 2002
    Posts
    63

    Thumbs up

    Originally posted by JeffB
    actually, if you use the OCX I provide you, you will have to add this OCX and use it to code, the code will be much simpler than to use API, if you don't want to use it, you don't need to add any references, except that you will have to use the APIS, StartService, OpenSCManager, StopService, GetServiceDisplayName, OpenService, etc.. Each time you use a API, you need to add the API declarations and some time, a structure used with the API (that case, there is a SERVICE_STATUS structure you may need). There is no object provided with VisualBasic to create a service, the OCX I show you is the one Microsoft Distribute, but you can find other on the market (Desaware NT Service ToolKit), but they cost money.

    for more informations on API:

    http://www.vbapi.com
    http://www.allapi.net

    JeffB
    Hey Jeff,

    Thanks a lot for the info,Actually i could not download that sample code you were talking about.I could now,Jeff I am not a VC++ guy,so tell me is that ocx created in vc++ so what should i do to add it in vb program

    Bye

  6. #6
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    the OCX is created in Visual C++, but you don't need to do that, you only add the OCX in your project on your form, like the way you add and use a CommonDialog object. in the downlaod is include the compiled OCX, the source C++ code and a sample in VB (with code and properly working). To add a OCX, on your form, do Add Composants, browse and go search for the OCX, an icon will be added to your toolbar, select it and put it on your form, the default name will be NTService1, you will see all his property, and you can use Object Explorer to look property, const and method

    JeffB - hope it helps

  7. #7
    Join Date
    Aug 2002
    Posts
    63

    Thumbs up

    Originally posted by JeffB
    the OCX is created in Visual C++, but you don't need to do that, you only add the OCX in your project on your form, like the way you add and use a CommonDialog object. in the downlaod is include the compiled OCX, the source C++ code and a sample in VB (with code and properly working). To add a OCX, on your form, do Add Composants, browse and go search for the OCX, an icon will be added to your toolbar, select it and put it on your form, the default name will be NTService1, you will see all his property, and you can use Object Explorer to look property, const and method

    JeffB - hope it helps
    Hi Jeff,

    I am working on it,I will get back when i have some problem,hopefully i wont have any.I have to create my own service which queries database and sends a response when the condition matches.
    If you have any suggestion ,do reply.

    Thanks.

  8. #8
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    here is the sample plus OCX:

    JeffB
    Attached Files Attached Files

  9. #9
    Join Date
    Aug 2002
    Posts
    63

    Thumbs up

    Originally posted by JeffB
    here is the sample plus OCX:

    JeffB
    hi jeff,

    everything fine,but i am not able to see it in services.how to run it.
    i think it is not entering this statement "If Command = "-install" Then"
    do i have to set anything before i run my exe.

    thanks

  10. #10
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    The first time you run it you must pass -install as a commandline parameter to install it as a service. Your command line should look like

    YouServiceName.exe -install

  11. #11
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    Yeah, before running a service, it must be installed on the computer, Configuration Pannel -> Service, and you need administrator right to install / uninstall it, you can look the service already installed on your computer with regedit:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

    You might also want your service to use an NT account and his password, because your service will be running even if no one is logged, so if you use ADO (for example), you absolutely need registry key, and when no user is connected, no registry, error and, because a service, you don't know when it is bugged (except if you use custom log or the NTService logevent that write to NT log)

    JeffB

  12. #12
    Join Date
    Aug 2002
    Posts
    63

    Thumbs up

    Originally posted by DSJ
    The first time you run it you must pass -install as a commandline parameter to install it as a service. Your command line should look like

    YouServiceName.exe -install
    hi dsj,

    my serive exe is called "sample.exe"
    so i have to give 'sample.exe -install' in the command prompt isn't ?
    or do i have to give the path where it recides.
    I dont get exactly what you are saying,when i type that in my command prompt it gives an error saying "command not recognised"
    could you be a little more specific.
    Or is there anything else i have to do.

    thanks

  13. #13
    Join Date
    Aug 2002
    Posts
    63
    Originally posted by JeffB
    Yeah, before running a service, it must be installed on the computer, Configuration Pannel -> Service, and you need administrator right to install / uninstall it, you can look the service already installed on your computer with regedit:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services

    You might also want your service to use an NT account and his password, because your service will be running even if no one is logged, so if you use ADO (for example), you absolutely need registry key, and when no user is connected, no registry, error and, because a service, you don't know when it is bugged (except if you use custom log or the NTService logevent that write to NT log)

    JeffB
    hi jeff,

    hi dsj,

    my serive exe is called "sample.exe"
    so i have to give 'sample.exe -install' in the command prompt isn't ?
    or do i have to give the path where it recides.
    I dont get exactly how and what you are saying,when i type that in my command prompt it gives an error saying "command not recognised"
    could you be a little more specific.
    Or is there anything else i have to do.


    thanks

  14. #14
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923
    There's three way to do it:

    >First, compile your EXE with Visual Basic (create the EXE, not execute the program), after, go to MSDOS, browse your HardDisk by using cd.. and cd /NameFolder (or type C: to go to the root of your C Next, when it come to your EXE, type sample -install, it will look like C:\AppName\> sample -install

    >Second, go to StartMenu, go to Execute, on the little window, go to browse, select your EXE (sample.exe), add to the text that should be sample.exe " -install" so it will be writed in the textbox: "sample.exe -install"

    >Directly from VB, when you compile your code and execute it FROM VB, you can add command property, before running the app, go to -project/property of sample, then on the tab create, search for the textbox parameters of the command line (my version is in french, so the translate might be innaccurate ), then type -install

    >Because Service are a little special, your project will need a documentation, for any one that must install it on his computer, they must know to type -install, to have administrator rights and to type -uninstall (or whatever you want the parameters to be, I was using -i and -u)

    JeffB - hope it helps

  15. #15
    Join Date
    Aug 2002
    Posts
    63

    Thumbs up

    Originally posted by JeffB
    There's three way to do it:

    >First, compile your EXE with Visual Basic (create the EXE, not execute the program), after, go to MSDOS, browse your HardDisk by using cd.. and cd /NameFolder (or type C: to go to the root of your C Next, when it come to your EXE, type sample -install, it will look like C:\AppName\> sample -install

    >Second, go to StartMenu, go to Execute, on the little window, go to browse, select your EXE (sample.exe), add to the text that should be sample.exe " -install" so it will be writed in the textbox: "sample.exe -install"

    >Directly from VB, when you compile your code and execute it FROM VB, you can add command property, before running the app, go to -project/property of sample, then on the tab create, search for the textbox parameters of the command line (my version is in french, so the translate might be innaccurate ), then type -install

    >Because Service are a little special, your project will need a documentation, for any one that must install it on his computer, they must know to type -install, to have administrator rights and to type -uninstall (or whatever you want the parameters to be, I was using -i and -u)

    JeffB - hope it helps

    Hey Jeff,

    That was of great help.thanks a lot.Actually i have to query a database and perform certain actions...do you think i can do this ?
    I will give it a try on monday.
    Also if you have any idea about VB.NET:-My question is If i create a EXE in VB.NET and have to install in client systems,what are the minimum requirements for that client machine.

    Thanks.
    Have a great week end.

Page 1 of 2 12 LastLast

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

Featured