Partager via


Developing for the Control Panel

Developing for the Control Panel-Windows Vista

Control Panel allows users to configure operating system features and perform related tasks such as hardware and software setup and configuration, security, system maintenance, and user account management. Many users do not perform Control Panel tasks frequently, so they may not remember how to begin, perform or complete these tasks. Control Panel has lots of control panel items, so some users have difficulty knowing which tasks to perform with which applets.

Microsoft Windows Vista® provides a visually enhanced and better-organized user interface that alleviates these problems and makes the Control Panel easier to use. Windows Vista also makes it easier for developers to add their own applets and tasks to the Control Panel.

Microsoft Windows Vista provides new features that make Control Panel more user-oriented. The new features in Windows Vista Control Panel include:

  • A fast search that allows users to quickly find applets and tasks from anywhere in Control Panel

  • A more enhanced Control Panel Home (similar to the category view in Windows XP) that makes browsing easier

  • Tasks Links that allow users to easily find tasks associated with each applet

  • An easy way for software developers to add and register their own applets and tasks to Control Panel

  • A new syntax for opening Control Panel applets programmatically

This article highlights the new features that may be of interest to software developers and only summarizes the new search and Task Link features. For detailed information on the search and Task Link features, see Control Panel User Interface.

Searching for Applets and Tasks Is Easy and Fast

The new search is a major feature in Windows Vista Control Panel.

The new search provides:

  • The ability to quickly find applets and tasks from anywhere in Control Panel. Tasks cannot be searched in Classic View.

  • The ability to quickly find applets from the start menu search box.

  • The ability to launch applets and tasks from search results.

Although Windows Vista provides almost twice as many applets as Windows XP, this new search feature makes navigating Control Panel very easy. For more information on the new search feature, see Control Panel User Interface.

Enhanced Control Panel View

Control Panel in Windows Vista has two views; Classic View and Control Panel Home. Classic View shows all the applets and their titles in a big alphabetical list, and Control Panel Home shows all the applets organized in categories. Control Panel Home also shows some of the most commonly used Task Links.

New in both Classic View and Control Panel Home, is the Search box (wordwheel) which allows you to search applets by name. Also new in Classic View is the category column. You can sort applets by category by clicking the category column in Classic View.

Microsoft’s investment in Control Panel enhancements are mostly in the Control Panel Home. This was done to improve user experience in the Control Panel and make it easier for users, software developers and administrators to complete their tasks quickly and efficiently.

Control Panel now has new hyperlinks that allow quick and easy navigation. In Control Panel Home, you can select a category to display the applets in that category. You can then click an applet to open the control panel item, or click a Task Link that appears under the applet to display a few of the tasks you can perform with that applet. For more information on the new search feature and enhanced views, see Control Panel User Interface.

Types of Control Panel Applets

There are three types of Control Panel applets:

  • Command objects—applets that run commands specified in the registry

  • Shell folders—applets open up in the Control Panel. Examples of shell folder applets are the Fonts Folder, Administrative Tools, Personalization, System, User Accounts, and Programs

  • CPLs—applets that implement the CplApplet function

Command objects are the easiest to implement.

Adding and Registering Your Own Applets and Tasks

Adding your own applet to Control Panel is easier in Windows Vista. Software developers can now easily add their own applets and tasks to Control Panel.

In previous versions of Windows, you add applets to the Control Panel by using the Windows Registry and the CplApplet function. The operating system uses the Registry to enumerate the modules containing the applets. Each module's CplApplet function is called to display the applet, its icon and description, and then invoke the applet. This process is more complicated than using command objects because the applet must implement the CplApplet Interface. Although this process is still supported in Windows Vista, using command objects is encouraged since it is easier to implement.

Now, in Windows Vista, you can just write an executable (.exe), register it as a command object and the applet appears in Control Panel. For example, you can write an executable, MySystemApplet.exe, for your applet and add the applet to Control Panel by simply registering MySystemApplet.exe as a shell command object instead of tediously modifying the binary with an implementation of the CplApplet interface.

The following code example registers MySystemApplet.exe applet as a command object and adds the applet to Control Panel.

To register MySystemApplet.exe applet as a command object and add the applet to Control Panel

  1. Create a new GUID for your command object. This example uses {0052D9FC-6764-4D29-A66F-2F3BD9E2BB40} as a new GUID.

  2. Set the value of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40} to MySystemApplet. Default Value = "MySystemApplet" and thenreplace the GUID with your GUID.

    Note

    For a 64 bit applet in a 64 bit version of Windows Vista, the registry entries must go to a 64 bit registry. For a 32 bit applet in a 64 bit version of Windows Vista, the registry entries must go to ControlPanelWOW64 rather than ControlPanel, as in the following path:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanelWOW64\NameSpace\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40}.

    The ControlPanelWOW64 path does not exist in the default version and must be added.

  3. SetHKEY_CLASSES_ROOT\CLSID\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40} to the following values:

     // Sets your applet’s display name.
    (Default value) as REG_SZ = "MySystemApplet"
    // Sets your applet's canonical name.  
    System.ApplicationName as Reg_sz = "MyCompany.MySystemApplet"
    //Invoking control.exe /name MyCompany.MySystemApplet will launch the applet.
    // Adds the applet to Appearance and Personalization and the Programs categories. 
    System.ControlPanel.Category as Reg_sz = "1,8"
    // Defines the module name and string table ID of the name of the applet.  The format
    // starts with "@" followed by the .exe or .dll that contains the MUI string table,
    // followed by "-", followed by the ID in the string table.  The format can also
    // contain just text if your applet does not have a string table.  In this case,
    // the name will not be localized.
    LocalizedString as Reg_expand_sz = "@%SystemRoot%\MySystemApplet.exe,-9"  
    // Same format as the LocalizedString.  
    InfoTip as reg_expand_sz = "@%SystemRoot%\MySystemApplet.exe,-5"
    
  4. Setthe default Icon ofHKEY_CLASSES_ROOT\CLSID\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40}

    //Sets the DefaultIcon to a default value. 2 represents the resource ID of the icon(default).
    reg_expand_sz = "%SystemRoot%\MySystemApplet.exe,-2"
    
  5. Set the command for HKEY_CLASSES_ROOT\CLSID\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40}\Shell\Open\Command.

     // Specify the command to call when your icon gets invoked.(default)
    reg_expand_sz = "%ProgramFiles%\MyCompany\MySystemApplet.exe"
    
  6. Under HKEY_CLASSES_ROOT\CLSID\{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40}, where this GUID is the GUID you used to register your applet, Set the value of System.Software.TasksFileUrl. "System.Software.TasksFileUrl" as reg_expand_sz = "C:\\test\\MySystemApplettasks.xml" so that "System.Software.TasksFileUrl" reg value points to the location of your installed tasks XML. See the sample code below for an example a task XML file.

The following table lists the values that represent each Control Panel category in Windows Vista.

Value

Category Icon appears in

1

Appearance and Personalization

2

Hardware and Sound

3

Network and Internet

4

Not used

5

System and Maintenance

6

Clock, Language and Region

7

Ease of Access

8

Programs

9

User Accounts and Family Safety (called just "User Accounts" on business Release, and on Ultimate when joined to a domain)

10

Security

11

Mobile PC (this category only visible on laptop computers)

The following code sample defines tasks in an XML file. You can point "System.Software.TasksFileUrl" reg to this XML file.

<?xml version="1.0" ?>
<applications xmlns="https://schemas.microsoft.com/windows/cpltasks/v1" xmlns:sh="https://schemas.microsoft.com/windows/tasks/v1">
    <!-- MySystemApplet -->
    <application id="{0052D9FC-6764-4D29-A66F-2F3BD9E2BB40}">  <!-- this GUID must match the GUID you created for your applet, and registered in namespace -->
        <!-- Solitaire -->
        <sh:task id="{3B75A7AE-C4E4-4E5A-9420-7CECCDA75425}"> <!-- This is a made-up GUID, just for this task -->
              <sh:name>Play solitaire</sh:name>              <sh:keywords>game;cards;ace;diamond;heart;club;single</sh:keywords>
              <sh:command>%ProgramFiles%\Microsoft Games\Solitaire\solitaire.exe</sh:command>
        </sh:task>
        <!-- Task Manager -->
        <sh:task id="{BF46D6AA-B5E6-4EE1-9E5B-ED017272B9F9}">  <!-- made-up GUID for this task -->
              <sh:name>Run Task Manager</sh:name>            <sh:keywords>taskmgr;taskman;programs;processes;threads;cpu;utilization</sh:keywords>
              <sh:command>taskmgr.exe</sh:command>
        </sh:task>
   <!-- IE -->
        <sh:task id="{DE3A6DCC-C18A-4BBF-9227-11856D7B4422}">
              <sh:name>Open Internet Explorer</sh:name>
<sh:keywords>IE;web;browser;net;Internet;Netscape;Trident;ActiveX;plug-in;plugin</sh:keywords>
              <sh:command>iexplore.exe</sh:command>
        </sh:task>
        <category id="1"> <!-- Appearance and Themes -->
  <!—these idref entries are referring to the GUIDs of the tasks defined above.  "3B7.." is Solitaire, "BF4.." is Task Manager, "DE3.." is Internet Explorer.-->
       <sh:task idref="{3B75A7AE-C4E4-4E5A-9420-7CECCDA75425}" />   
       <sh:task idref="{BF46D6AA-B5E6-4EE1-9E5B-ED017272B9F9}" />
       <sh:task idref="{DE3A6DCC-C18A-4BBF-9227-11856D7B4422}" />
   </category>
       <category id="8"> <!-- Programs -->
       <sh:task idref="{3B75A7AE-C4E4-4E5A-9420-7CECCDA75425}">
                  <sh:name>Click here for fun</sh:name>
      <!—this is showing an 'override name.' When the MySystemApplet applet appears in the Programs category, it will use the "Click here for fun" text for this Solitaire link, instead of the "Play solitaire" text. -->
       </sh:task>
       <sh:task idref="{BF46D6AA-B5E6-4EE1-9E5B-ED017272B9F9}" />
       <sh:task idref="{DE3A6DCC-C18A-4BBF-9227-11856D7B4422}" />
   </category>
    </application>
</applications>

A New syntax for Opening Control Panel

Windows Vista provides a new syntax for opening Control Panel applets from code and the Start->Run menu by specifying simple, easy to understand canonical names for each applet. These new canonical names are the best way to access an applet because, if the implementation or the filename changes, the canonical name remains the same. For example, in previous versions of Windows, you launch Internet Properties (the Internet Explorer Control Panel applet) with the following syntax: Control.exe inetcpl.cpl. This syntax only works as long as the applet is implemented with a .cpl file.

This syntax has changed in Windows Vista. Many of the files that are .cpl files in Windows XP are now implemented as Shell folder applets. For example, desk.cpl is replaced with the Personalization applet and nusrmgr.cpl is replaced with the User Accounts.

The way to access these new in-frame applets is with this new syntax using the canonical name. To access the Personalization applet, for example, you use control.exe /name Microsoft.Personalization. To access the user accounts applet, you use control.exe /name Microsoft.UserAccounts. 

The following lists all the canonical names of applets that ship with Windows Vista.

Microsoft.AddHardware

Microsoft.AdministrativeTools

Microsoft.AudioDevicesAndSoundThemes

Microsoft.AutoPlay

Microsoft.BackupAndRestoreCenter

Microsoft.BitLockerDriveEncryption

Microsoft.Bluetooth

Microsoft.CardSpace

Microsoft.ColorManagement

Microsoft.DateAndTime

Microsoft.DefaultPrograms

Microsoft.DeviceManager

Microsoft.EaseOfAccessCenter

Microsoft.FolderOptions

Microsoft.Fonts

Microsoft.GameControllers

Microsoft.GetPrograms

Microsoft.GetProgramsOnline

Microsoft.IndexingOptions

Microsoft.Infrared

Microsoft.InternetOptions

Microsoft.iSCSIInitiator

Microsoft.Keyboard

Microsoft.MobilityCenter

Microsoft.Mouse

Microsoft.NetworkAndSharingCenter

Microsoft.OfflineFiles

Microsoft.ParentalControls

Microsoft.PenAndInputDevices

Microsoft.PeopleNearMe

Microsoft.PerformaceInformationAndTools

Microsoft.Personalization

Microsoft.PhoneAndModemOptions

Microsoft.PowerOptions

Microsoft.Printers

Microsoft.ProblemReportsAndSolutions

Microsoft.ProgramsAndFeatures

Microsoft.RegionalAndLanguageOptions

Microsoft.ScannersAndCameras

Microsoft.SecurityCenter

Microsoft.SpeechRecognitionOptions

Microsoft.SyncCenter

Microsoft.System

Microsoft.TabletPCSettings

Microsoft.TaskbarAndStartMenu

Microsoft.TextToSpeech

Microsoft.UserAccounts

Microsoft.WelcomeCenter

Microsoft.WindowsAnytimeUpgrade

Microsoft.WindowsDefender

Microsoft.WindowsFirewall

Microsoft.WindowsSideShow

Microsoft.WindowsSidebarProperties

Microsoft.WindowsUpdate

Software developers can add to this list if they add their own applet to Control Panel. These canonical names are easy to understand and easy to remember.

Now, in Windows Vista, you can add your own applet to Control Panel by creating an executable for your applet and registering it, instead of going through the trouble of creating a .cpl file.