Fixed bug #66 that forces all SafeMemString string representations to Empty when a size not known (like as a return value from a COM object).

pull/83/head
David Hall 2019-10-08 13:29:30 -06:00
parent 6aacdf6d91
commit cca953eb5f
2 changed files with 4 additions and 1 deletions

View File

@ -37,6 +37,9 @@ namespace Vanara.InteropServices
{
}
/// <summary>Prevents a default instance of the <see cref="SafeCoTaskMemString"/> class from being created.</summary>
private SafeCoTaskMemString() : base() { }
/// <summary>Initializes a new instance of the <see cref="SafeCoTaskMemString"/> class.</summary>
/// <param name="ptr">The PTR.</param>
/// <param name="charSet">The character set.</param>

View File

@ -186,6 +186,6 @@ namespace Vanara.InteropServices
/// <summary>Returns the string value held by this instance.</summary>
/// <returns>A <see cref="System.String"/> value held by this instance or <c>null</c> if the handle is invalid.</returns>
public override string ToString() => IsInvalid ? null : StringHelper.GetString(handle, CharSet, Size);
public override string ToString() => IsInvalid ? null : StringHelper.GetString(handle, CharSet, Size == 0 ? long.MaxValue : (long)Size);
}
}