// Monitor HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run item # include <windows. h> // define a function for monitoring Registry Startup items, int Reg () {handle hnotify; hkey hkeyx; // DWORD dwres; hnotify = createevent (null, // The security_attributes structure is not used false, // true is not automatically reset, // The initial state "registrypolicy" // The Name Of The event object); If (hpolicy = 0) {MessageBox (null, "createevent failed", "", mb_ OK); exitprocess (0);} If (regopenkeyex (HKEY_LOCAL_MACHINE ,// Root Key "Software \ Microsoft \ Windows \ CurrentVersion \ Run", // sub-Key 0, // reserved key_policy, // Monitoring & hkeyx // Save the handle )! = Error_success) {closehandle (hsf-y); MessageBox (null, "regopenkeyex failed", "", mb_ OK); exitprocess (0);} If (regpolicychangekeyvalue (hkeyx, // monitor the sub-key handle true, // monitor the sub-key of this item reg_policy_change_name | reg_policy_change_last_set, // monitor whether the Sub-key is added or deleted, and whether the monitoring key value changes hnotify, // accept the event object handle of the registry change event true // report before registry change )! = Error_success) {closehandle (hnotify); regclosekey (hkeyx); MessageBox (null, "regpolicychangekeyvalue failed", "", mb_ OK); exitprocess (0 );} if (waitforsingleobject (hsf-y, infinite )! = Wait_failed) {MessageBox (null, "Registry changed", "", mb_ OK);} closehandle (hnotify); regclosekey (hkeyx); Return 0;} void main () {// dword id; // createthread (null, 0, (lpthread_start_routine) reg, null, 0, & ID ); // create thread // printf ("OK \ n"); Reg ();}