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
属性

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

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 (アセンブリ登録) ツールまたはメソッドを介して (直接または間接的に) 登録されている場合に、この属性を持つメソッドをRegistrationServices.RegisterAssembly呼び出します。

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

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

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

  • 次のコマンドを入力します: static

  • パラメーター: 1 つの 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)

適用対象

こちらもご覧ください