Before reading this article, you 'd better take a look at it first.. NET Compact framework BASICS (1)This articleArticle.
What we want to talk about today is an extension in the above section. In this article, we will mention the systemstate class.
This class is mainly used to collect and monitor many status information of the system.
Today, we will introduce another feature. When the monitoring conditions are met, start the application.Program.
Why? For example, if you set a monitoring rule and let the system handle it by yourself, once the condition is triggered, the corresponding program will be called immediately.
Scenario: When I receive 100 unread messages, I immediately delete the read messages in my inbox.
The following describes how to use this method.
Create a systemstate class to tell it what to monitor
1 Private Systemstate state;
2
3 Private Void Form1_load ( Object Sender, eventargs E)
4 {
5 // Number of unread SMS messages
6 State = New Systemstate (systemproperty. messagingsmsunread );
7 // Comparison Method
8 State. comparisontype = Statuscomparisontype. Greater;
9 // Comparison Value
10 State. comparisonvalue = 100 ;
11 }
Start System Monitoring:
1 Private Void Menuitem3_click ( Object Sender, eventargs E)
2 {
3 // Tell it applicationid. You can also add the path to start the application.
4 State. enableapplicationlauncher ( " Devautostartdemo " );
5 }
Cancel System Monitoring:
1 Private Void Menuitem4_click ( Object Sender, eventargs E)
2 {
3 State. disableapplicationlauncher ();
4 }
Once the system monitoring is started[HKEY_LOCAL_MACHINE \ SYSTEM \ notifications].
This directory records key values to describe the application path.
See the following results:
Start the program, enable is start, disable is cancel
Close the program and check the number of unread messages in the current system.
No unread text message. Check the registry.
The Registry has been inserted into this directory, indicating that the system monitoring has been registered.
Send a text message to test the effect.
Indicates that the program has been triggered.
CodeDownload:Devautostartdemo.rar
Author: appleseeker
Date: 2008-09-21