Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

call InternetGetCookie in CE6 cannot get the cookie.

13 views
Skip to first unread message

2755...@qq.com

unread,
Dec 7, 2009, 12:30:03 AM12/7/09
to
I tried to call InternetGetCookie in CE6 to get the cookie but fail.
Following is my code,

CString url = L"http://www.wallaceshushu.com"; //
just
for test
CString sCookies = L"CWSID=test; expires=Tue, 03 Dec 2019
18:08:20
GMT;";
DWORD rs=0;
if(!InternetSetCookieEx
(url,NULL,sCookies,INTERNET_COOKIE_THIRD_PARTY,rs))
{
return;
}


DWORD size=0;
::SetLastError(0);
InternetGetCookie(url, NULL, NULL, &size);
HRESULT ret = ::GetLastError();
if (size<=0)
{
return;
}
TCHAR* buf=new TCHAR[size];


if (!InternetGetCookie(url, NULL, buf ,&size))
{
delete[] buf;
return;
}


I built this project in VS2005 with CE6 SDK, the same code run in
Window Mobile 5 and Mobile 6 is ok, but in CE6 it doesn't work(I
have
try many devices which system is CE6 and emulator). I had found the
cookie in \Windows\Profiles\guest\Cookies\, but while calling
InternetGetCookie, the result is false and the variable named size is
0, I try to get the last error but the return value is S_OK.


I don't know why? Is CE6 system bug?


Paul G. Tobey [ eMVP ]

unread,
Dec 7, 2009, 2:29:01 PM12/7/09
to
I don't know what the problem is, but I can list a few things that I would try:

Check the Internet Explorer settings (unlikely to be a problem, but you're
running a different version of Windows CE than either Windows Mobile 5 or 6,
so many things may have changed; the browser is also completely different
than in WM5 at least, not sure about 6). Some setting might be preventing
you from seeing the cookie.

Try allocating, say, double the buffer size returned by the GetCookie call
and passing that larger size to the second call.

Always check the result of GetLastError() when things fail.

Paul T.

"2755...@qq.com" wrote:

> .
>

2755...@qq.com

unread,
Dec 8, 2009, 9:20:55 PM12/8/09
to
Thanks Paul, I have found the solution to deal with this problem. I
tried to compare the Winnet.dll binary code of WM6 to the one of CE6,
and I found there are some differences when call the wide char version
API InternetGetCookieW. So I try to use the Ansi version
InternetGetCookieA and translate the Ansi to Unicode by myself, and it
can work. I think this is a bug of CE6 system.

Paul G. Tobey [ eMVP ]

unread,
Dec 10, 2009, 10:04:02 AM12/10/09
to
That would be a very strange way for things to show a bug. I can understand
if the meaning of the buffer size is a size in bytes, not characters, and
you're setting it wrong (the docs are not clear). Generally, though, the
Unicode versions of all of the calls are the 'native' ones that perform the
operations; it would be strange if ASCII worked and Unicode didn't.

Paul T.

"2755...@qq.com" wrote:

> .
>

0 new messages