The strange behavior is this:
I write to a file using WritePrivateProfileString and then try to print
that file out. Instead of the file being printed out nicely, the last
entries created by WPPPS are just some binary-type blocks. Though
really, when I open up the file as soon as I can after the
modifications, it is fine. I tried pausing (by waiting before stepping
into the printer loop) and that worked - the file printed out as
possible. Can anybody help? Here is some code...
WritePrivateProfileString("Companies", "number", (const char *)&num,
lpExistingFileName);
//snip
//(database closing and catch statements)
//snip
TRACE("Opening file for reading.\n");
CFile *fFile = new CFile(lpExistingFileName, CFile::modeRead);
CArchive *arFile = new CArchive(fFile, CArchive::load);
TRACE("Opening printer for writing.\n");
CFile *fPrinter = new CFile("c:\\temp\\1.txt", CFile::modeWrite |
CFile::modeCreate);
char byte;
UINT readsize;
TRACE("Reading in file and writing to printer buffer. \n");
do
{
readsize = arFile->Read((void *)&byte, 1);
fPrinter->Write((void *)&byte, 1);
}
while (readsize > 0);
TRACE("Flushing printer buffer and closing printer and file.\n");
arFile->Close();
fFile->Close();
fPrinter->Flush();
fPrinter->Close();
Thanks in advance,
mike
The 'privateprofile' functions cache the most recent ini-file in memory.
To force write to disk just access another Private ini file. I believe
that you can also call wpps with a NULL ini-filename to flush the last
ini-file to disk (not sure).
--
Gert Rijs
g...@wirehub.net (at home)
gert...@corp.ah.nl (at work)
Thanks! That fixed the problem. I simply put the following before
attempting to print, and it worked.
WritePrivateProfileString("","","","");
Thanks again!
Actually, it's a NULL everything except the filename. It's documented in the
help.
--------------------
Dave Connet
Dave_...@krinfo.com
My opinions are my own. I think...