WindowsRuntimeMarshal.StringToHString Method (String)

.NET Framework (current version)
 

This API supports the product infrastructure and is not intended to be used directly from your code.

Allocates a Windows Runtime HSTRING and copies the specified managed string to it.

Namespace:   System.Runtime.InteropServices.WindowsRuntime
Assembly:  mscorlib (in mscorlib.dll)

<SecurityCriticalAttribute>
Public Shared Function StringToHString (
	s As String
) As IntPtr

Parameters

s
Type: System.String

The managed string to copy.

Return Value

Type: System.IntPtr

An unmanaged pointer to the new HSTRING, or IntPtr.Zero if s is String.Empty.

Exception Condition
PlatformNotSupportedException

The Windows Runtime is not supported on the current version of the operating system.

ArgumentNullException

s is null.

Use the FreeHString method to release the HSTRING when you are done using it.

SecurityCriticalAttribute

requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show: