예제 #1
0
        public static bool InternetGetCookieEX(string url, string cookiename, ref string cookiedata)
        {
            int           length = 1024;
            StringBuilder sb     = new StringBuilder(length);

            //检查Domain是否忘记写http://
            if (url.ToLower().IndexOf("http:") <= 0)
            {
                url = "http://" + url;
            }
            //检查Cookiename
            if (cookiename == "")
            {
                cookiename = null;
            }
            if (Wininet.InternetGetCookie(url, cookiename, sb, ref length))
            {
                cookiedata = sb.ToString();
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// VBA方法:取得缓存中的Cookie,cookiename为空表示一次传递所有cookies
        /// </summary>
        public virtual string GetCacheCookie(string domain, string cookiename)
        {
            string s = "";

            if (Wininet.InternetGetCookieEX(domain, cookiename, ref s))
            {
                return(s);
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
 /// <summary>
 /// VBA方法:设置缓存中的Cookie,cookiename为空表示一次传递所有cookies
 /// </summary>
 public virtual bool SetCacheCookie(string domain, string cookiename, string cookievalue)
 {
     return(Wininet.InternetSetCookieEX(domain, cookiename, cookievalue));
 }