Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

StructLayoutAttribute.CharSet Field

Indicates how string data fields within the class should be marshaled as LPWSTR or LPSTR by default.

[Visual Basic]
Public CharSet As CharSet
[C#]
public CharSet CharSet;
[C++]
public: CharSet CharSet;
[JScript]
public var CharSet : CharSet;

Remarks

If the CharSet field is set to CharSet.Unicode, all string arguments are converted to Unicode characters (LPWSTR) before being passed to the unmanaged implementation. If the field is set to CharSet.Ansi, the strings are converted to ANSI strings (LPSTR). If the CharSet field is set to CharSet.Auto, the conversion is platform dependent (Unicode on Windows NT, Windows 2000, Windows XP, and Windows Server 2003 family; ANSI on Windows 98 and Windows Me).

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

StructLayoutAttribute Class | StructLayoutAttribute Members | System.Runtime.InteropServices Namespace

Show:
© 2015 Microsoft