Re: How to migrate from Delphi3 to Delphi2005

Posted by DelphiMan on March 23, 2006

In Reply to How to migrate from Delphi3 to Delphi2005 posted by Bijal on March 07, 2006

: We have project in delphi 3 on windows98 . Now we want to migrate this project from delphi 3 to delphi 2005 on WindowsXp.
: But we r getting error : E2033 Types of actual and formal var parameters must be identical.
: This is due to HModule being declared as system.Cardinal instead of integer as it was earlier.

: Hmodule, the Windows Handle is of type integer in the Delphi 3 code and it was running fine on win98.

: On recompiling in Delphi 2005 on winXP, the compiler and the help insight state that the windows.pas has these same parameters of type cardinal.

: Any idea why and when this has happened and what is the workaround ?

: Are there any other memory issues/upgrades in windows API due to a change in OS from Win 98 to Win XP ?

HMODULE has the same type as HINST and THANDLE. At least since Delphi 4, HINST is of the type LONGWORD, not of type INTEGER. See the following two lines that I copied from Windows.pas of D4:

HINST = type LongWord;
HMODULE = HINST; { HMODULEs can be used in place of HINSTs }

CARDINAL is a "generic" integer type, whose size is not guaranteed over different Delphi versions. Currently, CARDINAL has the same capacity as LONGWORD, which is a fundamental unsigned 32 bits integer type.

Tip: when you declare variables of type HMODULE, do not declare them as CARDINAL or LONGWORD or INTEGER, but simply as HMODULE:
   don't write: var hMod: LONGWORD;
   but write: var hMod: HMODULE;