"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Obtain information from the Windows operating system in VB6 and VBA with 32 and 64 bit Windows API calls.
Procedure List
Procedure Name
|
Type
|
Description
|
(Declarations)
|
Declarations
|
Declarations and private variables for the COSInfo class
|
Beep
|
Property
|
Determine whether the warning beeper is on or off
|
ComputerName
|
Property
|
Get the name of the computer
|
CurrentHardwareProfile
|
Property
|
Get the name of the current hardware profile
|
DefaultCompanyName
|
Property
|
Get the default company name used by Microsoft setup programs
|
DefaultUserName
|
Property
|
Get the default user name used by Microsoft setup programs
|
DisplayColors
|
Property
|
Get the number of colors displayed by the adapter
|
Language
|
Property
|
Get the user language
|
LargeFonts
|
Property
|
Determine whether large fonts are displayed
|
OSAdditional
|
Property
|
Get additional information about the operating system version
|
OSBuild
|
Property
|
Get the operating system build number
|
OSMajorVersion
|
Property
|
Get the operating system major version
|
OSMinorVersion
|
Property
|
Get the operating system minor version
|
ScreenResolutionX
|
Property
|
Get the screen resolution X value
|
ScreenResolutionY
|
Property
|
Get the screen resolution Y value
|
ScreenSaverActive
|
Property
|
Determine whether the screen saver is enabled
|
ScreenSaverTimeout
|
Property
|
Get the screen saver time-out value
|
SystemDirectory
|
Property
|
Get the Windows system directory
|
TempFile
|
Property
|
Get a temporary file name. The TempFile property only uses the first three characters of the strPrefix parameter.
|
TempPath
|
Property
|
Get the path of the temporary directory
|
UserName
|
Property
|
Get the Windows user name
|
WindowsDirectory
|
Property
|
Get the Windows directory
|
WindowsType
|
Property
|
Get the Windows type.
|
WindowsVersionString
|
Property
|
Get the Windows version as a string with major and minor build plus 32 or 64 bitness (e.g. "Windows 8 v.6.2, 64 bit" or "Windows 7 v.6.1, 32 bit")
|
WindowsUpTime
|
Property
|
Get the length of time in minutes that the current Windows session has been running
|
CreateGUID
|
Method
|
Generates a GUID (Globally Unique IDentifier)
|
PadHex
|
Private
|
Pad a string to a minimum length by adding trailing hex character
|
GetWorkArea
|
Method
|
Get the visible area of the desktop, minus the taskbar
|
RegistryGetKeyValue
|
Private
|
Get a value from the system registry
|
TrimNull
|
Private
|
Get the passed string terminated at the first null character. If there isn't a null, the entire string is returned.
|
Example Code for Using Class: OSInfo
' Example of COSInfo
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
' F5 to run it, or
' F8 to step through it line-by-line (see the Debug menu for more options)
Private Sub Example_COSInfo()
' Comments: Example of using the COSInfo class to get Windows operating system information in VB6 and VBA with 32 and 64 bit Windows API calls.
' Run this procedure and see the information in the Immediate Window.
Dim clsOSInfo As New COSInfo
Dim intLeft As Integer
Dim intTop As Integer
Dim intWidth As Integer
Dim intHeight As Integer
Dim lngX As Long
Dim lngY As Long
' Display operating system information in the Immediate Window
With clsOSInfo
Debug.Print "Beep warning = " & .Beep
Debug.Print "Computer Name = " & .ComputerName
Debug.Print "Current Hardware Profile = " & .CurrentHardwareProfile
Debug.Print "Default Company Name = " & .DefaultCompanyName
Debug.Print "Default User Name = " & .DefaultUserName
Debug.Print "Display Colors = " & .DisplayColors
.GetWorkArea intLeft, intTop, intWidth, intHeight
Debug.Print "WorkArea = (" & intLeft & "," & intTop & ") - (" & intWidth & "," & intHeight & ")"
lngX = .ScreenResolutionX
lngY = .ScreenResolutionY
Debug.Print "Screen Resolution = " & lngX & " x " & lngY
Debug.Print "Guid = " & .CreateGUID
Debug.Print "Language = " & .Language
Debug.Print "LargeFonts = " & .LargeFonts
Debug.Print "OSBuild = " & .OSBuild
Debug.Print "OSAdditional = " & .OSAdditional
Debug.Print "Version = " & .OSMajorVersion & "." & .OSMinorVersion
Debug.Print "Screen Saver Active = " & .ScreenSaverActive
Debug.Print "Screen Saver Timeout = " & .ScreenSaverTimeout
Debug.Print "System Directory = " & .SystemDirectory
Debug.Print "Temp File = " & .TempFile("tes")
Debug.Print "Temp Path = " & .TempPath
Debug.Print "User Name = " & .UserName
Debug.Print "Windows Directory = " & .WindowsDirectory
Debug.Print "Windows Type = " & .WindowsType
Debug.Print "Windows Version = " & .WindowsVersionString
End With
Set clsOSInfo = Nothing
End Sub
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|