Newsgroups : Microsoft : microsoft.public.inetsdk.programming.wininet : 2007 Feb : How to use CInternetSession class in _UNICODE compile environment?

www.cryer.info
Managed Newsgroup Archive

How to use CInternetSession class in _UNICODE compile environment?

Subject:How to use CInternetSession class in _UNICODE compile environment?
Posted by:"john Lee" (john90..@paran.com)
Date:Wed, 28 Feb 2007 02:44:46

Dear.

The following code works well in the normal complie environment, however,
when I compile functions with _UNICODE Debugging options, the functions
does't work well.

Please let me know the reason and how to fix it.

Best Regards.

John


long CHTTPConnect::SendReceive_Get(LPCTSTR pszOrg, CString& pszDest)
{
    CInternetSession*    session    = NULL;
    CInternetFile*        file    = NULL;
    CString                buf        = "";

    if (m_nProxyEnabled)
    {
        session = new CInternetSession(_T("CQEK"), 1, INTERNET_OPEN_TYPE_PROXY,
m_szProxyName, NULL, 0);
    }
    else
    {
        session = new CInternetSession(_T("CQEK"), 1,
INTERNET_OPEN_TYPE_PRECONFIG,    NULL, NULL, 0);
    }

    buf = pszOrg;
    pszDest = "";

    try
    {
        file = (CInternetFile*)session->OpenURL(buf, 1, INTERNET_FLAG_DONT_CACHE |
INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD);
    }
    catch (CInternetException* file2)
    {
        TCHAR sz[1024];
        file2->GetErrorMessage(sz, 1024);
        printf("ERROR! %s
", sz);
        file2->Delete();
        c_CommonInfo.Error_Window(IDS_10001);

        return FALSE;
    }

    if (file)
    {
        file->SetReadBufferSize(30000);
        while (1)
        {
            BOOL bRet = file->ReadString(buf);
            pszDest += buf;
            if (!bRet)
            {
                break;
            }
        }
        file->Close();
    }

    if (file)
    {
        delete file;
    }
    if (session)
    {
        delete session;
    }

    return TRUE;
}

Replies:

www.cryer.info
Managed Newsgroup Archive