Get service run-time parameters

Posted on 2006-04-03
Last Modified: 2010-04-07
Dear Experts,

I have developed a Windows NT Service in VB using the NTSVCOCX control from MSDN. I now need to develop an application that can communicate with the service and allow me to change the service's run-time parameters in real time as well as view various statistics on the service. The service is implemented as an in-process DLL and it exposes various properties and methods to the host application. How best can I implement this?

NOTE: The services processes data in a database. Users capture data into the database, and the service checks for new information in one of the tables. Once there is new information in the table, the service sends an SMS to the Admin via a GSM modem. If the database connection is dropped, the service also notifies the Admin. Now I need to develop an application that should communicate with the service and shows the service's realtime statistics and configurations.
Question by:bmatumbura
    LVL 41

    Accepted Solution

    Ouch, that might be hard to do, let me explain...

    Services are multithreaded applications... with at least 2 threads.  VB doesn't natively support multi-threading (hince the need for the OCX control)

    The OCX control doesn't provide the full functionality of a "native" service, just the bare-bones parts to make it "service-compliant".

    By design, services do NOT expose properties and methods to the host application... instead you'd use the Service Control Manager to "talk" to the service.

    Any serious communication between a host application and the service would be require a communication channel (shared memory, sockets, etc)

    However, you might be able to communicate with your service via the shared database...  where you pass command to the service via a table entry, the service removes the commands from the table and performs that command, etc.   The service would just poll that table for new commands.

    BTW:  This would be much easier with VB.Net (if that's an option).
    LVL 11

    Author Comment

    Since I have no options, let me do it the socket way so I can even run the application from another PC.
    LVL 41

    Expert Comment

    Yep, that's the "normal" way to communicate with a service.

    One more thing... since your service (or perhaps a host program?) will be sending email (or SMS) it obviously needs access to the network.  Make sure the service is running under the context of a user that has network access.  By default, services are run with LocalSystem account which doesn't have valid credentials for networking.
    LVL 11

    Author Comment

    Thanks Graye,

    This would have caused me a lot of problems.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now