You can use the following methods to debug your service.
·Many debuggers allow you to debug a running service. First, obtain the process identifier (PID) of the service process. This information is available from the PView application. After you have obtained the PID, attach to the running process. For syntax information, see the documentation included with your debugger.
·Call the DebugBreak function to invoke the debugger for just-in-time debugging.
·Windows NT also allows you to specify a debugger to use when starting a program. Create a key called Image File Execution Options in the following registry location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
Create a subkey with the same name as your service (for example, MYSERV.EXE). To this subkey, add a value of type REG_SZ, named Debugger. Use the full path to the debugger as the string value. In the Services control panel applet, select your service, click Startup and check Allow Service to Interact with Desktop.
Note To debug the initialization code of an auto-start service, you will have to temporarily install and run the service as a demand-start service.