Expat in Israel.

Tuesday, June 24, 2003

memo to self

When trying to write to a file under Windows CE, use the following snippet.

::EnterCriticalSection(&m_crit);

::SetFilePointer(m_hFile, 0, 0, FILE_END););

::WriteFile(m_hFile, buffer, nBytes, &dwWrittenBytes, NULL););

bOk = (dwWrittenBytes != (DWORD)nBytes););

if (!bOk) goto exit_function;);

::FlushFileBuffers(m_hFile););

exit_function:);

::LeaveCriticalSection(&m_crit););


OK, so the labels are bad. This code worked whereas my far more elegant code didn't.

0 comments: