Developers can use VB6’s SysInfo
control to get information about the operating system and computer hardware. To
use the SysInfo control in a project, you must select
it in the Components dialog box (select Project | Components from the menu) so
it will be available in the Toolbox. (Note: This control does not display
during program execution but it is available in code.)
The SysInfo control also has some
events that respond to certain changes. For instance, the TimeChanged
event is useful if your application needs to keep close track of the time. This
event is fired whenever the system time changes, either through an application
or by the user through the Control Panel.
Here’s an example of how the SysInfo
control might come in handy: Suppose your program writes time-stamped
information to a log file every 60 seconds. If the user notices that the system
clock is several minutes slow and adjusts it, there will be a gap in the log
record. This may lead you to wonder if this was a program malfunction. By detecting
the time change with the SysInfo control, the program
can make a note in the log file that the time was changed.
Advance your scripting skills to the next level with TechRepublic’s free Visual Basic newsletter, delivered each Friday. Automatically sign up today!
Miss a column?
Check out the Visual Basic Archive, and catch up on the most recent editions of Peter Aitken’s column.