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

A tricky way to use SetLength()

Several Windows API functions that retrieve a string get a PChar as an argument and return the number of bytes retrieved. This return value can be used for SetLength().

An example for that is the function GetWindowsDirectory() that is used in the following piece of code:

{$IFDEF WIN32}
 function GetWindowsDir: string;
 begin
   SetLength(Result, MAX_PATH);
   SetLength(Result, GetWindowsDirectory(PChar(Result), Length(Result)));
 end;
 {$ENDIF}
 
You don't like the formatting? Check out SourceCoder then!
Generated 4:01:23 on Jul 22, 2018