Windows APIs to Xojo data type conversion

Here is a list of Windows types related to their Xojo equivalent, this is useful when you perform a Declare in Xojo.

Rule of thumb: ByRef and ByVal are only applicable to intrinsic data types (Integer, String, Double, Structures etc.) All arrays and object types are reference types, effectively behaving as if ByRef was used with an intrinsic data type.

If a parameter specifies OUT and is an intrinsic data type then it will need a ByRef so the value can be modified.

Remember: If you are calling a 32bit library from a 64bit application you may need to use use Int32 instead of Integer and UInt32 instead of UInteger.

If you find this useful, grab the Xojo Reformat Code Script and perform these conversions as you type.

Key: ? needs confirmation
References Used

Please post here if you spot an error.

Data typeXojo typeCode
ACCESS_MASKUInt32name As UInt32
APIENTRYSee WINAPI
ATOMUInt16name As UInt16
BOOLInt32name As Int32
value=CType(name, Boolean)
or
name As Boolean (if binary values)
BOOLEANUInt8name As UInt8
value=CType(name, Boolean)
or
name As Boolean (if binary values)
BYTEBytename As Byte
CALLBACKSee WINAPI
CCHARInt8name As Int8
CHARInt8name As Int8
CHAR *See PCHAR or LPTSTR
COLORREFUInt32 or Color ?See Color
CONSTConstname As (check call)
DOUBLEDoublename As Double
DWORDUInt32name As UInt32
DWORDLONGUInt64name As UInt64
DWORD_PTRUIntegername As UInteger
DWORD32UInt32name As UInt32
DWORD64UInt64name As UInt64
ENUMInt32Used for enumeration that have no defined type
EXECUTION_STATEUInt32name As UInt32
FARPROCIntegername As Integer
FILEOP_FLAGSUInt16name As UInt16
FLOATSinglename As Single
HACCELIntegername As Integer
HALF_PTRInt16 (x32)
Int32 (x64)
Let me know if you find a use for this
HANDLEIntegername As Integer
HBITMAPIntegername As Integer
HBRUSHIntegername As Integer
HCOLORSPACEIntegername As Integer
HCONVIntegername As Integer
HCONVLISTIntegername As Integer
HCURSORIntegername As Integer
HDCIntegername As Integer
HDDEDATAIntegername As Integer
HDESKIntegername As Integer
HDROPIntegername As Integer
HDWPIntegername As Integer
HENHMETAFILEIntegername As Integer
HFILEInt32name As Int32
HFONTIntegername As Integer
HGDIOBJIntegername As Integer
HGLOBALIntegername As Integer
HHOOKIntegername As Integer
HICONIntegername As Integer
HINSTANCEIntegername As Integer
HKEYIntegername As Integer
HKLIntegername As Integer
HLOCALIntegername As Integer
HMENUIntegername As Integer
HMETAFILEIntegername As Integer
HMODULEIntegername As Integer
HMONITORInteger (W2000 onwards)name As Integer
HPALETTEIntegername As Integer
HPENIntegername As Integer
HRESULTInt32name As Int32
HRGNIntegername As Integer
HRSRCIntegername As Integer
HSZIntegername As Integer
HWINSTAIntegername As Integer
HWNDInteger or Ptrname as Integer
name As Ptr
INTInt32name As Int32
INT_PTRIntegername As Integer
INT8Int8name As Int8
INT16Int16name As Int16
INT32Int32name As Int32
INT64Int64name As Int64
LANGIDUInt16name As UInt16
LCIDUInt32name As UInt32
LCTYPEUInt32name As UInt32
LGRPIDUInt32name As UInt32
LONGInt32name As Int32
LONGLONGInt64name As Int64
LONG_PTRIntegername As Integer
LONG32Int32name As Int32
LONG64Int64name As Int64
LPARAMIntegername As Integer
LPBOOLInt32ByRef name As Int32
value=CType(name, Boolean)
or
name As Ptr
or
name As Integer
LPBYTEByteByRef name As Byte
or
name As Ptr
or
name As Integer
LPCOLORREFUInt32 or
Color ?
ByRef name As UInt32
name As Color See Color
LPCSTRCStringname As CString
LPCTSTRWStringname As WString
LPCVOIDUInt32 or
See PVOID
Const name As (check call) = xxx
ByRef name As (check call) (if intrinsic)
name As (check call) (if NOT intrinsic)
LPCWSTRWStringname As WString
LPDWORDUInt32ByRef name As UInt32
LPHANDLEIntegerByRef name As Integer
LPINTInt32ByRef name As Int32
LPLONGInt32ByRef name As Long
LPSTRCStringname As CString
LPTSTRWString
CString

Ptr
name As WString (unicode)
name As CString (ansi)
If a value is returned, use:
ByRef name As Ptr
Dim tmp As New MemoryBlock(256)
Dim p as Ptr = tmp
//Make your call passing in p
system.debuglog(tmp.CString(0))

Note: allocate 2x more space for WString
LPVOIDSee PVOID
LPWORDUInt16ByRef UInt16
LPWSTRWStringSee LPTSTR
LRESULTIntegername As Integer
NTSTATUSInt32name As Int32
NTSYSAPIInt32name As Int32
PBOOLInt32ByRef name As Int32
value=CType(name, Boolean)
PBOOLEANUInt8ByRef name As UInt8
value=CType(name, Boolean)
PBYTEByteByRef name As Byte
PCHARCStringname As CString
PCSTRCStringname As CString
PCTSTRWString
CString
name As WString (unicode)
name As CString (ansi)
PCWSTRWStringname As WString
PDWORDUInt32ByRef name As UInt32
PDWORDLONGUInt64ByRef name As UInt64
PDWORD_PTRUIntegerByRef name As UInteger
PDWORD32UInt32ByRef name As UInt32
PDWORD64UInt64ByRef name As UInt64
PFLOATSingleByRef name As Single
PHALF_PTRInt16 (x86)
Int32 (x64)
ByRef name As Int16
ByRef name As Int32
PHANDLEIntegerByRef name As Integer
PHKEYIntegerByRef name As Integer
PINTInt32ByRef name As Int32
PINT_PTRIntegerByRef name As Integer
PINT8Int8ByRef name As Int8
PINT16Int16ByRef name As Int16
PINT32Int32ByRef name As Int32
PINT64Int64ByRef name As Int64
PLCIDUInt32ByRef name As UInt32
PLONGInt32ByRef name As Int32
PLONGLONGInt64ByRef name As Int64
PLONG_PTRIntegerByRef name As Integer
PLONG32Int32ByRef name As Int32
PLONG64Int64ByRef name As Int64
POINTER_32IntegerByRef name As Integer
POINTER_64IntegerByRef name As Integer
POINTER_SIGNEDIntegername As Integer
POINTER_UNSIGNEDUIntegername As UInteger
PSHORTInt16ByRef name As Int16
PSIZE_TUIntegerByRef name As UInteger
PSSIZE_TIntegerByRef name As Integer
PSTRCStringname As CString
PTBYTEUInt16
Int8
ByRef name As UInt16 (unicode)
ByRef name As Int8 (ansi)
PTCHARUInt16
UInt8
ByRef name As UInt16 (unicode)
ByRef name As UInt8 (ansi)
PTSTRWString
CString
ByRef name As WString (unicode)
ByRef name As CString (ansi)
PUCHARUInt8ByRef name As UInt8
PUHALF_PTRUInt16 (x86)
UInt32 (x64)
ByRef name As UInt16
ByRef name As UInt32
PUINTUInt32ByRef name As UInt32
PUINT_PTRUIntegerByRef name As UInteger
PUINT8UInt8ByRef name As UInt8
PUINT16UInt16ByRef name As UInt16
PUINT32UInt32ByRef name As UInt32
PUINT64UInt64ByRef name As UInt64
PULONGUInt32ByRef name As UInt32
PULONGLONGUInt64ByRef name As UInt64
PULONG_PTRUIntegerByRef name As UInteger
PULONG32UInt32ByRef name As UInt32
PULONG64UInt64ByRef name As UInt64
PUSHORTUInt16ByRef name As UInt16
PVOIDPtr
(check call)
(check call)
name As Ptr (if using memoryblock)
ByRef name As (check call) (if intrinsic)
name As (check call) (if NOT intrinsic)
PWCHAR
WString
name As WString
PWORDUInt16ByRef name As UInt16
PWSTRWString
Ptr
ByRef name As WString
name As Ptr (to memoryblock)
QWORDUInt64name As UInt64
REGSAMUInt32name As UInt32
SC_HANDLEIntegername As Integer
SC_LOCKSee PVOID
SERVICE_STATUS_HANDLEIntegername As Integer
SHORTInt16name As Int16
SIZE_TUIntegername As UInteger
SSIZE_TIntegername As Integer
TBYTEUInt16
Int8
ByRef name As UInt16 (unicode)
ByRef name As Int8 (ansi)
TCHARUInt16
UInt8
ByRef name As UInt16 (unicode)
ByRef name As Int8 (ansi)
UCHARUInt8name As UInt8
UHALF_PTRUInt16 (x86)
UInt32 (x64)
name As UInt16
name As UInt32
UINTUInt32name As UInt32
UINT_PTRUIntegername As UInteger
UINT8UInt8name As UInt8
UINT16UInt16name As UInt16
UINT32UInt32name As UInt32
UINT64UInt64name As UInt64
ULONGUInt32name As UInt32
ULONGLONGUInt64name As UInt64
ULONG_PTRUIntegername As UInteger
ULONG32UInt32name As UInt32
ULONG64UInt64name As UInt64
UNICODE_STRINGStructure ?Structure UNICODE_STRING
  Length As UInt16
  MaximumLength As UInt16
  Buffer As WString
End Structure
USHORTUInt16name As UInt16
USNInt64name As Int64
VARTYPE*UInt16name As UInt16
VOIDPtr
(check call)
(check call)
(nothing)
name As Ptr
ByRef name As (check call)
name As (check call)
(If there is no return, see Declare Sub)
WCHAR
WCHAR name[128]
UInt16
See code
name As UInt16
name As String * 256 (in a structure)
WINAPIMicrosoft Win32 API calls are all StdCall so you might need:
#Pragma X86CallingConvention StdCall
WNDPROCInteger or PtrhWnd as Integer
hWnd As Ptr
WORDUInt16name As UInt16
WPARAMUIntegername As UInteger
ByRef name As UInteger (if OUT)
STDMETHODCALLTYPE
STDAPICALLTYPE
STDMETHODCALLTYPE
STDAPICALLTYPE
STDAPI
STDAPI_(type)
STDMETHODIMP
STDMETHODIMP_(type)
Note:
#Pragma X86CallingConvention stdcall
STDMETHODVCALLTYPE
STDAPIVCALLTYPE
STDAPIVCALLTYPE
STDAPIV
STDAPIV_(type)
STDMETHODIMPV
STDMETHODIMPV_(type)
Note:
#Pragma X86CallingConvention cdecl

References
Microsoft – Windows API Index
Microsoft – Windows Data Types (see below for up to date edition)
Microsoft – Data Type Ranges
Microsoft – Integer Limits
Microsoft – New Data Types
Microsoft – WINVER List
Xojo – Integer Sizes (bottom of page)
Xojo Data Types
Microsoft – Windows Data Types (published and up to date edition)
Sign Extension (POINTER_32 and POINTER_64)
Rules for Using Pointers


2 thoughts on “Windows APIs to Xojo data type conversion

Leave a Reply

Your email address will not be published. Required fields are marked *