doc. inconsistency: default p/invoke marshaling for strings

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Below given several excerpts from msdn library documentation for default
p/invoke marshaling for strings. which of them says the truth? which one
should we depend on?
thanks

--- Default Marshaling for Strings
ms-help://MS.MSDNQTR.2003APR.1033/cpguide/html/cpcondefaultmarshalingforstri
ngs.htm

Strings Used in Platform Invoke
UnmanagedType.BStr
(default)

--- MarshalAsAttribute Class
ms-help://MS.MSDNQTR.2003APR.1033/cpref/html/frlrfSystemRuntimeInteropServic
esMarshalAsAttributeClassTopic.htm

By default, the runtime marshals a string parameter (and fields in a value
type) as a LPStr to a platform invoke method or function. For additional
information, see Default Marshaling Behavior.

--- Platform Invoke Tutorial
ms-help://MS.MSDNQTR.2003APR.1033/csref/html/vcwlkPlatformInvokeTutorial.htm
#pinvoke_defaultmarshaling

For example, the default marshaling for C# string values is to the type
LPTSTR (pointer to TCHAR char buffer).
 
Below given several excerpts from msdn library documentation for default
p/invoke marshaling for strings. which of them says the truth?

In COM interfaces the default is BStr.

In DllImport methods the default is LPStr if you don't set the
CharSet.



Mattias
 
Back
Top