LCIDConversionAttribute クラス

定義

メソッドのアンマネージ シグネチャにロケール識別子 (LCID) パラメーターが必要であることを示します。

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

次の例では、 に指定されたさまざまな値に基づいて、さまざまな署名変換を LCIDConversionAttribute示します。

using namespace System;
using namespace System::Runtime::InteropServices;
using namespace System::Reflection;

#define LCID_INSTALLED 1
#define LCID_SUPPORTED 2

ref class LCIDAttrSample
{
public:

   // Position of the LCID argument

   [DllImport("KERNEL32.DLL",EntryPoint="IsValidLocale",SetLastError=true,CharSet=CharSet::Auto)]
   [LCIDConversionAttribute(0)]
   static bool IsValidLocale( int dwFlags ); // options

   void CheckCurrentLCID()
   {
      MethodInfo^ mthIfo = this->GetType()->GetMethod( "IsValidLocale" );
      Attribute^ attr = Attribute::GetCustomAttribute( mthIfo, LCIDConversionAttribute::typeid );
      if ( attr != nullptr )
      {
         LCIDConversionAttribute^ lcidAttr = dynamic_cast<LCIDConversionAttribute^>(attr);
         Console::WriteLine( "Position of the LCID argument in the unmanaged signature: {0}", lcidAttr->Value );
      }

      bool res = IsValidLocale( LCID_INSTALLED );
      Console::WriteLine( "Result LCID_INSTALLED {0}", res );
      res = IsValidLocale( LCID_SUPPORTED );
      Console::WriteLine( "Result LCID_SUPPORTED {0}", res );
   }
};

int main()
{
   LCIDAttrSample^ smpl = gcnew LCIDAttrSample;
   smpl->CheckCurrentLCID();
}
using System;
using System.Runtime.InteropServices;
using System.Reflection;

class LCIDAttrSample
{
    private const int LCID_INSTALLED = 1;
    private const int LCID_SUPPORTED = 2;

    [DllImport("KERNEL32.DLL", EntryPoint="IsValidLocale", SetLastError = true, CharSet = CharSet.Auto)]
    [LCIDConversionAttribute(0)] // Position of the LCID argument
    public static extern bool IsValidLocale(
                                                uint dwFlags            // options
                                            );

    public void CheckCurrentLCID()
    {
        MethodInfo mthIfo = this.GetType().GetMethod("IsValidLocale");
        Attribute attr = Attribute.GetCustomAttribute(mthIfo,typeof(LCIDConversionAttribute));

        if( attr != null)
        {
            LCIDConversionAttribute lcidAttr = (LCIDConversionAttribute)attr;
            Console.WriteLine("Position of the LCID argument in the unmanaged signature: " + lcidAttr.Value.ToString());
        }

        bool res = IsValidLocale(LCID_INSTALLED);
        Console.WriteLine("Result LCID_INSTALLED " + res.ToString());
        res = IsValidLocale(LCID_SUPPORTED);
        Console.WriteLine("Result LCID_SUPPORTED " + res.ToString());
    }

    static void Main(string[] args)
    {
        LCIDAttrSample smpl = new LCIDAttrSample();
        smpl.CheckCurrentLCID();
    }
}

Imports System.Runtime.InteropServices
Imports System.Reflection

Class LCIDAttrSampler

    Const LCID_INSTALLED As Integer = 1
    Const LCID_SUPPORTED As Integer = 2

    <DllImport("KERNEL32.DLL", EntryPoint:="IsValidLocale", _
    SetLastError:=True, CharSet:=CharSet.Unicode, _
    CallingConvention:=CallingConvention.StdCall), _
    LCIDConversionAttribute(0)> _
    Public Shared Function IsValidLocale(ByVal dwFlags As Integer) As Boolean
    End Function

    Public Sub CheckCurrentLCID()
        Dim mthIfo As MethodInfo = Me.GetType().GetMethod("IsValidLocale")
        Dim attr As Attribute = Attribute.GetCustomAttribute(mthIfo, GetType(LCIDConversionAttribute))

        If Not(attr Is Nothing) Then
            Dim lcidAttr As LCIDConversionAttribute = CType(attr, LCIDConversionAttribute)
            Console.WriteLine("Position of the LCID argument in the unmanaged signature: " + lcidAttr.Value.ToString())
        End If

        Dim res As Boolean = IsValidLocale(LCID_INSTALLED)
        Console.WriteLine("Result LCID_INSTALLED " + res.ToString())
        res = IsValidLocale(LCID_SUPPORTED)
        Console.WriteLine("Result LCID_SUPPORTED " + res.ToString())
    End Sub

    Public Shared Sub Main()
        Dim smpl As LCIDAttrSampler = New LCIDAttrSampler()
        smpl.CheckCurrentLCID()
    End Sub

End Class

注釈

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

この属性は、指定されたメソッド引数の後に LCID が渡されることをマーシャラーが想定していることを示します。 マネージド コードからアンマネージド コードへの呼び出しが行われると、マーシャラーは LCID 引数を自動的に提供します。

コンストラクター

LCIDConversionAttribute(Int32)

アンマネージ シグネチャ内での LCID の位置を指定して、LCIDConversionAttribute クラスの新しいインスタンスを初期化します。

プロパティ

TypeId

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

(継承元 Attribute)
Value

アンマネージ シグネチャ内での引数 LCID の位置を取得します。

メソッド

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)

適用対象