コード例 #1
0
        public static string GetCookies(string uri, CookieRetrievalFlags flags)
        {
            StringBuilder buffer;
            string        result;
            int           bufferLength;

            bufferLength = 1024;
            buffer       = new StringBuilder(bufferLength);

            if (NativeMethods.InternetGetCookieEx(uri, null, buffer, ref bufferLength, (int)flags, IntPtr.Zero))
            {
                result = buffer.ToString();
            }
            else
            {
                result = null;

                if (Marshal.GetLastWin32Error() == NativeMethods.ERROR_INSUFFICIENT_BUFFER)
                {
                    buffer.Length = bufferLength;

                    if (NativeMethods.InternetGetCookieEx(uri, null, buffer, ref bufferLength, (int)flags, IntPtr.Zero))
                    {
                        result = buffer.ToString();
                    }
                }
            }

            return(result);
        }
コード例 #2
0
 public static string GetCookies(Uri uri, CookieRetrievalFlags flags)
 {
     return(GetCookies(uri.OriginalString, flags));
 }