home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / winnt / service / readme.txt < prev    next >
Text File  |  1996-07-05  |  3KB  |  92 lines

  1. Simple Service
  2.  
  3.  
  4. SUMMARY
  5. =======
  6.  
  7. The SERVICE sample demonstrates how to create and install a service.
  8.  
  9. In this particular sample, the service merely opens a named pipe (the name 
  10. defaults to \\.\pipe\simple) and waits for read and write operations to the 
  11. pipe. If the pipe receives input, it creates the string:
  12.  
  13.     Hello! [<input goes here>]
  14.  
  15. and sends it back to the client through the pipe.
  16.  
  17. The service can be started and stopped from the control panel Services 
  18. applet, the net command, or by using the service controller utility (see 
  19. MORE INFORMATION).
  20.  
  21. The service also provides command-line parameters which install, remove, or 
  22. run (debug) the service as a console application.
  23.  
  24. MORE INFORMATION
  25. ================
  26.  
  27. To aid in writing and debugging services, the SDK contains a utility
  28. (MSTOOLS\BIN\SC.EXE) that can be used to control, configure, or obtain 
  29. service status. SC displays complete status for any service in the service 
  30. database, and allows any of the configuration parameters to be easily 
  31. changed at the command line. For more information on SC.EXE, type SC at the 
  32. command line.
  33.  
  34. Usage:
  35.  
  36. To install the service, first compile everything, and then type:
  37.  
  38.     simple -install
  39.  
  40. Now, let's look at SC's command-line parameters:
  41.  
  42.     sc
  43.  
  44. To start the service, use the "net start" command, the control panel 
  45. Services applet, or the command:
  46.  
  47.     sc start simpleservice
  48.  
  49. Verify that the service has entered the RUNNING state:
  50.  
  51.     sc query simpleservice
  52.  
  53. Once the service has been started, you can use the CLIENT program to verify 
  54. that it really is working, using the syntax:
  55.  
  56.     client 
  57.  
  58. which should return the response:
  59.  
  60.     Hello! [World]
  61.  
  62. If, after playing with the sample, you wish to remove the service, simply 
  63. say:
  64.  
  65.     simple -remove
  66.  
  67. You may change the name of the pipe by specifying -pipe <pipename> as a 
  68. startup parameter for both CLIENT and SIMPLE. The string passed in by CLIENT 
  69. can be changed by specifying -string <string>.
  70.  
  71. Notes:
  72.  
  73. 1) The use of the SERVICE.H header file and the accompanying SERVICE.C file 
  74. simplifies the process of writing a service. You as a developer simply need 
  75. to follow the TODO's outlined in the header file, and implement the 
  76. ServiceStart and ServiceStop functions for your service.
  77.  
  78. There is no need to modify the code in SERVICE.C. Just add SERVICE.C to your 
  79. project and link with the following libraries:
  80.  
  81.     libcmt.lib 
  82.     kernel32.lib 
  83.     advapi.lib 
  84.     shell32.lib
  85.  
  86. 2) Install/Remove functionality should not be included in a production service.  
  87. The functionality is included in this service for illustration purposes, and as 
  88. a convenience to developers.
  89.  
  90.  
  91.  
  92.