ProgIdAttribute クラスとは? わかりやすく解説

ProgIdAttribute クラス

ユーザークラスの ProgID を指定することを許可します

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class, Inherited:=False)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 ProgIdAttribute
    Inherits Attribute
Dim instance As ProgIdAttribute
[AttributeUsageAttribute(AttributeTargets.Class, Inherited=false)]
 
[ComVisibleAttribute(true)] 
public sealed class ProgIdAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, Inherited=false)]
 
[ComVisibleAttribute(true)] 
public ref class ProgIdAttribute sealed : public
 Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=false)
 */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class ProgIdAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class, Inherited=false)
 
ComVisibleAttribute(true) 
public final class ProgIdAttribute extends
 Attribute
解説解説
使用例使用例

ProgIdAttributeクラス適用する方法次の例に示します。この例では、MyClassすべての属性取得しProgIdAttributeValue プロパティ出力します

   <ClassInterface(ClassInterfaceType.AutoDispatch), ProgId("InteropSample.MyClass")>
  _
   Public Class [MyClass]
      
      Public Sub New()
      End Sub 'New
   End Class '[MyClass]

   Class TestApplication
      
      Public Shared Sub
 Main()
         Try
            Dim attributes As AttributeCollection
            attributes = TypeDescriptor.GetAttributes(GetType([MyClass]))
            Dim progIdAttributeObj As ProgIdAttribute
 = CType(attributes(GetType(ProgIdAttribute)), ProgIdAttribute)
            Console.WriteLine(("ProgIdAttribute's value is set
 to : " + progIdAttributeObj.Value))
         Catch e As Exception
            Console.WriteLine(("Exception : " + e.Message.ToString()))
         End Try
      End Sub 'Main
   End Class 'TestApplication
End Namespace 'InteropSample 
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("InteropSample.MyClass")]
public class MyClass
{
    public MyClass() {}
}

class TestApplication
{      
   public static void Main()
   {
      try
      {
         AttributeCollection attributes;
         attributes = TypeDescriptor.GetAttributes(typeof(MyClass));
         ProgIdAttribute progIdAttributeObj = (ProgIdAttribute)attributes[typeof(ProgIdAttribute)];
         Console.WriteLine("ProgIdAttribute's value is set
 to : " + progIdAttributeObj.Value);
      }         
      catch(Exception e)
      {
         Console.WriteLine("Exception : " + e.Message);
      }
   }
}
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ProgId("InteropSample.MyClass")]
public ref class MyClass
{
public:
   MyClass(){}

};

int main()
{
   try
   {
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( MyClass::typeid );
      ProgIdAttribute^ progIdAttributeObj = dynamic_cast<ProgIdAttribute^>(attributes[
 ProgIdAttribute::typeid ]);
      Console::WriteLine( "ProgIdAttribute's value is set
 to : {0}", progIdAttributeObj->Value );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception : {0}", e->Message );
   }
}
/** @attribute ClassInterface(ClassInterfaceType.AutoDispatch)
 */
/** @attribute ProgId("InteropSample.MyClass")
 */
public class MyClass
{
    public MyClass()
    {
    } //MyClass
} //MyClass

class TestApplication
{
    public static void main(String[]
 args)
    {
        try {
            AttributeCollection attributes;
            attributes = TypeDescriptor.GetAttributes(MyClass.class.ToType());
            ProgIdAttribute progIdAttributeObj = (ProgIdAttribute)
                (attributes.get_Item(ProgIdAttribute.class.ToType()));
            Console.WriteLine("ProgIdAttribute's value is set
 to : " 
                + progIdAttributeObj.get_Value());
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception : " + e.get_Message());
        }
    } //main
} //TestApplication
継承階層継承階層
System.Object
   System.Attribute
    System.Runtime.InteropServices.ProgIdAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ProgIdAttribute メンバ
System.Runtime.InteropServices 名前空間



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

辞書ショートカット

すべての辞書の索引

「ProgIdAttribute クラス」の関連用語

ProgIdAttribute クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS