(view source code of systeminformationdll.cs as plain text)
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace RobvanderWoude
{
[ComVisible( true )]
public class SystemInformation
{
private static string mypath = Assembly.GetAssembly( typeof( RobvanderWoude.SystemInformation ) ).Location.ToString( );
[ComVisible( true )]
public string GetHelp( )
{
string helptemplate = "{0}, Version {1}\n{2}\n\nUsage in VBScript:\n\n";
helptemplate += "Set objSysInfo=CreateObject( \"RobvanderWoude.SystemInformation\" )\n";
helptemplate += "' Read some property values\n";
helptemplate += "WScript.Echo objSysInfo.UserName\n";
helptemplate += "WScript.Echo objSysInfo.MonitorCount\n";
helptemplate += "' Get the DLL's version\n";
helptemplate += "WScript.Echo objSysInfo.GetVersion( )\n";
helptemplate += "' List all available property names\n";
helptemplate += "WScript.Echo objSysInfo.ListPropertyNames( )\n";
helptemplate += "' List all property names and their values\n";
helptemplate += "Wscript.Echo objSysInfo.ListPropertyValues( )\n\n";
helptemplate += "Note: All property values are returned as string or 32-bit integer.\n\n";
helptemplate += "{3}\n";
helptemplate += "http://www.robvanderwoude.com\n";
FileVersionInfo myfileversioninfo = FileVersionInfo.GetVersionInfo( mypath );
string filename = Path.GetFileName( myfileversioninfo.FileName );
string fileversion = myfileversioninfo.FileVersion;
string filecomment = myfileversioninfo.Comments;
string copyrights = myfileversioninfo.LegalCopyright;
string description = String.Format( helptemplate, filename, fileversion, filecomment, copyrights );
return description;
}
[ComVisible( true )]
public string GetVersion( )
{
return FileVersionInfo.GetVersionInfo( mypath ).FileVersion;
}
[ComVisible( true )]
public string ListPropertyNames( )
{
string result = String.Empty;
foreach ( PropertyInfo property in this.GetType( ).GetProperties( ) )
{
result += property.Name + "\n";
}
return result;
}
[ComVisible( true )]
public string ListPropertyValues( )
{
string result = String.Empty;
foreach ( PropertyInfo property in this.GetType( ).GetProperties( ) )
{
string val = String.Empty;
try
{
val = property.GetValue( this, null ).ToString( );
}
catch { };
result += String.Format( "{0}={1}\n", property.Name, val );
}
return result;
}
[ComVisible( true )]
public int ActiveWindowTrackingDelay
{
get { return System.Windows.Forms.SystemInformation.ActiveWindowTrackingDelay; }
}
[ComVisible( true )]
public string ArrangeDirection
{
get { return Enum.GetName( typeof( ArrangeDirection ), System.Windows.Forms.SystemInformation.ArrangeDirection ); }
}
[ComVisible( true )]
public string ArrangeStartingPosition
{
get { return Enum.GetName( typeof( ArrangeStartingPosition ), System.Windows.Forms.SystemInformation.ArrangeStartingPosition ); }
}
[ComVisible( true )]
public string BootMode
{
get { return Enum.GetName( typeof( BootMode ), System.Windows.Forms.SystemInformation.BootMode ); }
}
[ComVisible( true )]
public string Border3DSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.Border3DSize.Width, System.Windows.Forms.SystemInformation.Border3DSize.Height ); }
}
[ComVisible( true )]
public int BorderMultiplierFactor
{
get { return System.Windows.Forms.SystemInformation.BorderMultiplierFactor; }
}
[ComVisible( true )]
public string BorderSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.BorderSize.Width, System.Windows.Forms.SystemInformation.BorderSize.Height ); }
}
[ComVisible( true )]
public string CaptionButtonSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.CaptionButtonSize.Width, System.Windows.Forms.SystemInformation.CaptionButtonSize.Height ); }
}
[ComVisible( true )]
public int CaptionHeight
{
get { return System.Windows.Forms.SystemInformation.CaptionHeight; }
}
[ComVisible( true )]
public int CaretBlinkTime
{
get { return System.Windows.Forms.SystemInformation.CaretBlinkTime; }
}
[ComVisible( true )]
public int CaretWidth
{
get { return System.Windows.Forms.SystemInformation.CaretWidth; }
}
[ComVisible( true )]
public string ComputerName
{
get { return System.Windows.Forms.SystemInformation.ComputerName; }
}
[ComVisible( true )]
public string CursorSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.CursorSize.Width, System.Windows.Forms.SystemInformation.CursorSize.Height ); }
}
[ComVisible( true )]
public string DbcsEnabled
{
get { return ( System.Windows.Forms.SystemInformation.DbcsEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string DebugOS
{
get { return ( System.Windows.Forms.SystemInformation.DebugOS ? "True" : "False" ); }
}
[ComVisible( true )]
public string DoubleClickSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.DoubleClickSize.Width, System.Windows.Forms.SystemInformation.DoubleClickSize.Height ); }
}
[ComVisible( true )]
public int DoubleClickTime
{
get { return System.Windows.Forms.SystemInformation.DoubleClickTime; }
}
[ComVisible( true )]
public string DragFullWindows
{
get { return ( System.Windows.Forms.SystemInformation.DragFullWindows ? "True" : "False" ); }
}
[ComVisible( true )]
public string DragSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.DragSize.Width, System.Windows.Forms.SystemInformation.DragSize.Height ); }
}
[ComVisible( true )]
public string FixedFrameBorderSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.FixedFrameBorderSize.Width, System.Windows.Forms.SystemInformation.FixedFrameBorderSize.Height ); }
}
[ComVisible( true )]
public int FontSmoothingContrast
{
get { return System.Windows.Forms.SystemInformation.FontSmoothingContrast; }
}
[ComVisible( true )]
public int FontSmoothingType
{
get { return System.Windows.Forms.SystemInformation.FontSmoothingType; }
}
[ComVisible( true )]
public string FrameBorderSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.FrameBorderSize.Width, System.Windows.Forms.SystemInformation.FrameBorderSize.Height ); }
}
[ComVisible( true )]
public string HighContrast
{
get { return ( System.Windows.Forms.SystemInformation.HighContrast ? "True" : "False" ); }
}
[ComVisible( true )]
public int HorizontalFocusThickness
{
get { return System.Windows.Forms.SystemInformation.HorizontalFocusThickness; }
}
[ComVisible( true )]
public int HorizontalResizeBorderThickness
{
get { return System.Windows.Forms.SystemInformation.HorizontalResizeBorderThickness; }
}
[ComVisible( true )]
public int HorizontalScrollBarArrowWidth
{
get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarArrowWidth; }
}
[ComVisible( true )]
public int HorizontalScrollBarHeight
{
get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarHeight; }
}
[ComVisible( true )]
public int HorizontalScrollBarThumbWidth
{
get { return System.Windows.Forms.SystemInformation.HorizontalScrollBarThumbWidth; }
}
[ComVisible( true )]
public int IconHorizontalSpacing
{
get { return System.Windows.Forms.SystemInformation.IconHorizontalSpacing; }
}
[ComVisible( true )]
public string IconSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.IconSize.Width, System.Windows.Forms.SystemInformation.IconSize.Height ); }
}
[ComVisible( true )]
public string IconSpacingSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.IconSpacingSize.Width, System.Windows.Forms.SystemInformation.IconSpacingSize.Height ); }
}
[ComVisible( true )]
public int IconVerticalSpacing
{
get { return System.Windows.Forms.SystemInformation.IconVerticalSpacing; }
}
[ComVisible( true )]
public string IsActiveWindowTrackingEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsActiveWindowTrackingEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsComboBoxAnimationEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsComboBoxAnimationEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsDropShadowEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsDropShadowEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsFlatMenuEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsFlatMenuEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsFontSmoothingEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsFontSmoothingEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsHotTrackingEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsHotTrackingEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsIconTitleWrappingEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsIconTitleWrappingEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsKeyboardPreferred
{
get { return ( System.Windows.Forms.SystemInformation.IsKeyboardPreferred ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsListBoxSmoothScrollingEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsListBoxSmoothScrollingEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsMenuAnimationEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsMenuAnimationEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsMenuFadeEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsMenuFadeEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsMinimizeRestoreAnimationEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsMinimizeRestoreAnimationEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsSelectionFadeEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsSelectionFadeEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsSnapToDefaultEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsSnapToDefaultEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsTitleBarGradientEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsTitleBarGradientEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string IsToolTipAnimationEnabled
{
get { return ( System.Windows.Forms.SystemInformation.IsToolTipAnimationEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public int KanjiWindowHeight
{
get { return System.Windows.Forms.SystemInformation.KanjiWindowHeight; }
}
[ComVisible( true )]
public int KeyboardDelay
{
get { return System.Windows.Forms.SystemInformation.KeyboardDelay; }
}
[ComVisible( true )]
public int KeyboardSpeed
{
get { return System.Windows.Forms.SystemInformation.KeyboardSpeed; }
}
[ComVisible( true )]
public string MaxWindowTrackSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MaxWindowTrackSize.Width, System.Windows.Forms.SystemInformation.MaxWindowTrackSize.Height ); }
}
[ComVisible( true )]
public string MenuAccessKeysUnderlined
{
get { return ( System.Windows.Forms.SystemInformation.MenuAccessKeysUnderlined ? "True" : "False" ); }
}
[ComVisible( true )]
public string MenuBarButtonSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuBarButtonSize.Width, System.Windows.Forms.SystemInformation.MenuBarButtonSize.Height ); }
}
[ComVisible( true )]
public string MenuButtonSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuButtonSize.Width, System.Windows.Forms.SystemInformation.MenuButtonSize.Height ); }
}
[ComVisible( true )]
public string MenuCheckSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MenuCheckSize.Width, System.Windows.Forms.SystemInformation.MenuCheckSize.Height ); }
}
[ComVisible( true )]
public string MenuFont
{
get { return String.Format( "[Font:Name={0},Size={1},Units={2},GdiCharSet={3},GdiVerticalFont={4}]", System.Windows.Forms.SystemInformation.MenuFont.Name, System.Windows.Forms.SystemInformation.MenuFont.Size.ToString( ), System.Windows.Forms.SystemInformation.MenuFont.Unit.ToString( ), System.Windows.Forms.SystemInformation.MenuFont.GdiCharSet.ToString( ), ( System.Windows.Forms.SystemInformation.MenuFont.GdiVerticalFont ? "True" : "False" ) ); }
}
[ComVisible( true )]
public int MenuHeight
{
get { return System.Windows.Forms.SystemInformation.MenuHeight; }
}
[ComVisible( true )]
public int MenuShowDelay
{
get { return System.Windows.Forms.SystemInformation.MenuShowDelay; }
}
[ComVisible( true )]
public string MidEastEnabled
{
get { return ( System.Windows.Forms.SystemInformation.MidEastEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string MinimizedWindowSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimizedWindowSize.Width, System.Windows.Forms.SystemInformation.MinimizedWindowSize.Height ); }
}
[ComVisible( true )]
public string MinimizedWindowSpacingSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimizedWindowSpacingSize.Width, System.Windows.Forms.SystemInformation.MinimizedWindowSpacingSize.Height ); }
}
[ComVisible( true )]
public string MinimumWindowSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinimumWindowSize.Width, System.Windows.Forms.SystemInformation.MinimumWindowSize.Height ); }
}
[ComVisible( true )]
public string MinWindowTrackSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MinWindowTrackSize.Width, System.Windows.Forms.SystemInformation.MinWindowTrackSize.Height ); }
}
[ComVisible( true )]
public int MonitorCount
{
get { return System.Windows.Forms.SystemInformation.MonitorCount; }
}
[ComVisible( true )]
public string MonitorsSameDisplayFormat
{
get { return ( System.Windows.Forms.SystemInformation.MonitorsSameDisplayFormat ? "True" : "False" ); }
}
[ComVisible( true )]
public int MouseButtons
{
get { return System.Windows.Forms.SystemInformation.MouseButtons; }
}
[ComVisible( true )]
public string MouseButtonsSwapped
{
get { return ( System.Windows.Forms.SystemInformation.MouseButtonsSwapped ? "True" : "False" ); }
}
[ComVisible( true )]
public string MouseHoverSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.MouseHoverSize.Width, System.Windows.Forms.SystemInformation.MouseHoverSize.Height ); }
}
[ComVisible( true )]
public int MouseHoverTime
{
get { return System.Windows.Forms.SystemInformation.MouseHoverTime; }
}
[ComVisible( true )]
public string MousePresent
{
get { return ( System.Windows.Forms.SystemInformation.MousePresent ? "True" : "False" ); }
}
[ComVisible( true )]
public int MouseSpeed
{
get { return System.Windows.Forms.SystemInformation.MouseSpeed; }
}
[ComVisible( true )]
public string MouseWheelPresent
{
get { return ( System.Windows.Forms.SystemInformation.MouseWheelPresent ? "True" : "False" ); }
}
[ComVisible( true )]
public int MouseWheelScrollDelta
{
get { return System.Windows.Forms.SystemInformation.MouseWheelScrollDelta; }
}
[ComVisible( true )]
public int MouseWheelScrollLines
{
get { return System.Windows.Forms.SystemInformation.MouseWheelScrollLines; }
}
[ComVisible( true )]
public string NativeMouseWheelSupport
{
get { return ( System.Windows.Forms.SystemInformation.NativeMouseWheelSupport ? "True" : "False" ); }
}
[ComVisible( true )]
public string Network
{
get { return ( System.Windows.Forms.SystemInformation.Network ? "True" : "False" ); }
}
[ComVisible( true )]
public string PenWindows
{
get { return ( System.Windows.Forms.SystemInformation.PenWindows ? "True" : "False" ); }
}
[ComVisible( true )]
public string PopupMenuAlignment
{
get { return Enum.GetName( typeof( LeftRightAlignment ), System.Windows.Forms.SystemInformation.PopupMenuAlignment ); }
}
[ComVisible( true )]
public string PowerStatus
{
get { return GetPowerStatus( ); }
}
[ComVisible( true )]
public string PrimaryMonitorMaximizedWindowSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.PrimaryMonitorMaximizedWindowSize.Width, System.Windows.Forms.SystemInformation.PrimaryMonitorMaximizedWindowSize.Height ); }
}
[ComVisible( true )]
public string PrimaryMonitorSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width, System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height ); }
}
[ComVisible( true )]
public string RightAlignedMenus
{
get { return ( System.Windows.Forms.SystemInformation.RightAlignedMenus ? "True" : "False" ); }
}
[ComVisible( true )]
public string ScreenOrientation
{
get { return Enum.GetName( typeof( ScreenOrientation ), System.Windows.Forms.SystemInformation.ScreenOrientation ); }
}
[ComVisible( true )]
public string Secure
{
get { return ( System.Windows.Forms.SystemInformation.Secure ? "True" : "False" ); }
}
[ComVisible( true )]
public string ShowSounds
{
get { return ( System.Windows.Forms.SystemInformation.ShowSounds ? "True" : "False" ); }
}
[ComVisible( true )]
public int SizingBorderWidth
{
get { return System.Windows.Forms.SystemInformation.SizingBorderWidth; }
}
[ComVisible( true )]
public string SmallCaptionButtonSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.SmallCaptionButtonSize.Width, System.Windows.Forms.SystemInformation.SmallCaptionButtonSize.Height ); }
}
[ComVisible( true )]
public string SmallIconSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.SmallIconSize.Width, System.Windows.Forms.SystemInformation.SmallIconSize.Height ); }
}
[ComVisible( true )]
public string TerminalServerSession
{
get { return ( System.Windows.Forms.SystemInformation.TerminalServerSession ? "True" : "False" ); }
}
[ComVisible( true )]
public string ToolWindowCaptionButtonSize
{
get { return String.Format( "{{Width={0},Height={1}}}", System.Windows.Forms.SystemInformation.ToolWindowCaptionButtonSize.Width, System.Windows.Forms.SystemInformation.ToolWindowCaptionButtonSize.Height ); }
}
[ComVisible( true )]
public int ToolWindowCaptionHeight
{
get { return System.Windows.Forms.SystemInformation.ToolWindowCaptionHeight; }
}
[ComVisible( true )]
public string UIEffectsEnabled
{
get { return ( System.Windows.Forms.SystemInformation.UIEffectsEnabled ? "True" : "False" ); }
}
[ComVisible( true )]
public string UserDomainName
{
get { return System.Windows.Forms.SystemInformation.UserDomainName; }
}
[ComVisible( true )]
public string UserInteractive
{
get { return ( System.Windows.Forms.SystemInformation.UserInteractive ? "True" : "False" ); }
}
[ComVisible( true )]
public string UserName
{
get { return System.Windows.Forms.SystemInformation.UserName; }
}
[ComVisible( true )]
public int VerticalFocusThickness
{
get { return System.Windows.Forms.SystemInformation.VerticalFocusThickness; }
}
[ComVisible( true )]
public int VerticalResizeBorderThickness
{
get { return System.Windows.Forms.SystemInformation.VerticalResizeBorderThickness; }
}
[ComVisible( true )]
public int VerticalScrollBarArrowHeight
{
get { return System.Windows.Forms.SystemInformation.VerticalScrollBarArrowHeight; }
}
[ComVisible( true )]
public int VerticalScrollBarThumbHeight
{
get { return System.Windows.Forms.SystemInformation.VerticalScrollBarThumbHeight; }
}
[ComVisible( true )]
public int VerticalScrollBarWidth
{
get { return System.Windows.Forms.SystemInformation.VerticalScrollBarWidth; }
}
[ComVisible( true )]
public string VirtualScreen
{
get { return String.Format( "{{X={0},Y={1},Width={2},Height={3}}}", System.Windows.Forms.SystemInformation.VirtualScreen.X, System.Windows.Forms.SystemInformation.VirtualScreen.Y, System.Windows.Forms.SystemInformation.VirtualScreen.Width, System.Windows.Forms.SystemInformation.VirtualScreen.Height ); }
}
[ComVisible( true )]
public string WorkingArea
{
get { return String.Format( "{{X={0},Y={1},Width={2},Height={3}}}", System.Windows.Forms.SystemInformation.WorkingArea.X, System.Windows.Forms.SystemInformation.WorkingArea.Y, System.Windows.Forms.SystemInformation.WorkingArea.Width, System.Windows.Forms.SystemInformation.WorkingArea.Height ); }
}
static string GetPowerStatus( )
{
string powerstatus = String.Empty;
object propval = typeof( SystemInformation ).GetProperty( "PowerStatus" ).GetValue( typeof( SystemInformation ), null );
string bcs = typeof( PowerStatus ).GetProperty( "BatteryChargeStatus" ).GetValue( propval, null ).ToString( );
string bfl = typeof( PowerStatus ).GetProperty( "BatteryFullLifetime" ).GetValue( propval, null ).ToString( );
string blp = ( Convert.ToInt32( typeof( PowerStatus ).GetProperty( "BatteryLifePercent" ).GetValue( propval, null ) ) * 100 ).ToString( ) + "%";
string blr = typeof( PowerStatus ).GetProperty( "BatteryLifeRemaining" ).GetValue( propval, null ).ToString( );
string pls = typeof( PowerStatus ).GetProperty( "PowerLineStatus" ).GetValue( propval, null ).ToString( );
powerstatus = String.Format( "{{BatteryChargeStatus={0}", bcs );
powerstatus += String.Format( ",BatteryFullLifetime={0}", ( bfl == "-1" ? "Unknown" : bfl ) );
powerstatus += String.Format( ",BatteryLifePercent={0}", blp );
powerstatus += String.Format( ",BatteryLifeRemaining={0}", ( blr == "-1" ? "Unknown" : blr ) );
powerstatus += String.Format( ",PowerLineStatus={0}}}", pls );
return powerstatus;
}
}
}
page last modified: 2024-04-16; loaded in 0.0154 seconds