次の方法で共有


ManagementClass.GetStronglyTypedClassCode メソッド (Boolean, Boolean)

指定した WMI クラスの厳密に型指定されたクラスを生成します。

Overloads Public Function GetStronglyTypedClassCode( _
   ByVal includeSystemClassInClassDef As Boolean, _   ByVal systemPropertyClass As Boolean _) As CodeTypeDeclaration
[C#]
public CodeTypeDeclaration GetStronglyTypedClassCode(boolincludeSystemClassInClassDef,boolsystemPropertyClass);
[C++]
public: CodeTypeDeclaration* GetStronglyTypedClassCode(boolincludeSystemClassInClassDef,boolsystemPropertyClass);
[JScript]
public function GetStronglyTypedClassCode(
   includeSystemClassInClassDef : Boolean,systemPropertyClass : Boolean) : CodeTypeDeclaration;

パラメータ

  • includeSystemClassInClassDef
    管理システム プロパティのクラスを格納する必要がある場合は true 。それ以外の場合は false
  • systemPropertyClass
    生成したクラスがシステム プロパティを管理する場合は true 。それ以外の場合は false

戻り値

厳密に型指定されたクラスの宣言を表す CodeTypeDeclaration インスタンス。

使用例

 
using System;
using System.Management; 
using System.CodeDom;
using System.IO;
using System.CodeDom.Compiler;
using Microsoft.CSharp;

void GenerateCSharpCode()
{
      string strFilePath = "C:\\temp\\LogicalDisk.cs";
      CodeTypeDeclaration ClsDom;
    
      ManagementClass cls1 = new ManagementClass(null,"Win32_LogicalDisk",null);
      ClsDom = cls1.GetStronglyTypedClassCode(false,false);
    
      ICodeGenerator cg = (new CSharpCodeProvider()).CreateGenerator ();
      CodeNamespace cn = new CodeNamespace("TestNamespace");
    
      // Add any imports to the code
      cn.Imports.Add (new CodeNamespaceImport("System"));
      cn.Imports.Add (new CodeNamespaceImport("System.ComponentModel"));
      cn.Imports.Add (new CodeNamespaceImport("System.Management"));
      cn.Imports.Add(new CodeNamespaceImport("System.Collections"));
   
      // Add class to the namespace
      cn.Types.Add (ClsDom);
    
      //Now create the filestream (output file)
      TextWriter tw = new StreamWriter(new
      FileStream (strFilePath,FileMode.Create));
    
      // And write it to the file
      cg.GenerateCodeFromNamespace (cn, tw, new CodeGeneratorOptions());

      tw.Close();
}
   

[Visual Basic, C++, JScript] Visual Basic、C++、および JScript のサンプルはありません。C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

ManagementClass クラス | ManagementClass メンバ | System.Management 名前空間 | ManagementClass.GetStronglyTypedClassCode オーバーロードの一覧