// Win32_cui.cpp: defines the entry point of the console application.
//
# Include "stdafx. H"
# Include <windows. h>
# Include <wininet. h>
# Include <iostream>
Using namespace STD;
Int _ tmain (INT argc, char * argv [])
{
If (argc! = 2)
{
Cout <"Please useing: Test http://www.google.cn ";
Cout <Endl;
}
Else
{
Int ilen = strlen (argv [1]);
If (ilen <256)
{
Char szurl [256] = {0 };
Strncpy (szurl, argv [1], ilen );
Lpstr lpszdata = NULL;
DWORD dwsize = 0;
Lpszdata = new char [1];
Memset (lpszdata, 0, 1 );
Retry:
If (! Internetgetcookie (szurl, "", lpszdata, & dwsize ))
{
If (getlasterror () = error_insufficient_buffer)
{
Delete [] lpszdata;
Lpszdata = new char [dwsize + 1];
Memset (lpszdata, 0, dwsize + 1 );
Goto retry;
}
Else
{
Cout <"cookie is empty! ";
}
}
Else
{
Cout <"Cookie obtained successfully! "<Endl;
}
Cout <"the cookie for the URL you entered is:" <Endl <lpszdata <Endl;
Delete [] lpszdata;
}
Else
{
Cout <"parameter is too long! ";
Return-1;
}
}
Return 0;
}