Development Platform: Win32
IDE: MS VisualStudio.NET Executable Platform: Windows NT/2000/XP/2003
General:
This application is used to create a Windows Service for applications that dont wish to get involved in programming the service stuff. You just need to create an executable that you want to be a service. Then install GenSvc.exe as a service. Using a service name that is the name of your executable. eg: myapp.exe will have service name of myapp. (If you want a GUI utitlity for installing services click here)
The service Setting should be as follows:-
ServiceName(name of service reg key): EXAMPLE:
ServiceName: notepad
DisplayName: My Notepad Service
ImagePath: C:/Windows/GenSvc.exe "C:Windows/notepad.exe" c:/Windows/setuplog.txt
This example will set notepad as a service and will open
setuplog.exe when run.
GenSvc.exe will then wait for your app to exit. If the service is stopped then it Sets a named event (with the name of the service) which your application can wait for. Then your app can exit cleanly without being terminated. The following code can be used in your app to wait for this named event. (you will need to use CreateThread to syncronously wait for this event so your app can continue executing).
Info links:
N/A
DWORD WINAPI WaitEventThread(LPVOID lpParam)
{
//get the service name
char szExe[MAX_PATH];
char *psname;
char *p;
GetModuleFilename(0,szExe,MAX_PATH);
psname = strrchr(szExe,);
psname++;
p = strrchr(psname,.);
*p=0;
//open the event
HANDLE hEvent;
hEvent = OpenEvent(EVENT_ALL_ACCESS,0,psname);
//wait for the event to signal
WaitForSingleObject(hEvent,INFINITE);
//close event
CloseEvent(hEvent);
// NOW YOU SHOULD NOTIFY THE REST OF YOU APP TO
// CLEAN UP AND EXIT WITHIN ONE SECOND //
// OR YOUR APPLICATION WILL BE TERMINATED //
return 1;
}
ScreenShot:
N/A












