DelphiFAQ Home Search:
General :: Programming :: Delphi :: Strings
Algorithms for string handling problems, implemented in Delphi but useful for any procedural language.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Is PChar(string) ok?

Q: Is it ok to cast a string to a pchar?

A: Yes. Delphi long strings (the default string type in 32-bit Delphi) are designed specifically to allow typecasting to PChar.

The following code is valid (with Delphi 2/3/4):

procedure p;
 var
   s : string;
 begin
   s := 'Hello world';
   // set the current window's caption
   SetWindowText (GetActiveWindow, PChar(s));
 end;

Generated 20:01:28 on Jun 18, 2018