NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

String Types

Both String and StringBuilder have similar marshaling behavior. Strings can be can be marshaled as COM style BTSR’s which have a prepended length or as a null terminated array of characters. The characters within the string can be marshaled as Unicode, ANSI or in a platform dependent manner such that the characters are Unicode on Windows NT and ANSI on Window 9x.

The marshaling options for ELEMENT_TYPE_STRING, ELEMENT_TYPE_CLASS <String> and ELEMENT_TYPE_CLASS <StringBuilder> are as follows:

Unmanaged Type Description of unmanaged format
UnmanagedType.BStr (COM) A COM style BSTR with a prepended length and Unicode characters. Not supported for StringBuilder.
UnmanagedType.ANSIBStr A COM style BSTR with a prepended length and ANSI characters (rarely used). Not supported for StringBuilder.
UnmanagedType.TBStr A COM style BSTR with a prepended length and platform dependent characters format (rarely used)
UnmanagedType.LPStr (P/Invoke) A pointer to a null terminated array of ANSI characters
UnmanagedType.LPWStr A pointer to a null terminated array of Unicode characters
UnmanagedType.LPTStr
PInvoke ONLY
A pointer to a null terminated array of platform characters
UnmanagedType.ByValTStr  

Table 6 - Marshaling options for strings