From 2473914e7d16a7779eb771af045cb8cef033c849 Mon Sep 17 00:00:00 2001 From: dahall Date: Mon, 26 Oct 2020 18:24:12 -0600 Subject: [PATCH] Added PIDL conversion to byte[] --- PInvoke/Shell32/ShTypes.PIDL.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/PInvoke/Shell32/ShTypes.PIDL.cs b/PInvoke/Shell32/ShTypes.PIDL.cs index 4ef8b8f7..1c694bf6 100644 --- a/PInvoke/Shell32/ShTypes.PIDL.cs +++ b/PInvoke/Shell32/ShTypes.PIDL.cs @@ -29,6 +29,10 @@ namespace Vanara.PInvoke /// A string that contains the path. public PIDL(string path) : this(IntILCreateFromPath(path)) { } + /// Initializes a new instance of the class from an array of bytes. + /// The bytes. + public PIDL(byte[] bytes) : this() { using var p = new PinnedObject(bytes); SetHandle(IntILClone(p)); } + /// Initializes a new instance of the class. internal PIDL() : base(Free) { } @@ -126,6 +130,10 @@ namespace Vanara.PInvoke /// true if the current object is equal to the parameter; otherwise, false. public bool Equals(PIDL other) => ReferenceEquals(this, other) || Equals(other?.handle ?? IntPtr.Zero); + /// Gets the ID list as an array of bytes. + /// An array of bytes representing the ID list. + public byte[] GetBytes() => handle.ToArray((int)Size); + /// Returns an enumerator that iterates through the collection. /// A that can be used to iterate through the collection. public IEnumerator GetEnumerator() => new InternalEnumerator(handle);