Name

StringToWideChar Function

Syntax

function StringToWideChar(const Str: string; Result: PWideChar;
                          Size: Integer): PWideChar;

Description

The StringToWideChar function converts Str to a wide string. It copies at most Size-1 characters from Str to Result, appending #0 to the result string. It returns a pointer to Result.

StringToWideChar is a real function.

Example

procedure Demo;
var
  OleStr: PWideChar;
begin
  GetMem(OleStr, (Length(S)+1) * SizeOf(WideChar));
  try
    StringToWideChar(S, OleStr, Length(S)+1);
    SomeOLEProcedure(OleStr);
  finally
    FreeMem(OleStr);
  end;
end;

See Also

OleStrToString Function, OleStrToStrVar Procedure, PWideChar Type, String Keyword, WideChar Type, WideCharLenToString Function, WideCharLenToStrVar Procedure, WideCharToString Function, WideCharToStrVar Procedure, WideString Type

Get Delphi in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.