The Win32 system contains a large amount of information that is accessible to a WFC application or component. Most of this access is through classes in the com.ms.wfc.app package. Much of this information is stored in the Windows registry and accessed through the RegistryKey and Registry classes. Other system information, such as Windows display element sizes, operating system settings, network availability, and the hardware capabilities, are accessed using static methods in the com.ms.wfc.app.SystemInformation class. System time is available using the com.ms.wfc.app.Time class.
This section provides an overview of how a WFC application can access this system information.
The RegistryKey class in the com.ms.wfc.app package contains methods to access the Windows system registry. Use the methods in this class to create and delete subkeys, to get the count and names of subkeys for the current key, and to retrieve, set, and delete values assigned to subkeys.
The com.ms.wfc.app.Registry class contains fields holding RegistryKey objects that represent the root keys of the registry (those starting with HKEY_). (Root RegistryKey objects can also be instantiated using the getBaseKey method.) Methods can be called on any RegistryKey object to enumerate and manipulate keys and key values in the subkey tree below the root object. For example, the following code obtains an array of subkey names under the HKEY_CURRENT_USER key and the number of names in that array:
int subKeyCount; String[] subKeyNames; subKeyNames = Registry.CURRENT_USER.getSubKeyNames(); subKeyCount = Registry.CURRENT_USER.getSubKeyCount();
Similarly, any subkey can be retrieved or set given its path, and subkey value names and data can be retrieved or set given the value name. You can also create new keys, using the createSubKey method and set values in that key using the setValue method.
Locale information provides details about the language and regional settings on the user's computer. There are many characteristics about a language or region that are stored. These include the character set, international telephone codes, how monetary information is displayed, which calendar is used, the measurement system, and so on.
This information is typically set using the Regional Settings dialog box in Control Panel, but it is also available programmatically. In WFC, this access is provided through the methods in the com.ms.wfc.app.Locale class and through the many subclasses of Locale that contain field constants pertaining to Locale methods. For details about setting and retrieving this information, see the methods in the Locale class.
Another category of system information is time. The com.ms.wfc.app.Time class provides a Time object that has many capabilities, including capturing system time. The default constructor creates a Time object with the system date and time. Beyond retrieving system time information, the Time object is useful for doing many other things, such as comparing Date and Time objects, converting the time to various formats, and storing a Time object for later retrieval.
Time objects, once created, cannot be altered. However, the Time class provides many methods for creating new objects with offset time (such as addSeconds, addMinutes, addHours, addDays, and addYears). Also, there are many methods for retrieving just one of the properties of a Time object, such as the second, minute, hour, day, and so on.
The Time object in WFC stores time as the number of hundred-nanosecond units since A.D. 100, beginning Jan 1. The maximum value that can be stored in a WFC Time object is A.D. 10,000, ending Dec 31. Converting WFC Time objects to other formats (Strings, Variants, SYSTEMTIME, and so on) can cause loss of accuracy, and not all formats can store this wide of a range.
Do not confuse the Time class with another com.ms.wfc.app class called Timer. Timer is actually a control; however, it is not in the com.ms.wfc.ui package because it does not have a user interface.