• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1814
  • Last Modified:

Upgrade from D7 to Delphi XE

before to move fully to VS, I have to upgrade a lot of source code to the newest Delphi version.(Reasons: Windows 7,UTF8,...)
And I am waiting for the XE next month.
I have some questions:

1. What is your expierence (with 2009,2010) ? Is it easy to upgrade the existing source codes?
2. Is there something like guidance (patterns) or it is not necessary?
3. What should I be aware of?

  • 7
  • 6
  • 5
  • +1
2 Solutions
The main problem you will encounter is the fact that all strings are now Unicode.
So codes using String, Char and PChar with the implicit knowledge that a Char is a Byte might not work anymore.
These codes are usually fixed by replacing :
String => ANSIString
Char => ANSIChar
PChar => PANSIChar

Some codes could be made to work with all delphi version by adapting to the Char size automatically.
Ex :

Procedure CopyPCharString( Src,Dst:PChar; NbChars :Integer);
 Move ( Src^ , Dst^, NbChars * SizeOf(Char) );

in the above example, the original code was considering that a Char takes 1 byte. By adding the multiplication by the size of Char, it will work as well in Delphi 7 and Delphi 2009 (where sizeof(Char)=2 )

That is the kind of problems you'll encounter
mottorAuthor Commented:
>>  PChar => PANSIChar

What is with the calls to Windows API. I am converting usually string to PChar.
I will make PChar to PANSIChar, but don't want to change string to ANSIString.
How are they defined in Windows.pas?
All the windows API in Windows.Pas exist in 2 versions, one with 'A' suffixe and one with 'W' suffix, for ANSIString and WideString. You can use those explicitly to be sure of the type used.

But usually, your old programs, and your new ones, will use the third version, which is an alias, without suffix, and depending on the Delphi version it will point to the 'A' version (Delphi<2009) or the 'W' version (Delphi >=2009)

One example out of many :
function CreateMutex(lpMutexAttributes: PSecurityAttributes; bInitialOwner: BOOL; lpName: PChar): THandle; stdcall;
function CreateMutexA(lpMutexAttributes: PSecurityAttributes; bInitialOwner: BOOL; lpName: PAnsiChar): THandle; stdcall;
function CreateMutexW(lpMutexAttributes: PSecurityAttributes; bInitialOwner: BOOL; lpName: PWideChar): THandle; stdcall;

Open in new window

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Geert GOracle dbaCommented:
if you're very lucky, not a lot of work
if you're not lucky (75% change), you'll have a lot of work

nick hodges posts a lot of articles concerning this:

i found this as a reference to upgrading to unicode

from bob swart's site
Oh, and it's fun to be able to play with generics, hope you will enjoy that too! :-)
Generics, yeah ! that is one useful feature of newest Delphi.
Like templates in C++
Since someone introduced them to me I can't wait the time when I'll be able to upgrade.
mottorAuthor Commented:

Will I have problems by migration with DOA,DevExpress and FastReport components?

Geert GOracle dbaCommented:
if you use the QuantumTreeview v4
you'll have to upgrade it to v5 in D2010
Quantumgrid v6 wasn't a problem
I don't have other components of DevExpress

DOA ???

Don't have FastReport either
Geert GOracle dbaCommented:
ah got it ... DOA = Dead On Arrival   :)
Geert GOracle dbaCommented:
for the other DOA (if you are referring to devart.com components)
no problem either
Delphi XE is not out yet, so it's difficult to tell the extent of the problems you'll have with it.

But from experience with Delphi versions migrations, you will have to get the latest version of all the components you use, check on their websites if they even have a Delphi XE version ready.
Anyway, probably any components that have been certified with Delphi 2009 will present no problems, as it was the biggest step.

With components that don't have a newer version ready, if you have the source code you might just be able to recompile them without much work. Some will probably need a few tweaks here and there to work again.
And last, we cannot remove the possibility that some old and unmaintained components will pose more than a trouble.
Geert GOracle dbaCommented:
one thing that keeps hitting me about XE ... those letters

Oracle XE > Free
MSSQL  XE > Free
Delphi XE > ??? ... probably not, as it's not a database product :(
I've read in embarcadero site that XE stands for nothing. Just one of those marketing brilliant ideas - supposed to make the mass go for it without question because it's "cool". Yeah, whatever....
For XP, they found after some sort of definition "eXPerience". Maybe someone will come up with something for XE :o)
mottorAuthor Commented:
DOA is from Allround Automations

About XE is better to say nothing.  (Have learned in the past.)

Thanks for the help.

I will write here after the migration
mottorAuthor Commented:
>>Qualifying products for all XE Enterprise upgrades
>>Any Architect, Enterprise or Professional edition of: Delphi 2007-2010
>>C++Builder 2007-2010
>>Delphi and C++Builder Bundle 2009
>>RAD Studio 2007-2010
>>Upgrade product is also available on valid promotional upgrade offers
>>For a limited time, through Dec 31, 2010, registered users of  Borland Developer Studio 2006, C++Builder 2006, and Delphi 2006 also  qualify for upgrade pricing
I'm not eligible for upgrade. May be the question was for no purpose.
I have to rethink, if I should give 1999 Euro + VAT

I thank you anyway :)
> I have to rethink, if I should give 1999 Euro + VAT
maybe you don't need enterprise edition and professional is just enough ?
mottorAuthor Commented:
>maybe you don't need enterprise edition and professional is just enough ?

I have asked them, if I buy Pro and it is not enough, kann I upgrade to Enterprise.
The answer was NO.
I wanted to test with trial version. But there is not such (Pro).
mottorAuthor Commented:
I have found better solution for Delphi 7 Enterprise owner (me):
Embarcadero® All-Access™ Pass Silver with 1 Year Membership - Single Platform Upgrade

At least you get ER/Studio. I hope that is not a trap. :)
mottorAuthor Commented:
I've bought Embarcadero® All-Access™ Pass Silver.
Today I have successfully upgraded the first small application. It was easy.
Thank you.

P.S. The exe size has grown from 19MB to 22MB. Is this normal?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 5
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now