CHString::CHString(LPCWSTR) constructor

[The CHString class is part of the WMI Provider Framework, which is no longer available for use as of Windows Vista. Instead, see Using WMI for the preferred ways to write a WMI COM provider or a WMI provider that uses the .NET Framework System.Management namespaces.]

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

Syntax


CHString(
  LPCWSTR lpsz
) throw (CHeap_Exception);

Parameters

lpsz

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

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* ) pszEnables 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

Minimum supported client

None supported

Minimum supported server

Windows Server 2003

End of client support

None supported

End of server support

Windows Server 2003

Header

Chstring.h (include FwCommon.h)

Library

Framedyn.lib

DLL

Framedyn.dll

 

 

Show:
© 2014 Microsoft