Nelson T Joseph
Nelson T Joseph

Reputation: 2763

Error on closing a file in vc++

I have a function that encrypts and upload a file from my system to a server. After uploading the file when I am trying to close, there is an error occurs. The error code is 12030. The upload section of my code is shown below. What is the problem in that code which generate error on closing the file.

CFile   fp;
UINT uNoOfBytes;
UINT uNoOfEncBytes;
bool bIsFinalBlock = false;
BYTE*   pBuf = NULL;
HINTERNET m_hRequest;


if(!fp.Open(szFilePath, CFile::modeRead | CFile::shareDenyNone, &err))
{
    AfxThrowFileException(err.m_cause, err.m_lOsError, err.m_strFileName);
}

do
{
    uNoOfBytes = fp.Read( pBuffer, DATA_CHUNK_SIZE );

    if( uNoOfBytes < DATA_CHUNK_SIZE )
    {
        bIsFinalBlock = true;               
    }

    uNoOfEncBytes = aes.Encrypt(pBuffer,(int)uNoOfBytes, bIsFinalBlock);

    if (!(bRet=InternetWriteFile( m_hRequest, (BYTE*)pBuffer, uNoOfEncBytes,NULL)))
    {
        DWORD dw = GetLastError();
        break;
    }

    if(bIsFinalBlock)
        break;

    }while ( uNoOfBytes != 0 ) ;

fp.Close();

Upvotes: 0

Views: 234

Answers (1)

LeleDumbo
LeleDumbo

Reputation: 9340

According to MSDN:

"The connection with the server has been reset or terminated, or an incompatible SSL protocol was encountered. For example, WinHTTP version 5.1 does not support SSL2 unless the client specifically enables it."

Anyway, I don't see where you initialize m_hRequest. Read this, that HINTERNET should be initialized with either function.

Upvotes: 1

Related Questions