[AttributeUsage(AttributeTargets.Method)] |
This attribute provides the information needed to call an exported function in an unmanaged DLL.
[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW", SetLastError=true, CharSet=CharSet.Unicode, ExactSpelling=true, CallingConvention=CallingConvention.StdCall)] public static extern bool MoveFile(String src, String dst);
ctor #1 | Initializes a new instance of the DllImportAttribute class with the name of the DLL containing the method to import. |
CallingConvention | Indicates the CallingConvention value used when passing method arguments to the unmanaged implementation. |
CharSet | Controls name mangling and indicates how to marshal String arguments to the method. |
EntryPoint | Indicates the name or ordinal of the DLL entry point to be called. |
ExactSpelling | Indicates whether the name of the entry point in the unmanaged DLL should be modified to correspond to the CharSet value specified in the DllImportAttribute.CharSet field. |
PreserveSig | Indicates the managed method signature should not be transformed into an unmanaged signature that returns an HRESULT, and may have an additional [out, retval] argument for the return value. |
SetLastError | Indicates that the callee will call the Win32 API SetLastError before returning from the attributed method. |
TypeId (inherited from System.Attribute) |
Read-only See base class member description: System.Attribute.TypeId When implemented in a derived class, gets a unique identifier for this Attribute. |
Value | Read-only Gets the name of the DLL file with the entry point. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Attribute) |
See base class member description: System.Attribute.GetHashCode Returns the hash code for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
IsDefaultAttribute (inherited from System.Attribute) |
See base class member description: System.Attribute.IsDefaultAttribute When overridden in a derived class, returns an indication whether the value of this instance is the default value for the derived class. |
Match (inherited from System.Attribute) |
See base class member description: System.Attribute.Match When overridden in a derived class, returns a value indicating whether this instance equals a specified object. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public DllImportAttribute( |
dllName
public CallingConvention CallingConvention;
|
See Calling Conventions in the MSDN library for details on each.
public CharSet CharSet;
|
public string EntryPoint;
|
public bool ExactSpelling;
|
public bool PreserveSig;
|
The definition of a method such as "HRESULT CoCreateInstance(...)" would set this to false. The default is true.
See the COM interop specification for details.
public bool SetLastError;
|
The runtime marshaler will call GetLastError and cache the value returned to prevent it from being overwritten by other API calls. Users can retrieve the error code by calling Marshal.GetLastWin32Error.
public virtual object TypeId {get;}
|
public string Value {get;}
|
~DllImportAttribute(); |
public override int GetHashCode(); |
public Type GetType(); |
public virtual bool IsDefaultAttribute(); |
The implementation of this method in a derived class compares the value of this instance to a standard, default value obtained by some means, then returns a Boolean value that indicates whether the value of this instance is equal to the standard. The standard value is typically coded as a constant in the implementation, or stored programmatically in a field used by the implementation.
obj
protected object MemberwiseClone(); |
public virtual string ToString(); |