Data types

The same rules as unmanaged functions apply for most data types, with the following additions:

Unmanaged Data Type

Managed Data Type

Supply Data

Receive Data

GUID

System.Guid

System.Guid

IUnknown

TObject

TObject

IDispatch

TObject

TObject

Interface TObject TObject

Variant

TObject

TObject

SafeArray (of type)

array of <type>

array of <type>

BSTR

String

String

Using the MarshalAsAttribute custom attribute is required for some of the above uses of TObject, specifying the exact unmanaged type (such as UnmanagedType.IUnknown,

UnmanagedType.IDispatch or UnmanagedType.Interface). This is also true for certain array types. An example of explicitly specifying the unmanaged type is the Next method of the IEnumString interface. The Win32 API declares Next as follows:

HRESULT Next( ULONG celt, LPOLESTR * rgelt, ULONG * pceltFetched

In Delphi 8 for .NET the declaration would be:

function Next(celt: Longint;

[out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0)] rgelt: array of string; out pceltFetched: Longint ): Integer;

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook


Post a comment