CHString::CHString(LPCSTR) method (chstring.h)

[The CHString class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

Each of these constructors initializes a new CHString object with the specified data.

Syntax

throw(CHeap_Exception) CHString(
  LPCSTR lpsz
);

Parameters

lpsz

NULL-terminated string that is copied into this CHString object.

Return value

None

Remarks

Because the constructors copy the input data into new allocated storage, memory exceptions can result. Some of these constructors act as conversion functions; you can substitute, for example, an LPWSTR where a CHString object is expected.

Several forms of the constructor have special purposes:

  • CHString( LPCSTR lpsz )

    Constructs a Unicode CHString string from an ANSI string.

  • CHString( LPCWSTR lpsz )

    Constructs a CHString string from a Unicode string.

  • CHString( const unsigned char* psz )

    Enables you to construct a CHString string from a pointer to unsigned char.

Examples

The following code example shows how to use CHString::CHString.

CHString s1;                    // Empty string
CHString s2( L"cat" );          // From a C string literal
CHString s3 = s2;               // Copy constructor
CHString s4( s2 + " " + s3 );   // From a string expression

CHString s5( 'x' );             // s5 = "x"
CHString s6( 'x', 6 );          // s6 = "xxxxxx"

CHString city = L"Philadelphia"; // NOT the assignment operator

Requirements

Requirement Value
Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header chstring.h (include FwCommon.h)
Library FrameDyn.lib
DLL FrameDynOS.dll; FrameDyn.dll