システム情報を取得する

注意:
この文書は以前「.NETでいきまっしょい!」で公開していたものですが、公開以降メンテナンスされていません。 今や古い情報となった内容が記載されている場合があるのでご注意ください。
VB.NET
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
Console.WriteLine(System.Windows.Forms.SystemInformation.IconSize)
Console.WriteLine(System.Windows.Forms.SystemInformation.SmallIconSize)
Console.WriteLine(System.Windows.Forms.SystemInformation.WorkingArea)

Console.WriteLine(System.Windows.Forms.SystemInformation.DoubleClickTime)
Console.WriteLine(System.Windows.Forms.SystemInformation.DoubleClickSize)

Console.WriteLine(System.Windows.Forms.SystemInformation.MousePresent)
Console.WriteLine(System.Windows.Forms.SystemInformation.MouseButtons)
Console.WriteLine(System.Windows.Forms.SystemInformation.MouseWheelPresent)
Console.WriteLine(System.Windows.Forms.SystemInformation.MouseWheelScrollLines)

Console.WriteLine(System.Windows.Forms.SystemInformation.BootMode)
Console.WriteLine(System.Windows.Forms.SystemInformation.ComputerName)
Console.WriteLine(System.Windows.Forms.SystemInformation.UserDomainName)
Console.WriteLine(System.Windows.Forms.SystemInformation.UserName)
出力例
{Width=32, Height=32}
{Width=16, Height=16}
{X=0,Y=0,Width=1280,Height=960}
200
{Width=4, Height=4}
True
5
True
7
0
********
********
********
Press any key to continue

(コンピュータ名ほか隠してあります)

 System.Windows.Forms.SystemInformationのプロパティを参照することで、各種システムメトリック値やコンピュータ名・ユーザー名などを取得できる。 APIのGetSystemMetricで取得したい値は、代わりにこのクラスを用いて取得できる。 ここで紹介した以外のプロパティも多数存在する。