This attribute (and, in C#, the keyword “extern”) specifies that a method definition is implemented externally (usually in a DLL). Apply this attribute to a method that has been declared (but not defined) to specify the DLL name and entry point in which the method can be found.
The attribute can be customized in a number of different ways to help
control the binding against the external method. The
CallingConvention value dictates how the
parameters to the call (and return value coming back) should be sent
to the function.
for calling into
which is most of the Win32 API set) and
CallingConvention.Cdecl (used for calling
functions declared directly from C or C++) are the two most common
CharSet value indicates which
character set parameters to the call are expected to be, either
two-byte Unicode or one-byte ANSI.
indicates the name of the exported function from the DLL to bind to
(normally this is guessed from the name of the .NET-declared method),
ExactSpelling indicates whether the .NET
compiler should attempt to “best
match” a declared
method against a possible set of exported functions. The
PreserveSig value indicates how .NET should treat
[retval]-declared parameters. By default, the .NET
compilers ignore the HRESULT return value on IDL-declared methods and
[retval]-declared parameter as the return