Get ready for Delphi 2009 and when developing with Delphi 7?

I am developing a Word addin in Delphi 7, but soon I will upgrade it to Delphi 2010, as you know, since the 2009 version of Delphi introduces a new UnicodeString string type , which is equal to the keyword string . On the other hand, according to this topic , we should use WideString to communicate with COM.

My question is: what should I do to prepare for Delphi 2010 in the future while it is being developed in Delphi 7? In my code I use a custom UnicodeString type, the idea is that when compiling with D7 my string is WideString, when compiling with D2009 and at the top of UnicodeString, I see that Virtual TreeView uses a technique like the following code:

{$ifndef COMPILER_12_UP}
type
  UnicodeString = WideString;
  PByte = PAnsiChar;
{$endif COMPILER_12_UP}
+5
source share
4 answers

Step 1
Usually you should stick with the "normal" types as much as possible: i.e. String and Char
This way your code will be "automatically" converted when updated.
NOTE. There are a few exceptions for specific applications.

If you do not, you may have a problem when updating the code library that used AnsiString in some places. This was not a problem in old Delphi when AnsiString = String. But obviously, this was problematic when the types were no longer the same.

2
Unicode Delphi 2009. , , , 1 . .

3, 4 5
. .

6, 7, 8, 9 10
, . . , VCL, "" , String. " " - Delphi 2009.

, - ; , , , Delphi 2009 .

! Windows API. Windows Ansi, Wide . Delphi Ansi ; Delphi 2009, .


WideString COM:
Delphi String WideString - , . , COM- WideString, - .


, : Delphi 2009 Delphi 7?

: Delphi ( Delphi 2009). "", - . , , ; , , .

, - Delphi, :

  • /​​ .
  • Unmaintained , .
  • Midas Delphi 3 . ( , .)
+6

+3

, , Delphi 7, Unicode:

, Char 1.

,

SizeOf(Char) 1 .

, . , .

+1
source

(The odd pbyte declaration for VST is probably a more workaround for {$ pointermath on} to be D2009, and you cannot override pbyte in lower versions. This probably doesn't apply to Unicode)

0
source

All Articles