LCIDConversionAttribute LCIDConversionAttribute LCIDConversionAttribute LCIDConversionAttribute Class

Definición

Indica que la firma no administrada de un método espera un parámetro de identificador de configuración regional (LCID).Indicates that a method's unmanaged signature expects a locale identifier (LCID) parameter.

public ref class LCIDConversionAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class LCIDConversionAttribute : Attribute
type LCIDConversionAttribute = class
    inherit Attribute
Public NotInheritable Class LCIDConversionAttribute
Inherits Attribute
Herencia
LCIDConversionAttributeLCIDConversionAttributeLCIDConversionAttributeLCIDConversionAttribute
Atributos

Ejemplos

El ejemplo siguiente muestra las traducciones de firma diferente en función de los distintos valores proporcionados a LCIDConversionAttribute.The following example demonstrates different signature translations based on different values supplied to 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
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

Comentarios

Este atributo se puede aplicar a métodos.You can apply this attribute to methods.

Este atributo indica que el contador de referencias debe esperar un LCID que se pasarán después del argumento de método designado.This attribute indicates that the marshaler should expect an LCID to be passed after the designated method argument. Cuando se realizan llamadas desde código administrado a no administrado, el contador de referencias proporciona el argumento LCID automáticamente.When calls are made from managed to unmanaged code, the marshaler supplies the LCID argument automatically.

Constructores

LCIDConversionAttribute(Int32) LCIDConversionAttribute(Int32) LCIDConversionAttribute(Int32) LCIDConversionAttribute(Int32)

Inicializa una nueva instancia de la clase LCIDConversionAttribute con la posición del LCID en la firma no administrada.Initializes a new instance of the LCIDConversionAttribute class with the position of the LCID in the unmanaged signature.

Propiedades

TypeId TypeId TypeId TypeId

Cuando se implementa en una clase derivada, obtiene un identificador único para este Attribute.When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)
Value Value Value Value

Obtiene la posición del argumento de LCID en la firma no administrada.Gets the position of the LCID argument in the unmanaged signature.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Devuelve un valor que indica si esta instancia es igual que un objeto especificado.Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Devuelve el código hash de esta instancia.Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

Si se reemplaza en una clase derivada, indica si el valor de esta instancia es el valor predeterminado de la clase derivada.When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

Cuando se invalida en una clase derivada, devuelve un valor que indica si esta instancia es igual a un objeto especificado.When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Implementaciones de interfaz explícitas

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Obtiene la información de tipos de un objeto, que puede utilizarse para obtener la información de tipos de una interfaz.Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

Se aplica a