Delphi 64與32位的差異
相同點:
在Delphi 64位版本中,UnicodeString,AnsiString,WideString在使用上與32沒有區別,只是索引變成了64位,如:S[I]中的I變成了64位。
Singed types |
Delphi/32 |
Delphi/64 |
ShortInt |
1 bytes |
← |
SmallInt |
2 bytes |
← |
LongInt |
4 bytes |
← |
Integer |
4 bytes |
← |
Int64 |
8 bytes |
← |
Unsinged types |
Delphi/32 |
Delphi/64 |
Byte |
1 bytes |
← |
Word |
2 bytes |
← |
LongWord |
4 bytes |
← |
Cardianl |
4 bytes |
← |
UInt64 |
8 bytes |
← |
← 符號表示大小與Delphi/32相同
不同的地方:
NativeInt,NativeUint - 64 bits
Point(all pointers) - 64 bits
Dynamic Arrays - 64-bit indexing
Floating point math – Double
Point
String
Class instance
class reference
Interface
AnsiString
WideString
UnicodeString
Procedure pointer
Dynamic array
PAnsiChar
PWideChar
PChar
上面的型別在32位都是4 bytes,在64位下是8 bytes
總體來說:
- 同樣的Windows API,如:CreateWindowEx,PeekMessage,etc
- 同樣的Delphi RTL:SysUtils,Classes,Generics.Collections,etc
- VCL也相同:Forms,Graphics,Controls,Menus,etc
- 錯誤處理上也相同:try…finally…., try….exception…..
在64位下,這些呼叫約定將被看做一致:register,passcal, cdecl,stdcall
Delphi/64不支援pascal與BASM(ASM)混寫了,只支援純Asm procedure。
呼叫過程或函式的前面四傳參暫存器也發變成了:RCX, RDX, R8, R9(或XMM0-XMM3)
在處理Message訊息結構體時,需要進行顯示強制轉換,例如:
SendMessage(hWnd,WM_SETTEXT,0,LPARAM(@MyCharArray));
Message.Result:=LRESULT(Self);