Delphi与C之间的类型对应表.其中左边是C类型,右边是对应的Delphi类型:
ABC -> TABC
ACCEL -> TAccel
ATOM -> TAtom
BITMAP -> TBitMap
BITMAPCOREHEADER -> TBitmapCoreHeader
BITMAPCOREINFO -> TBitmapCoreInfo
BITMAPFILEHEADER -> TBitmapFileHeader
BITMAPINFO -> TBitmapInfo
BITMAPINFOHEADER -> TBitmapInfoHeader
BOOL -> Bool
CBT_CREATEWND -> TCBT_CreateWnd
CBTACTIVATESTRUCT -> TCBTActivateStruct
CHAR -> Char
CHAR* -> PChar
CLIENTCREATESTRUCT -> TClientCreateStruct
COLORREF -> TColorRef
COMPAREITEMSTRUCT -> TCompareItemStruct
COMSTAT -> TComStat
CREATESTRUCT -> TCreateStruct
CTLINFO -> TCtlInfo
CTLSTYLE -> TCtlStyle
CTLtype -> TCtltype
DCB -> TDCB
DDEAACK -> TDDEAck
DDEADVISE -> TDDEAdvise
DDEDATA -> TDDEData
DDEPOKE -> TDDEPoke
DEBUGHOOKINFO -> TDebugHookInfo
DELETEITEMSTRUCT -> TDeleteItemStruct
DEVMODE -> TDevMode
DOUBLE -> Double
DRAWITEMSTRUCT -> TDrawItemStruct
DWORD -> LongInt
ENUMLOGFONT -> TEnumLogFont
EVENTMSG -> TEventMsg
FARPROC -> TFarProc
FIXED -> TFixed
FLOAT -> Single
GLYPHMETRICS -> TGlyphMetrics
HANDLE -> THandle
HANDLETABLE -> THandleTable
HARDWAREHOOKSTRUCT -> THardwareHookStruct
HELPWININFO -> THelpWinInfo
INT -> Integer
KERNINGPAIR -> TKerningPair
LOGBRUSH -> TLogBrush
LOGFONT -> TLogFont
LOGPALETTE -> TLogPalette
LOGPEN -> TLogPen
LONG -> LongInt
LONG DOUBLE -> Extended
LONG INT -> LongInt
LPSTR -> PChar
LPWSTR -> PWideChar
MAT2 -> TMat2
MDICREATESTRUCT -> TMDICreateStruct
MEASUREITEMSTRUCT -> TMeasureItemStruct
MENUITEMTEMPLATE -> TMenuItemTemplate
MENUITEMTEMPLATEHEADER -> TMenuItemTemplateHeader
METAFILEPICT -> TMetaFilePict
METAHEADER -> TMetaHeader
METARECORD -> TMetaRecord
MINMAXINFO -> TMinMaxInfo
MOUSEHOOKSTRUCT -> TMouseHookStruct
MSG -> TMsg
MULTIKEYHELP -> TMultiKeyHelp
NCCALCSIZE_PARAMS -> TNCCalcSize_Params
NEWTEXTMETRIC -> TNewTextMetric
OFSTRUCT -> TOFStruct
OUTLINETEXTMETRIC -> TOutlineTextMetric
PAINTSTRUCT -> TPaintStruct
PALETTEENTRY -> TPaletteEntry
PANOSE -> TPanose
PATTERN -> TPattern
POINTFX -> TPointFX
PSTR -> PChar
PWSTR -> PWideChar
RASTERIZER_STATUS -> TRasterizer_Status
RGBQUAD -> TRGBQuad
RGBTRIPLE -> TRGBTriple
SEGINFO -> TSegInfo
SHORT -> SmallInt
SHORT INT -> SmallInt
SIZE -> TSize
TEXTMETRIC -> TTextMetric
TPOINT -> TPoint
TRECT -> TRect
TTPOLYCURVE -> TTTPolyCurve
TTPOLYGONHEADER -> TPolygonHeader
UINT -> Word
UNSIGNED -> Word
UNSIGNED CHAR -> Byte
UNSIGNED INT -> Word
UNSIGNED LONG -> LongInt(DWORD)
UNSIGNED LONG INT -> LongInt
UNSIGNED SHORT -> Word
UNSIGNED SHORT INT -> Word
VOID* -> Pointer
WINDOWPLACEMENT -> TWindowPlacement
WINDOWPOS -> TWindowPos
WNDCLASS -> TWndClass
WORD -> Word
下面是一些 C 变量类型和 Pascal 变量类型对照列表。
HWND = type LongWord (Cardinal)
HMENU = type LongWord
所有 HANDLE 类型均是 type LongWord (Cardinal) 或 THandle
(HICON, HBITMAP, HFONT, HBRUSH, HPEN)
BYTE = Byte
SHORT = Smallint;
INT = Integer
WORD = Word
DWORD = LongWord; (Cardinal)
LONG = Integer
LONGLONG = Int64
UINT = LongWord; (Cardinal)
ASCI null terminated string = PAnsiChar or PChar
LPSTR = PAnsiChar;
LPCTSTR = PAnsiChar;
ULONG = Cardinal;
BOOLEAN = Boolean
BOOL = LongBool
LPVOID = Pointer
PSID = Pointer
LCID = DWORD, LongWord (Cardinal)
LANGID = Word
理解 Win32 API 帮助里面的数据类型可能会有点困惑,因为里面好几个 C 类型被作为一个 Pascal 数据类型了,比如 DWORD、UNIT、HWND、ULONG 和 LCID 类型在 Pascal 语言里都是 Cardinal 类型。更加令人困惑的是,很多 Delphi 的示例代码使用 Pascal 类型 LongWord 代替 Cardinal 类型,使用 LongInt 代替 Integer 类型。如果你觉得 C 语言数据类型难以把握,你通常可以在代码中使用 C 语言数据类型,因为这在 windows.pas 单元大部分都有这些类型的定义。比如, windows.pas 单元有如下定义:
type
DWORD = LongWord;
UINT = LongWord;
LCID = DWORD;
ULONG = Cardinal;