Unmanaged Exports

From The Elements Wiki
Jump to: navigation, search

This is an Oxygene Language topic about Oxygene for .NET
 

Oxygene Language: Intro | Structured Overview | Grammar | Keywords | Functions



The Unmanaged Exports attribute is a special attribute for .NET defined in the RemObjects.Elements.System namespace and can be used on class methods only and it will export the method as a native (win32) export. When using this, the cpu type of an assembly has to be set to x86 or x64. AnyCPU cannot work, as native jumps require native code. The (virtual) attribute is defined as:

type
  [AttributeUsage(AttributeTargets.Method)]
  RemObjects.Elements.System.UnmanagedExportAttribute = public class(System.Attribute)
  public
    constructor;
    constructor(aExportName: string);
    constructor(aExportName: string; aCallingConv: CallingConvention);
  end;

When omitted, the aExportName will match the method now and the aCallingConv will be stdcall.

To use this, simply apply the attribute:

[UnmanagedExport('ShowMessage')]
class method ShowMessage(aMsg: string);


See Also