CHString::CHString 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

void CHString();

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.

  • 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 the use of 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
Header chstring.h