title: How to prevent an app from being pinned in Windows 7?
body: <p>I am trying to prevent the user from pinning my .NET app to the taskbar.  I've found some code on the <a href="http://blogs.msdn.com/b/oldnewthing/archive/2011/06/01/10170113.aspx">Old New Thing</a> that does just that.  However, it is in C++.</p>
  
  <pre><code>#include &lt;shellapi.h&gt;
  #include &lt;propsys.h&gt;
  #include &lt;propkey.h&gt;
  
  HRESULT MarkWindowAsUnpinnable(HWND hwnd)
  {
   IPropertyStore *pps;
   HRESULT hr = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&amp;pps));
   if (SUCCEEDED(hr)) {
    PROPVARIANT var;
    var.vt = VT_BOOL;
    var.boolVal = VARIANT_TRUE;
    hr = pps-&gt;SetValue(PKEY_AppUserModel_PreventPinning, var);
    pps-&gt;Release();
   }
   return hr;
  }
  
  
  BOOL
  OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
  {
   MarkWindowAsUnpinnable(hwnd);
   return TRUE;
  }
  </code></pre>
  
  <p>I am having very little luck converting it to c#.  Can someone help?</p>