Name

StringToOleStr Function

Syntax

function StringToOleStr(const Str: string): PWideChar;

Description

The StringToOleStr function converts a string to a wide string suitable for passing to OLE and COM routines.

StringToOleStr is a real function.

Tips and Tricks

The wide string is dynamically allocated, and you must make sure you free it by calling the Windows API function SysFreeString.

Example

procedure Demo;
var
  OleStr: PWideChar;
begin
  OleStr := StringToOleStr(S);
  try
    SomeOLEProcedure(OleStr);
  finally
    SysFreeString(OleStr);
  end;
end;

See Also

OleStrToString Function, OleStrToStrVar Procedure, PWideChar Type, String Keyword, StringToWideChar Function, 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.