Testing the Application
Before you test the application, verify that you have successfully installed the Windows service you created earlier. Then press F5 in Visual Studio 2005. Try starting, pausing, and stopping the service to verify that the Windows service works.
With the Windows service running, you can perform the following steps to verify that the Windows service works as intended:
- Create a new Word document in C:\.
- Name it as Exam Questions.doc.
- Rename it as Test Questions.doc.
Now go to C:\
and open up the WordDocumentsHistory.txt
file. You should see something like this:
2/25/2007 10:30:49 PM: WordFilesMonitor Started
2/25/2007 10:30:57 PM: File Created : C:\New Microsoft Word Document.doc
2/25/2007 10:30:57 PM: File Changed : C:\WINDOWS\SHELLNEW\WINWORD8.DOC
2/25/2007 10:30:57 PM: File Changed : C:\New Microsoft Word Document.doc
2/25/2007 10:31:07 PM: File : C:\New Microsoft Word Document.doc renamed to C:\Exam Questions.doc
2/25/2007 10:31:07 PM: File Changed : C:\Exam Questions.doc
2/25/2007 10:31:24 PM: File : C:\Exam Questions.doc renamed to C:\Test Questions.doc
2/25/2007 10:31:24 PM: File Changed : C:\Test Questions.doc
2/25/2007 10:33:48 PM: File Deleted : C:\Test Questions.doc
2/25/2007 10:33:48 PM: File Created : C:\RECYCLER\S-1-5-21-790525478-1425521274-839522115-1003\Dc2398.doc
2/25/2007 10:33:48 PM: File Changed : C:\RECYCLER\S-1-5-21-790525478-1425521274-839522115-1003\Dc2398.doc
|Figure 9. The Task Bar: Showing the running application.|
This WordDocumentsHistory.txt log file keeps track of all the files activities (with .doc extension).
Also observe that when the application is running, it has an entry in the task bar, as shown in Figure 9). When it is minimized, the entry in the task bar remains.
But when you click the "x" button, the entry in the task bar is gone. To bring the application back up, you can either double-click on the notify icon in the System Tray, or right-click on it and select the Options… menu item.
With some creativity, you can now write some cool, new utilities using Visual Studio 2005. If you have some cool ideas on how to use Windows services, email me. I would like to hear them.