COM Data Types
The following table shows data types used in COM and their corresponding .NET Framework built-in value types or classes. Any type not explicitly identified in this table is converted to an Int32 system type. For corresponding types in Visual Basic 2005, C#, and C++, see the Introduction to the .NET Framework Class Library.
COM value type |
COM reference type |
System type |
---|---|---|
bool |
bool * |
|
char, small |
char *, small * |
|
short |
short * |
|
long, int |
long *, int * |
|
Hyper |
hyper * |
|
unsigned char, byte |
unsigned char *, byte * |
|
wchar_t, unsigned short |
wchar_t *, unsigned short * |
|
unsigned long, unsigned int |
unsigned long *, unsigned int * |
|
unsigned hyper |
unsigned hyper * |
|
float |
float * |
|
double |
double * |
|
VARIANT_BOOL |
VARIANT_BOOL * |
|
void * |
void ** |
|
HRESULT |
HRESULT * |
System.Int16 or System.IntPtr |
SCODE |
SCODE * |
System.Int32 |
BSTR |
BSTR * |
|
LPSTR or [string, …] char * |
LPSTR * |
System.String |
LPWSTR or [string, …] wchar_t * |
LPWSTR * |
System.String |
VARIANT |
VARIANT * |
|
DECIMAL |
DECIMAL * |
|
DATE |
DATE * |
|
GUID |
GUID * |
|
CURRENCY |
CURRENCY * |
|
IUnknown * |
IUnknown ** |
System.Object |
IDispatch * |
IDispatch ** |
System.Object |
SAFEARRAY(type) |
SAFEARRAY(type) * |
type[] |
The following table lists COM value and reference types that convert to corresponding element types. For example, a COM coclass automatically maps to a managed class with the same name.
COM value type |
COM reference type |
Element type |
---|---|---|
Typedef BaseType MyType |
ByRef BaseType |
BaseType |
MyStruct |
ByRef VALUETYPE<MyStruct> |
valuetype<MyStruct> |
MyEnum |
ByRef VALUETYPE<MyEnum> |
valuetype<MyEnum> |
MyInterface * |
ByRef CLASS <MyInterface> |
Class <MyInterface> |
MyCoClass |
ByRef CLASS <_Class> |
Class <_Class> |
See Also
Concepts
Customizing COM Callable Wrappers
Customizing Runtime Callable Wrappers