Disabling and Removing Items
Continued from Inside Startup Cop
As previously noted, Startup Cop uses the same technique as Windows 98 to disable start-up items. For Win.ini items, it moves the filename to a key named NoLoad= or NoRun=. For StartUp group items, it moves the shortcut to a folder named "Disabled StartUp Items." For Registry items, it moves the value to a Registry key whose name is the same as the original with a minus sign at the end--for example, HKEY_LOCAL_MACHINE-\SOFTWARE-\Microsoft-\ Windows-\CurrentVersion-\Run-.
To pack an item for removal, Startup Cop does almost the same thing. Win.ini items are moved to keys named RemLoad= or RemRun=. StartUp group shortcuts are moved to a folder named "Startup Cop Removals." Registry items are moved to a key whose name has an X appended to it. These locations are specific to Startup Cop, and Windows 98 ignores them.
Because permanent deletion of a start-up item can cause system problems, Startup Cop disables the item and forces the user to restart Windows before it will allow the item's actual deletion. If the item's absence causes a problem, it will be evident when Windows restarts; if not, it should be okay to delete the item. The challenge for Startup Cop is to distinguish between items marked for removal during the previous Windows session versus those marked during the current session.
The first time Startup Cop is launched after a Windows restart, it examines the locations that define items packed for removal and records the names of any items found there in a section named [Removals] in Startcop.ini. Thereafter, each time Startup Cop reads the list of start-up items, it checks any that are packed for removal to see if they're found in the [Removals] section. If so, it promotes them to "tested and ready" status, represented by a red light with a question mark on it.
How can Startup Cop identify the first time it's run after a Windows restart? It calls the API function GlobalFindAtom() to check the global atom table for an atom corresponding to the string "PC Magazine Startup Cop First Time". The first time Startup Cop is launched during a given Windows session, this atom will not be present. In that case, Startup Cop clears the [Removals] section, writes the list of items that are packed for removal, and calls GlobalAddAtom() to create an atom corresponding to that string.
The global atom table is independent of any particular program. Atoms added to it remain there until explicitly deleted using GlobalDeleteAtom(), or until the Windows session ends. Even logging out the current user and logging in again doesn't destroy them. Thus, if Startup Cop finds the specified atom, it means that there has not been a full Windows restart since the last time Startup Cop was launched.
Published in the 4/20/99 issue of PC Magazine.