1. | How can you best describe a Windows service application?
|
|
2. | Windows services begin running:
|
|
3. | How can you view information about the services running on a specific computer?
|
|
4. | Your Windows service needs to read some default values from a disk file every time it is started. How can you accomplish this?
|
|
5. | All Windows service applications support the same basic interface, because:
|
|
6. | If you leave the AutoLog property set to the default value of True in your Windows service. what behavior will you see when the service is running?
|
|
7. | You create a Windows service project that includes two Windows services. When you add installer components to your project, how many objects will be added?
|
|
8. | You need to specify the security account that your Windows service will run under. How can you specify this while creating the project in Visual Studio .NET?
|
|
9. | What is the most commonly used security account for running Windows services?
|
|
10. | You have created a Windows service application and you would like to use the debugging tools in Visual Studio .NET to troubleshoot a problem with the application. You load the application in Visual Studio .NET. What should you do next?
|
|
11. | You need to create an application that is able programmatically to start and stop a Windows service. Which .NET Framework class should you use?
|
|
12. | You are creating an application that controls a Windows service programmatically. You would like to be able to call the Pause method to temporarily disable the service while your application is running, but this does not seem to be working. What can you do to overcome this problem?
|
|
13. | You have created an application that is able to programmatically start and stop a Windows service. However, after using the Start method, your application always reports back that the service’s status is StartPending rather than the Running status that you are looking for. How can you be sure that the service has successfully been started and is running, before your application takes any further action?
|
|
14. | You need to create an application that is able to programmatically execute custom commands of a Windows service. How do you call custom commands from your application?
|
|
15. | What does the OnPowerEvent method of the ServiceBase class do?
|
|
Answers
1. | B A Windows service runs in its own memory process space and has its own security account, most commonly LocalSystem. A Windows service does not interfere with other users or programs running on the computer. |
2. | A If the service’s StartUpType property is set to Automatic, the service will be started when the computer is started or rebooted. If the StartUpType property is set to Manual, then the service must be started by using either the Service Control Manager console or by application code that uses a ServiceController object. |
3. | D You can view information about Windows services by using either the Windows Service Control Manager console or the Visual Studio .NET Server Explorer. The GetServices and GetDevices methods of the ServiceController class also provide information about the services that are running on a specific computer. |
4. | A The OnStart method is the recommended place to put code that should run when a service is started. Code in the constructor, Sub New, might not run when a service is stopped and restarted. |
5. | D To create an application that will run as a Windows service in Visual Studio .NET, you must inherit base class functionality from the System.ServiceProcess.ServiceBase class. |
6. | B If the AutoLog property of a Windows service application is set to True, Stop, Start, Pause, and Continue events will be written to the Windows Application event log without any further coding necessary. |
7. | C A Windows service project in Visual Studio .NET can contain more than one Windows service component class module. When you add installers to the project, one ServiceInstaller object will be added, and one ServiceProcessInstaller object will be added for each Windows service module contained in the project. |
8. | B Use the Account property of the ServiceProcessInstaller object to specify which security account the service should run under. |
9. | B LocalSystem is currently the most commonly used security account for running Windows service applications. It is a highly privileged account, which can pose a security risk. The new Windows XP accounts, NetworkService and LocalService, might be better choices from a security standpoint. |
10. | C To debug a Windows service application, you must install and run it. After it is running, you can attach the Visual Studio .NET debugger to this external process. Use the Debug Ø Processes menu choice to display the Processes dialog box to choose from all running processes on the computer. |
11. | B The System.ServiceProcess.ServiceController .NET Framework class has properties and methods that enable you to get information about a Windows service and to control the service through application code. |
12. | D The original creator of the Windows service application sets the CanStop and CanPauseAndContinue properties of the service. The original designer might not want the service to be stopped or paused by a user, as is often the case with operating system services. |
13. | C The WaitforStatus method of the ServiceController class will cause application code to block until the desired status is reached. |
14. | D To call a custom command from an application that can control Windows services programmatically, use the ServiceController.ExecuteCommand method. This method takes a single integer parameter, which indicates the command that the user would like to run. Valid parameter values are defined by the designer of the Windows service application (within the range of 128 to 256). |
15. | C The OnPowerEvent method is intended to be used if your service must run on laptop computers. You might want to save data, for example, before the computer goes into suspended mode. |