lundi 29 juin 2015

C++ fstream is writing hex instead of string?


I'm trying to download a file using URLDownloadToFile() which is working so far, however I'm having trouble with the callback function and writing the callback output wszStatusText to a file.

Here is the function that's giving the problem:

HRESULT DownloadStatus::OnProgress(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR wszStatusText)
{
    fstream myfile;
    myfile.open("file.txt", ios::app);

    // this prints hex e.g. StatusText: 00435F78
    myfile << " StatusText: " << wszStatusText;
    myfile.close();

    // this prints the string properly e.g. text/plain
    MessageBox(NULL, wszStatusText, L"test", MB_OK);

    return S_OK;
}

The thing is that MessageBox() is showing the data properly...


Aucun commentaire:

Enregistrer un commentaire