I try to use the NT service framework class v. 1.75 on a new console application and have followed every steps include all the necessary files and rc and project settings.
The service is created and started. However, I can't view the event being log in the event viewer. It is giving me a message that said
The description for Event ID ( 1 ) in Source (Service ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: Service.
This could be a windows security issue. Are the files you are trying to delete located on a remote file share. If so you must remember that a service using the "LocalSystem" account by default does not have any network credentials. You will need to configure your service to use alternate credentials
I got attention to your CNTService... wrapper classes and i thought it will be usefull to my application. Before this i was using XYNTService to start my program. The problem here is My App. needs to disable Task Manager. i do this
by setting the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr
Well i am not able to do this anymore as the service runs in a 'Local System'
Is it possible to programatically tell the service to run in an User A/c providing User's logon information.
Great package, I am using it all the time for several projects.
Most are small services that open run database functions on a daily bases. I looked under task manager and these take nearly 2mb of memory. I have a couple of these running on Win2K machines and these machines are struggling from memory usage.
I am using Microsoft Visual C++ .NET 7.1.3088 and I would like to reduce the size of these bad boys!
I've got an existing app that uses Windows for message posting (the windows are always hidden from the user). My understanding is that this is not a problem in a service (the hidden windows still work in the service).
My question is how do I get the app to startup correctly? Currently, I've got the "CWinApp::InitInstance" returning TRUE to start the main frame message pump. But, how do I get the "ServiceMain" to run also?
Do I need to start another thread for the ServiceMain?
Sorry, but some methods is not rigths.
BOOL CNTScmService::AcceptPauseContinue(BOOL& bPauseContinue)
ASSERT(m_hService != NULL);
BOOL bSuccess = QueryStatus(&ServiceStatus);
if (bSuccess) bPauseContinue = (ServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE != 0);
TRACE(_T("Failed in call to QueryStatus in AcceptPauseContinue, GetLastError:%d\n"), ::GetLastError());
I think you meen:
bPauseContinue = ((ServiceStatus.dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) != 0);
But in c and c++ priority "!=" > priority "&"
And In your case:
1) (SERVICE_ACCEPT_PAUSE_CONTINUE != 0) = TRUE = 0x01
2) (ServiceStatus.dwControlsAccepted & 0x01) - analyse always only one right bit
VS2005 flags this (actually three instances) as a warning. Scoping the comparison as you described resolves the warnings.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
I need to create a service for Windows version 2000 and above. Would CNT service not work for those versions? If it wouldn't work, please let me know how I can create a service for these versions if you know.
The SDK function you want is StartService or the wrapping of it in my framework which is CNTScmService::Start. If you prefer a more higher level approach to controlling a service, also check out CNTService::SetServiceToStatus. If you prefer a command line approach you can use the built in Windows "NET START" command, or alternatively have a look at the /start command line support also provided by my framework.
I have the latest 1.69 version. And also I have unicode bug too. This bug seem to appear when we launch "TestSrv.exe -install" in Unicode environment (both unicode and release). ASSERT gives us I message "Buffer's too small". I debugged this fine code (naturally fine: I have the same style of coding ).
Search this piece of code in ntservEventLogSource.cpp file
#if (_MSC_VER >= 1400)
_tcscpy_s(&lpszString[nCurOffset], (nCurrentStringLength+1)*sizeof(TCHAR), sText); // here the author made a spell mistake: he put '\' instead of '*'. Late night programming practice? ;)
OK, Will review all the VC2005 safe string calls in the current version and update my web site with a fix over the next few days. Best to always directly email me with any bugs you spot as you will get a reply quicker!
Just to let you know that v1.70 is on my web site to fix this issue (along with another _tcscpy_s issue in one of the other modules). Yes it was a late night of coding which produced this problem . Is is just me or will the new VC 2005 safe string introduce as many problems as they are trying to solve. IMHO, I think depcrecating the standard C functions by default was a touch heavy handed
Will someone please explain why Log Message descriptions in the "Event Viewer" are only available when the service is "loaded" - is this normal behaviour ?
When the the service is not "loaded" I get ...
"The description for Event ID ( 3 ) in Source ( PJ's Demo NT Service ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: PJ's Demo NT Service.".
Im not sure what you mean 'service is loaded' - but it shouldnt matter - the issue would appear to be the message dll not being registered correctly/in the correct location as pointed to by the registry
I went back and had a look - once the test service is installed (is that what you meant by loaded ?) the message source exists, but not before then - thats because the message resources are in the service exe - thats one way of doing it - the other is to have a seperate dll as a message source - there are pros and cons to each