System.WideString.data

From RAD Studio API Documentation
Jump to: navigation, search

C++

WideChar* data()                    { return Data; }

Properties

Type Visibility Source Unit Parent
function public wstring.h System WideString

Description

Returns a pointer to the underlying string data.

data returns a pointer to a null-terminated character array that the WideString uses to store its value. This is the same value as the one returned by the c_bstr method, except that data returns a NULL pointer when the value is an empty string.

Note: Because data returns NULL instead of an empty string, it is useful for C++ functions that expect either a valid (nonempty) char* or NULL. The following example assumes that TCHAR mapping is not set to wchar_t:

WideString x;
ShellExecute(0, static_cast<const char*>(x.data()), "File.txt", NULL, NULL, SW_SHOW);

If TCHAR mapping is set to wchar_t, ShellExecute becomes the wide version, ShellExecuteW. If you want to use the Ansi version of ShellExecute when TCHAR mapping is set to wchar_t, you should specify ShellExecuteA.

See Also