Article ID: 199060
Article Last Modified on 12/11/2003
APPLIES TO
- Microsoft ActiveX Template Library 2.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft ActiveX Template Library 3.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
This article was previously published under Q199060
SYMPTOMS
Using the ATL COM AppWizard to generate an NT service may not produce code that behaves as expected. When the AppWizard-generated service is started as a local server, the message strings passed to CServiceModule::LogEvent() are not displayed to the console. When started as a service, the messages are logged into the applications' event log.
CAUSE
In the generated code CServiceModule::LogEvent() calls _putts() in to write the message to stdout, but stdout is not setup by default.
RESOLUTION
To remedy this behavior, the developer should do one of the following:
-
Edit CServiceModule::Start() to initialize stdout as desired (that is, redirect it either to a console or to a file). The code to do this is in the More Information section below.
-
Replace _putts() with ATLTRACE().
-
Redirecting the output of the application to a file, in a console window. For example:
MyApp.exe > output.txt
-
In CServiceModule::LogEvent(), remove the "if" statement and _putts() statement, so that the output always goes to the application log file.
Keywords: kbservice kbprb KB199060