使用Cookie登录,该怎么处理

使用Cookie登录
可以用InternetGetCookieEx和InternetSetCookieEx来实现
步骤如下:
1、用InternetGetCookieEx获取cookie,
2、InternetSetCookieEx重新写入Cookie

但不会调用这两个API,老是失败。求高手
------解决方案--------------------
http://bbs.csdn.net/topics/390092290
------解决方案--------------------

{获取包含httponly属性的cookies}
{Add 2013.4.8}
function GetCookie(host: string): string;
const
  INTERNET_COOKIE_HTTPONLY = 8192;
var
  hModule: THandle;
  lp: Pointer;
  InternetGetCookieEx: function(lpszUrl, lpszCookieName, lpszCookieData
    : PAnsiChar; var lpdwSize: DWORD; dwFlags: DWORD; lpReserved: pointer)
    : BOOL; stdCall;
  CookieSize: DWORD;
  CookieData: PAnsiChar;
begin
  LoadLibrary('wininet.dll');
  hModule := GetModuleHandle('wininet.dll');
  if hModule <> 0 then
  begin
    @InternetGetCookieEx := GetProcAddress(hModule, 'InternetGetCookieExA');
    if @InternetGetCookieEx <> nil then
    begin
      CookieSize := 1024;
      Cookiedata := AllocMem(CookieSize);
      if InternetGetCookieEx(PAnsiChar(AnsiString(host)), nil, Cookiedata, CookieSize, INTERNET_COOKIE_HTTPONLY, nil) then
      result:=cookiedata;
      FreeMem(Cookiedata);
    end;
  end;
end;