|Products Purchase Publishing Articles Support Company Contact|
support > Product FAQ > NT Service Toolkit > General
Event Log Toolkit
NT Service Toolkit
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.
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:
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:
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.
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