RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringT::data Method

Returns a pointer to the underlying string System::AnsiStringT::data.

Pascal
function data: const void*;
C++
__fastcall const void* data() const;

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

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

AnsiString 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. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!