delphi和c数据类型转换问题 ( 积分: 29 )

  • 主题发起人 主题发起人 gxcddnk
  • 开始时间 开始时间
G

gxcddnk

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个数据文件的数据格式说明,但是是用c的数据类型来说明的,我想用Delphi来读,请问一下该如何做?
具体是这样的:
数据格式说明中有Unsigned int,Long,,int,float,这些是c的数据类型,用Delphi读的时候是不是把他们申明为Word,Longint,smallint,single就行了?还是除了这样申明外还要做什么转换?
 
unsigned int DWORD
long, LongInt
int Integer
float Single
 
如楼上定义,不用转换了
 
给你一张比较完整的对应表,前面是C++的类型:
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的类型前加 T ,这个算是Delphi的命名规范)
 
多人接受答案了。
 
后退
顶部