ComRegisterFunctionAttribute クラス

定義

COM から使用するアセンブリを登録するときに呼び出すメソッドを指定します。これにより、登録プロセス中にユーザーが記述したコードを実行できます。

public ref class ComRegisterFunctionAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
public sealed class ComRegisterFunctionAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ComRegisterFunctionAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
type ComRegisterFunctionAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ComRegisterFunctionAttribute = class
    inherit Attribute
Public NotInheritable Class ComRegisterFunctionAttribute
Inherits Attribute
継承
ComRegisterFunctionAttribute
属性

次の例では、適切なシグネチャを持つメソッドに ComRegisterFunctionAttributeComUnregisterFunctionAttribute を適用する方法を示します。

using namespace System;
using namespace System::Runtime::InteropServices;
public ref class MyClassThatNeedsToRegister
{
public:

   [ComRegisterFunctionAttribute]
   static void RegisterFunction( Type^ t )
   {
      
      //Insert code here.
   }


   [ComUnregisterFunctionAttribute]
   static void UnregisterFunction( Type^ t )
   {
      
      //Insert code here.
   }

};
using System;
using System.Runtime.InteropServices;

public class MyClassThatNeedsToRegister
{
   [ComRegisterFunctionAttribute]
   public static void RegisterFunction(Type t)
   {
      //Insert code here.
   }

   [ComUnregisterFunctionAttribute]
   public static void UnregisterFunction(Type t)
   {
      //Insert code here.
   }
}
Imports System.Runtime.InteropServices

Public Class MyClassThatNeedsToRegister
    
    <ComRegisterFunctionAttribute()> Public Shared Sub _
      RegisterFunction(t As Type)
        'Insert code here.
    End Sub
    
    <ComUnregisterFunctionAttribute()> Public Shared Sub _
      UnregisterFunction(t As Type)
        'Insert code here.
    End Sub
End Class

注釈

この属性はメソッドに適用できます。

ComRegisterFunctionAttribute を使用すると、COM クライアントの要件に合わせて任意の登録コードを追加できます。 たとえば、Microsoft.Win32 名前空間の登録関数を使用してレジストリを更新できます。 登録方法を指定する場合は、登録解除メソッドにも System.Runtime.InteropServices.ComUnregisterFunctionAttribute を適用する必要があります。これは、登録メソッドで実行された操作を元に戻します。

.NET Framework: 共通言語ランタイムは、Regasm.exe (Assembly Registration) ツール) または RegistrationServices.RegisterAssembly メソッドを使用して、含まれるアセンブリが (直接または間接的に) 登録されるときに、この属性を持つメソッドを呼び出します。

.NET Core: 共通言語ランタイムは、RegSvr32.exe ツールを使用して、含まれるアセンブリの COM ホストが登録されている場合に、この属性を持つメソッドを呼び出します。

この属性は、次の特性を持つメソッドにのみ適用できます。

  • スコープ: 任意 (パブリック、プライベートなど)。

  • タイプ: static

  • パラメーター: 単一の Type パラメーターまたは String パラメーター型を受け入れます。

  • 戻り値の型: void

コンストラクター

名前 説明
ComRegisterFunctionAttribute()

ComRegisterFunctionAttribute クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
TypeId

派生クラスで実装されている場合は、この Attributeの一意の識別子を取得します。

(継承元 Attribute)

メソッド

名前 説明
Equals(Object)

このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 Attribute)
GetHashCode()

このインスタンスのハッシュ コードを返します。

(継承元 Attribute)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
IsDefaultAttribute()

派生クラスでオーバーライドされた場合、このインスタンスの値が派生クラスの既定値であるかどうかを示します。

(継承元 Attribute)
Match(Object)

派生クラスでオーバーライドされた場合、このインスタンスが指定したオブジェクトと等しいかどうかを示す値を返します。

(継承元 Attribute)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

明示的なインターフェイスの実装

名前 説明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

一連の名前を対応する一連のディスパッチ識別子に割り当てます。

(継承元 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

インターフェイスの型情報を取得するために使用できるオブジェクトの型情報を取得します。

(継承元 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。

(継承元 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

オブジェクトによって公開されるプロパティとメソッドへのアクセスを提供します。

(継承元 Attribute)

適用対象

こちらもご覧ください