Ing between C ++ and C # Data Structure Types
Online Article 1. ing between APIs and C # Data Structure Types
Data Type ing between APIs and C # |
API data type |
Type description |
C # type |
API data type |
Type description |
C # type |
Word |
16-bit unsigned integer |
Ushort |
Char |
Character |
Char |
Long |
32-bit unsigned integer |
Int |
Dwordlong |
64-bit long integer |
Long |
DWORD |
32-bit unsigned integer |
Uint |
HDC |
Device description table handle |
Int |
Handle |
Handle, 32-bit integer |
Int |
Hgdiobj |
GDI object handle |
Int |
Uint |
32-bit unsigned integer |
Uint |
Hinstance |
Instance handle |
Int |
Bool |
32-bit Boolean integer |
Bool |
Hwm |
Window handle |
Int |
Lpstr |
32-bit pointer to a character |
String |
Hparam |
32-bit message Parameters |
Int |
Lpcstr |
32-bit pointer to a common character |
String |
Lparam |
32-bit message Parameters |
Int |
Byte |
Bytes |
Byte |
Wparam |
32-bit message Parameters |
Int |
C # Data Type
Simple Type |
Description |
Example |
Sbyte |
8-bit signed integer |
Sbyte val = 12; |
Short |
16-bit signed integer |
Short val = 12; |
Int |
32-bit signed integer |
Int val = 12; |
Long |
64-bit signed integer |
Long val1 = 12; long val2 = 34l; |
Byte |
8-bit unsigned integer |
Byte val1 = 12; byte val2 = 34u; |
Ushort |
16-bit unsigned integer |
Ushort val1 = 12; ushort val2 = 34u; |
Uint |
32-bit unsigned integer |
Uint val1 = 12; uint val2 = 34u; |
Ulong |
64-bit unsigned integer |
Ulong val1 = 12; ulong val2 = 34u; ulong val3 = 56l; ulong val4 = 78ul; |
Float |
32-Bit Single-precision floating point number |
Float val = 1.23f; |
Double |
64-bit double-precision floating point number |
Double val1 = 1.23; double val2 = 4.56d; |
L |
Boolean Type |
Bool val1 = true; bool val2 = false; |
Char |
Character type, Unicode encoding |
Char val = 'H '; |
Decimal |
128-bit decimal type of 28 valid digits |
Decimal val = 1.23 m; |
Article 2:
C # data type ing when Windows API is called
Bool = system. int32
Boolean = system. int32
Byte = system. uint16
Char = system. int16
Colorref = system. uint32
DWORD = system. uint32
Dword32 = system. uint32
Dword64 = system. uint64
Float = system. Float
Haccel = system. intptr
Handle = system. intptr
Hbitmap = system. intptr
Hbrush = system. intptr
Hconv = system. intptr
Hconvlist = system. intptr
Hcursor = system. intptr
HDC = system. intptr
Hddedata = system. intptr
Hdesk = system. intptr
Hdrop = system. intptr
Hdwp = system. intptr
Henhmetafile = system. intptr
Hfile = system. intptr
Hfont = system. intptr
Hgdiobj = system. intptr
Hglobal = system. intptr
Hhook = system. intptr
Hicon = system. intptr
Himagelist = system. intptr
Himc = system. intptr
Hinstance = system. intptr
Hkey = system. intptr
Hlocal = system. intptr
Hmenu = system. intptr
Hmetafile = system. intptr
Hmodule = system. intptr
Hmonitor = system. intptr
Hpalette = system. intptr
Hpen = system. intptr
Hrgn = system. intptr
Hrsrc = system. intptr
Hsz = system. intptr
Hwinsta = system. intptr
Hwnd = system. intptr
Int = system. int32
Int32 = system. int32
Int64 = system. int64
Long = system. int32
Long32 = system. int32
Long64 = system. int64
Longlong = system. int64
Lparam = system. intptr
Lpbool = system. int16 []
Lpbyte = system. uint16 []
Lpcolorref = system. uint32 []
Lpcstr = system. String
Lpctstr = system. String
Lpcvoid = system. uint32
Lpcwstr = system. String
Lpdword = system. uint32 []
Lphandle = system. uint32
Lpint = system. int32 []
Lplong = system. int32 []
Lpstr = system. String
Lptstr = system. String
Lpvoid = system. uint32
Lpword = system. int32 []
Lpwstr = system. String
Lresult = system. intptr
Pbool = system. int16 []
Pboolean = system. int16 []
Pbyte = system. uint16 []
Pchar = system. Char []
Pcstr = system. String
Pctstr = system. String
Pcwch = system. uint32
Pcwstr = system. uint32
Pdword = system. int32 []
Pfloat = system. Float []
Phandle = system. uint32
Phkey = system. uint32
Pint = system. int32 []
Plcid = system. uint32
Plong = system. int32 []
Pluid = system. uint32
Pshort = system. int16 []
Pstr = system. String
Ptbyte = system. Char []
Ptchar = system. Char []
Ptstr = system. String
Puchar = system. Char []
Puint = system. uint32 []
Pulong = system. uint32 []
Pushort = system. uint16 []
Pvoid = system. uint32
Pwchar = system. Char []
Pword = system. int16 []
Pwstr = system. String
Regsam = system. uint32
SC _handle = system. intptr
SC _lock = system. intptr
Short = system. int16
Size_t = system. uint32
Ssize _ = system. uint32
Tbyte = system. Char
Tchar = system. Char
Uchar = system. byte
Uint = system. uint32
Uint32 = system. uint32
Uint64 = system. uint64
Ulong = system. uint32
Ulong32 = system. uint32
Ulong64 = system. uint64
Ulonglong = system. uint64
Ushort = system. uint16
WORD = system. uint16
Wparam = system. intptr
Appendix: an API declaration example
[Dllimport ("kernel32.dll")]
Public static extern system. uint32 virtualallocex (
System. intptr hprocess,
System. uint32 lpaddress,
System. uint32 dwsize,
System. uint32 flallocationtype,
System. uint32 flprotect
);