PowerStatusとは? わかりやすく解説

PowerStatus クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

現在のシステム電源の状態に関する情報示します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

public class PowerStatus
public ref class PowerStatus
public class PowerStatus
public class PowerStatus
解説解説
使用例使用例

ListBox コントロールにおける PowerStatus クラスすべてのプロパティ一覧表示しリスト項目が選択されている場合関連するプロパティ現在値TextBox表示する例を次に示します

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Reflection
Imports System.Windows.Forms

Public Class PowerStatusBrowserForm
    Inherits System.Windows.Forms.Form
    Private listBox1 As System.Windows.Forms.ListBox
    Private textBox1 As System.Windows.Forms.TextBox
  
    
    Public Sub New()
        Me.SuspendLayout()
        InitForm()
        
        'Add each property of the PowerStatus class to the list box.
        Dim t As Type = GetType(System.Windows.Forms.PowerStatus)
        Dim pi As PropertyInfo() = t.GetProperties()
        Dim i As Integer
        For i = 0 To pi.Length - 1
            listBox1.Items.Add(pi(i).Name)
        Next i
        textBox1.Text = "The PowerStatus class has "
 + pi.Length.ToString() + " properties." + ControlChars.CrLf
        
        ' Configure the list item selected handler for the list box
 to invoke a 
        ' method that displays the value of each property.         
  
        AddHandler listBox1.SelectedIndexChanged, AddressOf
 listBox1_SelectedIndexChanged
        Me.ResumeLayout(False)
    End Sub
        
    Private Sub listBox1_SelectedIndexChanged(sender
 As Object, e As EventArgs)
        ' Return if no item is selected.
        If listBox1.SelectedIndex = - 1 Then
            Return
        End If 
        ' Get the property name from the list item
        Dim propname As String
 = listBox1.Text
        
        ' Display the value of the selected property of the PowerStatus
 type.
        Dim t As Type = GetType(System.Windows.Forms.PowerStatus)
        Dim pi As PropertyInfo() = t.GetProperties()
        Dim prop As PropertyInfo = Nothing
        Dim i As Integer
        For i = 0 To pi.Length - 1
            If pi(i).Name = propname Then
                prop = pi(i)
                Exit For
            End If
        Next i 
        Dim propval As Object
 = prop.GetValue(SystemInformation.PowerStatus, Nothing)
        textBox1.Text += ControlChars.CrLf + "The value of the
 " + propname + " property is: " + propval.ToString()
    End Sub
    
    Private Sub InitForm()
        ' Initialize the form settings
        Me.listBox1 = New System.Windows.Forms.ListBox()
        Me.textBox1 = New System.Windows.Forms.TextBox()
        Me.listBox1.Anchor = CType(System.Windows.Forms.AnchorStyles.Top
 Or System.Windows.Forms.AnchorStyles.Bottom Or
 System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles)
        Me.listBox1.Location = New System.Drawing.Point(8,
 16)
        Me.listBox1.Size = New System.Drawing.Size(172,
 496)
        Me.listBox1.TabIndex = 0
        Me.textBox1.Anchor = CType(System.Windows.Forms.AnchorStyles.Top
 Or System.Windows.Forms.AnchorStyles.Bottom Or
 System.Windows.Forms.AnchorStyles.Right, System.Windows.Forms.AnchorStyles)
        Me.textBox1.Location = New System.Drawing.Point(188,
 16)
        Me.textBox1.Multiline = True
        Me.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
        Me.textBox1.Size = New System.Drawing.Size(420,
 496)
        Me.textBox1.TabIndex = 1
        Me.ClientSize = New System.Drawing.Size(616,
 525)
        Me.Controls.Add(Me.textBox1)
        Me.Controls.Add(Me.listBox1)
        Me.Text = "Select a PowerStatus property
 to get the value of"
    End Sub    
    
    <STAThread()>  _
    Shared Sub Main()
        Application.Run(New PowerStatusBrowserForm())
    End Sub

End Class
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;

namespace PowerStatusBrowser
{
    public class PowerStatusBrowserForm : System.Windows.Forms.Form
    {
        private System.Windows.Forms.ListBox listBox1;
        private System.Windows.Forms.TextBox textBox1;       
 
        
        public PowerStatusBrowserForm()
        {
            this.SuspendLayout();
            InitForm();
            
            //Add each property of the PowerStatus class to the list
 box.
            Type t = typeof(System.Windows.Forms.PowerStatus);            
            PropertyInfo[] pi = t.GetProperties();            
            for( int i=0; i<pi.Length; i++
 )
                listBox1.Items.Add( pi[i].Name );            
            textBox1.Text = "The PowerStatus class has "+pi.Length.ToString()+"
 properties.\r\n";

            // Configure the list item selected handler for the list
 box to invoke a 
            // method that displays the value of each property.    
       
            listBox1.SelectedIndexChanged += new EventHandler(listBox1_SelectedIndexChanged);
            this.ResumeLayout(false);
        }
        
        private void listBox1_SelectedIndexChanged(object
 sender, EventArgs e)
        {
            // Return if no item is selected.
            if( listBox1.SelectedIndex == -1 ) return;
            // Get the property name from the list item
            string propname = listBox1.Text;
            
            // Display the value of the selected property of the PowerStatus
 type.
            Type t = typeof(System.Windows.Forms.PowerStatus);
            PropertyInfo[] pi = t.GetProperties();            
            PropertyInfo prop = null;
            for( int i=0; i<pi.Length; i++
 )
                if( pi[i].Name == propname )
                {
                    prop = pi[i];
                    break;           
                }

            object propval = prop.GetValue(SystemInformation.PowerStatus, null);
            
            textBox1.Text += "\r\nThe value of the "+propname+" property
 is: "+propval.ToString();
        }

        private void InitForm()
        {
            // Initialize the form settings
            this.listBox1 = new System.Windows.Forms.ListBox();
            this.textBox1 = new System.Windows.Forms.TextBox();
            
            this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
 | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
            this.listBox1.Location = new System.Drawing.Point(8,
 16);
            this.listBox1.Size = new System.Drawing.Size(172,
 496);
            this.listBox1.TabIndex = 0;            
            this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top
 | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Right)));
            this.textBox1.Location = new System.Drawing.Point(188,
 16);
            this.textBox1.Multiline = true;
            this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
           
            this.textBox1.Size = new System.Drawing.Size(420,
 496);
            this.textBox1.TabIndex = 1;            
            this.ClientSize = new System.Drawing.Size(616,
 525);            
            this.Controls.Add(this.textBox1);
            this.Controls.Add(this.listBox1);
            
            this.Text = "Select a PowerStatus property to
 get the value of";                   
        }

        [STAThread]
        static void Main() 
        {
            Application.Run(new PowerStatusBrowserForm());
        }
    }
}
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::ComponentModel;
using namespace System::Drawing;
using namespace System::Reflection;
using namespace System::Windows::Forms;

public ref class PowerStatusBrowserForm: public
 System::Windows::Forms::Form
{
private:
   System::Windows::Forms::ListBox^ listBox1;
   System::Windows::Forms::TextBox^ textBox1;

public:
   PowerStatusBrowserForm()
   {
      this->SuspendLayout();
      InitForm();

      //Add each property of the PowerStatus class to the list box.
      Type^ t = System::Windows::Forms::PowerStatus::typeid;
      array<PropertyInfo^>^pi = t->GetProperties();
      for ( int i = 0; i < pi->Length;
 i++ )
         listBox1->Items->Add( pi[ i ]->Name );
      textBox1->Text = String::Format( "The PowerStatus class
 has {0} properties.\r\n", pi->Length );

      // Configure the list item selected handler for the list box to
 invoke a 
      // method that displays the value of each property.          
 
      listBox1->SelectedIndexChanged += gcnew EventHandler( this,
 &PowerStatusBrowserForm::listBox1_SelectedIndexChanged );
      this->ResumeLayout( false );
   }

private:
   void listBox1_SelectedIndexChanged( Object^ /*sender*/, EventArgs^
 /*e*/ )
   {
      // Return if no item is selected.
      if ( listBox1->SelectedIndex == -1 )
            return;

      // Get the property name from the list item
      String^ propname = listBox1->Text;

      // Display the value of the selected property of the PowerStatus
 type.
      Type^ t = System::Windows::Forms::PowerStatus::typeid;
      array<PropertyInfo^>^pi = t->GetProperties();
      PropertyInfo^ prop = nullptr;
      for ( int i = 0; i < pi->Length;
 i++ )
         if ( pi[ i ]->Name == propname )
         {
            prop = pi[ i ];
            break;
         }

      Object^ propval = prop->GetValue( SystemInformation::PowerStatus, nullptr
 );
      textBox1->Text = String::Format( "{0}\r\nThe value of the {1} property
 is: {2}", textBox1->Text, propname, propval );
   }

   void InitForm()
   {
      // Initialize the form settings
      this->listBox1 = gcnew System::Windows::Forms::ListBox;
      this->textBox1 = gcnew System::Windows::Forms::TextBox;
      this->listBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top
 | System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left
 | System::Windows::Forms::AnchorStyles::Right);
      this->listBox1->Location = System::Drawing::Point(
 8, 16 );
      this->listBox1->Size = System::Drawing::Size( 172,
 496 );
      this->listBox1->TabIndex = 0;
      this->textBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top
 | System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Right);
      this->textBox1->Location = System::Drawing::Point(
 188, 16 );
      this->textBox1->Multiline = true;
      this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
      this->textBox1->Size = System::Drawing::Size( 420,
 496 );
      this->textBox1->TabIndex = 1;
      this->ClientSize = System::Drawing::Size( 616, 525 );
      this->Controls->Add( this->textBox1
 );
      this->Controls->Add( this->listBox1
 );
      this->Text = "Select a PowerStatus property to get
 the value of";
   }
};

[STAThread]
int main()
{
   Application::Run( gcnew PowerStatusBrowserForm );
}
package PowerStatusBrowser;

import System.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Drawing.*;
import System.Reflection.*;
import System.Windows.Forms.*;

public class PowerStatusBrowserForm extends
 System.Windows.Forms.Form
{
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.TextBox textBox1;

    public PowerStatusBrowserForm()
    {
        this.SuspendLayout();
        InitForm();

        //Add each property of the PowerStatus class to the list box.
        Type t = System.Windows.Forms.PowerStatus.class.ToType();
        PropertyInfo pi[] = t.GetProperties();
        for (int i = 0; i < pi.get_Length();
 i++) {
            listBox1.get_Items().Add(pi[i].get_Name());
        }
        textBox1.set_Text("The PowerStatus class has "
 
            + System.Convert.ToString(pi.get_Length()) + " properties.\r\n");

        // Configure the list item selected handler for the list box
 to invoke 
        // a method that displays the value of each property.      
     
        listBox1.add_SelectedIndexChanged(
            new EventHandler(listBox1_SelectedIndexChanged));
        this.ResumeLayout(false);
    } //PowerStatusBrowserForm

    private void listBox1_SelectedIndexChanged(Object
 sender, EventArgs e)
    {
        // Return if no item is selected.
        if (listBox1.get_SelectedIndex() == -1) {
            return;
        }
        // Get the property name from the list item
        String propName = listBox1.get_Text();

        // Display the value of the selected property of the PowerStatus
 type.
        Type t = System.Windows.Forms.PowerStatus.class.ToType();
        PropertyInfo pi[] = t.GetProperties();
        PropertyInfo prop = null;
        for (int i = 0; i < pi.get_Length();
 i++) {
            if (pi[i].get_Name().Equals(propName)) {
                prop = pi[i];
                break;
            }
        }

        Object propVal = prop.GetValue(SystemInformation.get_PowerStatus(),
            null);
        textBox1.set_Text(textBox1.get_Text() + "\r\nThe value of the "
 
            + propName + " property is: " + propVal.ToString());
    } //listBox1_SelectedIndexChanged

    private void InitForm()
    {
        // Initialize the form settings
        this.listBox1 = new System.Windows.Forms.ListBox();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.listBox1.set_Anchor((System.Windows.Forms.AnchorStyles)(
            System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.
            AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.
            Left | System.Windows.Forms.AnchorStyles.Right));
        this.listBox1.set_Location(new System.Drawing.Point(8,
 16));
        this.listBox1.set_Size(new System.Drawing.Size(172,
 496));
        this.listBox1.set_TabIndex(0);
        this.textBox1.set_Anchor((System.Windows.Forms.AnchorStyles)(
            System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.
            AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right));
        this.textBox1.set_Location(new System.Drawing.Point(188,
 16));
        this.textBox1.set_Multiline(true);
        this.textBox1.set_ScrollBars(System.Windows.Forms.ScrollBars.Vertical);
        this.textBox1.set_Size(new System.Drawing.Size(420,
 496));
        this.textBox1.set_TabIndex(1);
        this.set_ClientSize(new System.Drawing.Size(616,
 525));
        this.get_Controls().Add(this.textBox1);
        this.get_Controls().Add(this.listBox1);
        this.set_Text("Select a PowerStatus property to get
 the value of");
    } //InitForm

    /** @attribute STAThread()
     */
    public static void main(String[]
 args)
    {
        Application.Run(new PowerStatusBrowserForm());
    } //main
} //PowerStatusBrowserForm
継承階層継承階層
System.Object
  System.Windows.Forms.PowerStatus
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PowerStatus メンバ
System.Windows.Forms 名前空間
PowerStatus
SystemInformation
PowerLineStatus 列挙
BatteryChargeStatus 列挙
PowerState 列挙

PowerStatus プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

PowerStatus クラス
System.Windows.Forms 名前空間
PowerStatus
SystemInformation
PowerLineStatus 列挙
BatteryChargeStatus 列挙
PowerState 列挙

PowerStatus メソッド


PowerStatus メンバ

現在のシステム電源の状態に関する情報示します

PowerStatus データ型公開されるメンバを以下の表に示します


パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

PowerStatus クラス
System.Windows.Forms 名前空間
PowerStatus
SystemInformation
PowerLineStatus 列挙
BatteryChargeStatus 列挙
PowerState 列挙



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「PowerStatus」の関連用語

PowerStatusのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



PowerStatusのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS