Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you look at the original signature, the function needs an <code>IntPtr</code> handle, a <code>Guid</code> id and an <code>PropertyStore</code> object that will be populated by the data.</p> <pre><code>HRESULT SHGetPropertyStoreForWindow( _In_ HWND hwnd, _In_ REFIID riid, _Out_ void **ppv ); </code></pre> <p>Translating this into c# would look like this:</p> <pre><code>[DllImport("shell32.dll", SetLastError = true)] static extern int SHGetPropertyStoreForWindow( IntPtr handle, ref Guid riid, out IPropertyStore propertyStore); </code></pre> <p>And you can grab the <code>IPropertyStore</code> interface from <a href="http://www.pinvoke.net/default.aspx/Interfaces/IPropertyStore.html" rel="nofollow">PInvoke.net</a>:</p> <pre><code>[ComImport, Guid("886D8EEB-8CF2-4446-8D02-CDBA1DBDCF99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface IPropertyStore { [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetCount([Out] out uint cProps); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetAt([In] uint iProp, out PropertyKey pkey); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void GetValue([In] ref PropertyKey key, out object pv); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void SetValue([In] ref PropertyKey key, [In] ref object pv); [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)] void Commit(); } </code></pre> <p>The only thing left is to actually implement the <code>PropertyStore</code>. Similar implementations in the .net framework can be found in e.g. <a href="http://msdn.microsoft.com/en-us/library/system.printing.printsystemobject.aspx" rel="nofollow">PrintSystemObject</a>.</p> <p>After implementing this you should be able to simply call the method and set the property:</p> <pre><code>IPropertyStore store = new PropertyStore(); //your propery id in guid var g = new Guid("32CE38B2-2C9A-41B1-9BC5-B3784394AA44"); SHGetPropertyStoreForWindow(this.Handle, ref g, out store); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload