title: Why IEGetProtectedModeCookie() always return 0x80070057?
body: <p>According the function description in &quot;<a href="http://msdn.microsoft.com/en-us/library/cc196998%28v=VS.85%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/cc196998%28v=VS.85%29.aspx</a>&quot;, I wrote the following code to try to get IE protected cookies:</p>
  <pre><code>public static string GetProtectedModeCookie(string lpszURL, string lpszCookieName, uint dwFlags)
  {
      var size = 255;
      var sb = new System.Text.StringBuilder(size);
      var acturalSize = sb.Capacity;
      var code = IEGetProtectedModeCookie(lpszURL, lpszCookieName, sb, ref acturalSize, dwFlags);
      if ((code &amp; 0x80000000) &gt; 0) return string.Empty;
      if (acturalSize &gt; size)
      {
          sb.EnsureCapacity(acturalSize);
          IEGetProtectedModeCookie(lpszURL, lpszCookieName, sb, ref acturalSize, dwFlags);
      }
      return sb.ToString();
  }
  
  [DllImport(&quot;ieframe.dll&quot;, SetLastError = true)]
  public static extern uint IEGetProtectedModeCookie(string lpszURL, string lpszCookieName, System.Text.StringBuilder pszCookieData, ref int pcchCookieData, int dwFlags);
  </code></pre>
  <p>to test this function:</p>
  <pre><code>var cookies = GetProtectedModeCookie(&quot;http://bbs.pcbeta.com/&quot;, null, 0);
  </code></pre>
  <p>But the api <strong>IEGetProtectedModeCookie</strong> always return <em><strong>0x80070057</strong></em> which indicates that one or more arguments are invalid.
  I was confused, after a lot of try finally failed, only get this result. Can anybody help me?</p>