Desaware Home
Products    Purchase    Publishing    Articles   Support    Company    Contact    
Support
Product FAQ
Licensing System
CC Factory
Event Log Toolkit
Gallimaufry
IniFile Tool-5M
LineGraph-5M
NT Service Toolkit
OneTime Download
SpyWorks
StateCoder
StorageTools
VBX Legacy
VersionStamper
Downloads
Documentation
Professional Services

 

bluebar
Contact Desaware and order today

bluebar
Sign up for Desaware's Newsletter for the latest news and tech tips.

NT Service Toolkit Support

Frequently Asked Questions - General

  1. I made some changes to my Service Configuration object and recompiled the Service DLL. But, when I run the Service, the changes I made were not applied to the Service.
  2. How do I access the Start Parameters?
  3. What is the dwLicGen6.exe (NT Service ActiveX Component re-distributable License Generator) utility used for? There is no documentation for it. (COM only)
  4. In what scenarios can the StopService function safely be used?
  5. The IdwEasyServConfig_GetDescription property does not seem to set the Service Description but the Service Name instead.
  6. Delaying NT from shutting down does not seem to work, I use the OnShutDown event to return a delay.
  7. How does the IdwEasyService_OnParamChange event work?
  8. What are the limitations of the NT Service Toolkit's service?
  9. How do I create a Control Panel Applet for the VS 2003 (or version 1.1) edition of .NET? The current Control Panel Applet Wizard only creates applets for VS 2002 (version 1.0).

1. I made some changes to my Service Configuration object and recompiled the Service DLL. But, when I run the Service, the changes I made were not applied to the Service.

When changing any of the Service Configuration settings in your Service DLL, in order for the changes to be reflected in the Service EXE, you must uninstall and install the EXE again. When you install the Service, it queries your Service DLL for the Service Configuration settings.


2. How do I access the Start Parameters?

We just added support for this feature that allows you to pass a Startup Parameter string to the NT Service. Run the NT Service Toolkit Files Update and download the latest type library and service template files. The new ControlObject.StartupParameters property contains the Startup Parameter string and can be accessed during OnStart or other Service events.

Before updating the files, make sure your NT Service DLL project is closed. After updating the NT Service Toolkit files, you can add code to access the startup parameters. You will also need to uninstall your Service, then recompile your Service DLL project, then your Service EXE, then install your Service EXE.

You can also contact Desaware and we can email you the latest files.


3. What is the dwLicGen6.exe (NT Service ActiveX Component re-distributable License Generator) utility used for? There is no documentation for it. (COM only)

This utility allows you to re-distribute some of the components included with the NT Service Toolkit as part of your components. The documentation for licensing components are missing from the NT Service Toolkit's manual and help file. The following link describes how to license the dwSock6.dll and dwbkthrd.dll components for distribution with your components.


4. In what scenario can the StopService function safely be used?

One situation for using the StopService function is when a service fails to initialize properly in OnStart. The appropriate thing to do is to write information to the event log and then call ControlObject.StopService.

The reason StopService is discouraged in general is twofold:

  1. Services are supposed to be started and stopped by the system/SCM.
  2. If a service that's supporting client objects stops, those clients will get COM automation errors.

However, StopService does perform a proper cleanup and correctly notifies the system that the service has stopped. So it's safe to use for this kind of situation.


5. I set the IdwEasyServConfig_GetDescription function and I see the description on NT 4.0, but on Windows 2000, it appears as the Service's name and the Service's description field is blank.

NT 4.0 does not support a Service's description, only the Service's name. Windows 2000 supports both name and description.

On the current version of the toolkit the new IdwEasyServConfig_GetDescription function can now hold both the Service's name and description. The name and description are separated by a vbnullchar, the first part of the string contains the service name and the second part contains the service description. For example:

IdwEasyServConfig_GetDescription = "Service Name" & vbNullChar & "Service Description"

will display both the Service name and description in Windows 2000, but will only display the Service name in Windows NT 4.0.

If you do not wish to display a service description, you can just specify the service name without appending a vbNullChar to the end of the function (in other words, you do not need to make any changes).

Before updating the files, make sure your NT Service DLL project is closed. After updating the NT files, you need to uninstall your Service, then recompile your Service DLL project, then your Service EXE, then install your Service EXE.


6. Delaying Windows from shutting down does not seem to work, I use the OnShutDown event to return a delay but the system does not wait before shutting down.

First, be sure you have the latest version of the toolkit. You can run the NT Files Update utility to retrieve the latest dwntserv.svt file, then rebuild your Service EXE to fix this problem. Another reason that this may not work is if you set a delay greater than 20 seconds. Microsoft's documentation states that there is an extremely limited time (about 20 seconds) available for service shutdown. After this time expires, system shutdown proceeds regardless of whether service shutdown is complete. Therefore, be sure your cleanup code can finish within 20 seconds.


7. How does the IdwEasyService_OnParamChange event work?

This is surely one of the most poorly documented features in Microsoft's documentation, and ours isn't much better.

To make this feature work, you must do the following:

In your service: In your ServiceConfiguration class, add svcParamChange to the list of controls accepted by the service. For example:

IdwEasyServConfig_ControlsAccepted = svcPauseAndContinue Or svcShutdown Or svcStop Or svcParamChange

Sending the Parameter Change Notification

As far as we can determine, the system never automatically sends a parameter change notification. Thus, the only way to send this notification is for you to do it yourself. For example: if you change a registry setting where you are storing parameters, or change a data file where you are storing parameters, it is up to you to also send the parameter change notification. This can be done by modifying the control panel sample application with the following changes:

When you call OpenService, be sure to request the SERVICE_PAUSE_CONTINUE exactly as shown here:

hService = OpenService(scHandle, "dwEasyServ", SERVICE_USER_DEFINED_CONTROL Or SERVICE_INTERROGATE Or SERVICE_PAUSE_CONTINUE)

Define the following constant:

Public Const SERVICE_CONTROL_PARAMCHANGE = 6

Use the ControlService function to send the parameter change notification thus:

Debug.Print ControlService(hService, SERVICE_CONTROL_PARAMCHANGE, sv)

What your service does when it receives this event is up to you. Presumably, you should reload any startup parameters that you have stored from wherever you stored them. But it's your responsibility to handle this event in whatever way you see fit.


8. Your advertising says services created with this toolkit can do almost everything a C++ service can do. What are the limitations?

There are some limitations in the current version that either follow from the nature of Visual Basic or represent areas for improvement in future versions. Here are the ones we are aware of at this time:

  • VB6 IDE debugging with DCOM. While you can debug your service using the VB6 IDE and test it with clients creating COM objects on a local system, your service must be compiled to test it with client requests coming in via DCOM.
  • VB6 IDE debugging and thread specific APIs. Any API function that uses a thread specific handle or reference cannot be debugged correctly in the VB IDE since a VB DLL runs in a separate process when being debugged in this mode. This is true for any VB DLL - not just those created for this toolkit. Note that the toolkit will correctly handle automatic duplication of synchronization objects when used for wait operations.
  • Only registry based security supported. DCOM server and client security must be set using the DCOMCNFG program. Programmatic security is not supported at this time.
  • Client threading. The toolkit uses a fixed thread pool to handle client objects. Future versions will include a thread per object capability.

The VB6 App.LogEvent method and some Printers object methods do not work within DLL's made with this toolkit. Use the framework report event functionality to report events (or the Desaware Event Log Toolkit). API printing and printing through external ActiveX EXE components are supported. Problems with these objects started with the 1.1 release and as far as we can tell are problems in VB that were exposed when we changed the threading model slightly to make the service toolkit support calling single threaded COM components.


9. How do I create a Control Panel Applet for the VS 2003 (or version 1.1) edition of .NET? The current Control Panel Applet Wizard only creates applets for VS 2002 (version 1.0).

Run the NT Service Toolkit or SpyWorks Files Auto Update utility to download the latest Control Panel Applet Wizard (CPLWizardNET.exe) and the VS 2003 control panel applet template file (dwcplNet11.svt) to the same folder as your current Control Panel Applet Wizard. The new Control Panel Applet Wizard includes an option to compile the applet for either .NET VS 2002 or VS 2003.

 

 


 
Products    Purchase    Articles    Support    Company    Contact
Copyright© 2012 Desaware, Inc. All Rights Reserved.    Privacy Policy