Moved PROPERTYKEY into its own file and embedded static PROPERTYKEY values into that structure under the "System" static class.

pull/10/head
David Hall 2018-01-15 09:44:26 -07:00
parent 9421c1195b
commit 668b2e09b8
6 changed files with 7736 additions and 7740 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -207,55 +207,5 @@ namespace Vanara.PInvoke
/// <summary>A void pointer for local use.</summary>
VT_BYREF = 0x4000,
}
/// <summary>Specifies the FMTID/PID identifier that programmatically identifies a property. Replaces SHCOLUMNID.</summary>
[PInvokeData("Wtypes.h", MSDNShortId = "bb773381")]
[StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct PROPERTYKEY : IComparable<PROPERTYKEY>
{
public Guid fmtid;
public uint pid;
public PROPERTYKEY(Guid key, uint id)
{
fmtid = key;
pid = id;
}
public Guid Key => fmtid;
public uint Id => pid;
public override string ToString() => GetCononicalName() ?? KnownShellItemPropertyKeys.ReverseLookup(this) ?? $"{Key:B} {Id}";
public override bool Equals(object obj) => obj is PROPERTYKEY propertykey && Equals(Key, propertykey.Key) && Id == propertykey.Id;
public override int GetHashCode() => new { Key, Id }.GetHashCode();
int IComparable<PROPERTYKEY>.CompareTo(PROPERTYKEY other)
{
var ret = Key.GetHashCode() - other.Key.GetHashCode();
if (ret == 0)
ret = (int)(Id - other.Id);
return ret;
}
public string GetCononicalName()
{
SafeCoTaskMemString str = null;
try
{
var pk = this;
PropSys.PSGetNameFromPropertyKey(ref pk, out str);
return str;
}
catch { }
finally
{
str?.Dispose();
}
return null;
}
}
}
}

View File

@ -221,7 +221,7 @@ namespace Vanara.PInvoke.Tests
if (ps == null) continue;
using (var pv = new PROPVARIANT())
{
ps.GetValue(ref KnownShellItemPropertyKeys.Thumbnail, pv);
ps.GetValue(ref PROPERTYKEY.System.Thumbnail, pv);
if (pv.IsNullOrEmpty) continue;
if (pv.vt == VARTYPE.VT_CF)
TestContext.WriteLine(f);

View File

@ -172,11 +172,10 @@ namespace Vanara.PInvoke.Tests
public void PSGetNameFromPropertyKeyTest()
{
var pkey = new PROPERTYKEY {fmtid = new Guid("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}"), pid = 5};
var hr = PSGetNameFromPropertyKey(ref pkey, out SafeCoTaskMemString str);
var hr = PSGetNameFromPropertyKey(ref pkey, out var str);
Assert.That(hr.Succeeded);
Assert.That((string)str, Is.Not.Null);
TestContext.WriteLine(str.ToString());
str.Dispose();
Assert.That(str, Is.Not.Null);
TestContext.WriteLine(str);
}
[Test()]
@ -405,7 +404,7 @@ namespace Vanara.PInvoke.Tests
public void PropVariantToStringAllocTest()
{
var pv = new PROPVARIANT("Test");
var hr = PropVariantToStringAlloc(pv, out SafeCoTaskMemString s);
var hr = PropVariantToStringAlloc(pv, out var s);
Assert.That(hr.Succeeded);
Assert.That(pv.Value, Is.EqualTo((string)s));
pv = new PROPVARIANT(1);

View File

@ -141,7 +141,7 @@ namespace Vanara.Collections.Tests
SHCreateItemFromParsingName(PInvoke.Tests.AdvApi32Tests.fn, null, typeof(IShellItem2).GUID, out object ppv);
Assert.That(ppv, Is.Not.Null);
var si2 = (IShellItem2) ppv;
var pk = KnownShellItemPropertyKeys.PropList.FullDetails;
var pk = PROPERTYKEY.System.PropList.FullDetails;
var pdl = si2.GetPropertyDescriptionList(ref pk, typeof(IPropertyDescriptionList).GUID);
var pdRiid = typeof(IPropertyDescription).GUID;