LittlePerson
asked on
CMemFile
Hi
I am trying to read a BLOB from a mysql database into a CMemFile and then read the
contents of the CMemFile.
This is my code.............
// deviceDB is the recordset derived class that has attribute m_cal_file declared as CLongBinary
CMemFile memFile;
LPSTR buffer = (LPSTR) GlobalLock(deviceDB.m_cal_ file.m_hDa ta);
memFile.WriteHuge(buffer, deviceDB.m_cal_file.m_dwDa taLength);
GlobalUnlock(deviceDB.m_ca l_file.m_h Data);
char buf[10];
DWORD dwBytesRemaining = memFile.GetLength();
CString msg;
msg.Format("%d", dwBytesRemaining);
AfxMessageBox(msg); // comes out as 98
CString text;
CString strTmp;
while(dwBytesRemaining) {
UINT nBytesRead = memFile.Read(buf, sizeof(buf));
dwBytesRemaining -= nBytesRead;
strTmp = text;
text.Format("%s%s", strTmp, (LPCSTR)buf);
msg.Format("%d", nBytesRead);
AfxMessageBox(msg); // always comes out as being 0 - zero!!!
}
Obviously I am getting stuck in an infinite loop as the number of bytes read is never anything but zero.
How can the CMemFile tell me it has 98 bytes of data and then reads none at a time?
Can anyone help??
Thanks in advance
LittlePerson
AfxMessageBox(text);
I am trying to read a BLOB from a mysql database into a CMemFile and then read the
contents of the CMemFile.
This is my code.............
// deviceDB is the recordset derived class that has attribute m_cal_file declared as CLongBinary
CMemFile memFile;
LPSTR buffer = (LPSTR) GlobalLock(deviceDB.m_cal_
memFile.WriteHuge(buffer, deviceDB.m_cal_file.m_dwDa
GlobalUnlock(deviceDB.m_ca
char buf[10];
DWORD dwBytesRemaining = memFile.GetLength();
CString msg;
msg.Format("%d", dwBytesRemaining);
AfxMessageBox(msg); // comes out as 98
CString text;
CString strTmp;
while(dwBytesRemaining) {
UINT nBytesRead = memFile.Read(buf, sizeof(buf));
dwBytesRemaining -= nBytesRead;
strTmp = text;
text.Format("%s%s", strTmp, (LPCSTR)buf);
msg.Format("%d", nBytesRead);
AfxMessageBox(msg); // always comes out as being 0 - zero!!!
}
Obviously I am getting stuck in an infinite loop as the number of bytes read is never anything but zero.
How can the CMemFile tell me it has 98 bytes of data and then reads none at a time?
Can anyone help??
Thanks in advance
LittlePerson
AfxMessageBox(text);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER