RAD Studio for Microsoft .NET
ContentsIndex
PreviousUpNext
Making Changes Required Due to 64-bit .NET 2.0 Support

Changes have been made to support 64-bit .NET 2.0. These changes might require minor code changes so that existing applications work correctly. This document describes these changes in detail. There are two general areas:

  1. Changed code patterns
  2. Windows API declarations for some callbacks and records
Warning: These changes are required due to changes made to support 64-bit systems. They must be made for applications intended for both 32-bit and 64-bit systems.

To make required changes for various code patterns

  1. Case statements Using a handle in a case statement no longer compiles. Replace statements like this:

case Msg.WParam of

with one of the following:

case Msg.WParam.ToInt64 of  // VCL.NET specific
case Int64(Msg.WParam) of   // Compatibile with VCL/Win32

  1. Casting enumerations A handle can no longer be directly type cast to an enumerated type. Replace code like this:

LEnum := TEnum(GetWindowLong(...));

with this:

LEnum := TEnum(GetWindowLong(...).ToInt64);

  1. Using handles with sets Overloading set operators isn’t supported, so code such as:

if Msg.WParam in [1..5] then

must be replaced with one of the following:

if Msg.WParam.ToInt64 in [1..5] then    // VCL.NET specific
if Int64(Msg.WParam) in [1..5] then     // Compatibile with VCL/Win32

  1. Indexing into arrays Using a handle to index into an array no longer compiles. Code such as this:

S := StrArray[Msg.WParam];

must be changed to one of the following:

S := StrArray[Msg.WParam.ToInt64];  // VCL.NET specific
S := StrArray[Int64(Msg.WParam)];   // Compatibile with VCL/Win32

  1. Assuming a specific handle size Code that is expected to run on 64-bit platforms should not assume the value of a handle or an IntPtr is in the Int32 range. In the case of an IntPtr, the ToInt32 method throws an overflow exception if it doesn't. Code such as this:

LIntPtr := IntPtr.Create(Buffer.ToInt32 + 10);

needs to be changed to this form:

LIntPtr := IntPtr.Create(Buffer.ToInt64 + 10);

Similarly, the following code:

var
   DC: HDC;
begin
   ...
   SendMessage(Window, Message, Integer(DC), 0);
end;

must be replaced by:

var
   DC: HDC;
begin
   ...
   SendMessage(Window, Message, WPARAM(DC), 0);
end;
To make required changes in various Windows callbacks

  1. Examine the first column of the table below to determine if you have used any of these units.
  2. If you have used any unit, determine if you have used any of the callbacks for that unit listed in the second column of the table.
  3. For each occurrence of such an callback, change the parameters noted in column 3 appropriately.
 

Unit 
Callback 
Details 
DDEml  
TFNCallback  
Data1 and Data2 param types changed  
MMSystem  
TFNDriverProc  
dwDriverId param type changed  
MMSystem  
TFNDrvCallBack  
dwUser, dw1 and dw2 param types changed  
MMSystem  
TFNTimeCallBack  
dwUser, dw1 and dw2 param types changed  
RichEdit  
TEditStreamCallBack  
dwCookie param type changed  
Windows  
TFNWndProc  
WParam, LParam and Result types changed  
Windows  
TFNWndEnumProc  
LParam param type changed  
Windows  
TFNTimerProc  
P3 param type changed  
Windows  
TFNAPCProc  
dwParam param type changed  
Windows  
TFNDlgProc  
Result type changed  
Windows  
TFNSendAsyncProc  
P3 param type changed  
Windows  
TFNPropEnumProcEx  
P4 param type changed  
WinInet  
PFN_AUTH_NOTIFY  
dwContext param type changed  
To make required changes in various Variant records

  1. Examine the first column of the table below to determine if you have used any of these units.
  2. If you have used any unit, determine if you have used any of the records for that unit listed in the second column of the table.
  3. For each such record, find all places where a field was passed as a var parameter that has been changed to a property and modify the code appropriately. The compiler warns you whether you need to update or not.
 

Unit 
Record 
ActiveX  
TPictDesc  
ActiveX  
TPropSpec  
ActiveX  
TStgMedium  
ActiveX  
TTypeDesc  
ActiveX  
TVarDesc  
ActiveX  
TVariantArg  
CommCtrl  
TPropSheetHeader  
CommCtrl  
TPropSheetPage  
CommCtrl  
TTVInsertStruct  
CommCtrl  
TTVInsertStructA  
CommCtrl  
TTVInsertStructW  
MMSystem  
TMixerControlDetails  
ShlObj  
TStrRet  
Windows  
TInput  
Windows  
TProcessHeapEntry  
Windows  
TSystemInfo  
WinSpool  
TPrinterNotifyInfoData  
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!