diff --git a/Core/InteropServices/StrPtr.cs b/Core/InteropServices/StrPtr.cs index 713b7a01..5da75913 100644 --- a/Core/InteropServices/StrPtr.cs +++ b/Core/InteropServices/StrPtr.cs @@ -311,4 +311,28 @@ namespace Vanara.InteropServices /// public override string ToString() => Value?.ToString("B") ?? ""; } + + /// + /// Represents a GUID point, or REFGUID, that will automatically dispose the memory to which it points at the end of scope. + /// You must use the value, or the parameter-less constructor to pass the equivalent of . + /// + public class SafeGuidPtr : SafeMemStruct + { + /// + /// Initializes a new instance of the class. This value is equivalent to a pointer. + /// + public SafeGuidPtr() : base(IntPtr.Zero, true, 0) { } + + /// Initializes a new instance of the class. + /// The unique identifier to assign to the pointer. + public SafeGuidPtr(in Guid guid) : base(guid) { } + + /// Performs an implicit conversion from to . + /// The unique identifier. + /// The resulting instance from the conversion. + public static implicit operator SafeGuidPtr(Guid? guid) => guid.HasValue ? new SafeGuidPtr(guid.Value) : Null; + + /// The equivalent of a pointer to a GUID value. + public static readonly SafeGuidPtr Null = new SafeGuidPtr(); + } } \ No newline at end of file