This is my first real use of the win32 api for file i/o and I can't seem to get it to work.
The goal is to save an xml file with some config settings when the program exits, but I can't seem to get the stupid file to write anything and I have a feeling I am handling the buffers or the string manipulation wrong.
I'm trying to use the win32 api and not iostream, ect ..
Here's the write file section:
Unfortunately my config file comes out empty, so I'm stumped how I'm supposed to handle this, I don't wanna just do a buttload of WriteFiles line for line, I'd rather write it all at once using lstrcat on a single buffer, like I said I'm probably doing the buffer all wrong so any help would be appreciated.Code:HANDLE hConfig = NULL; DWORD dwWrittenBuffer = 0; TCHAR *szWriteBuffer = NULL; hConfig = CreateFile( _T("config.xml"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, 0); if(hConfig != INVALID_HANDLE_VALUE) { lstrcat(szWriteBuffer, _T("<config>")); // do rest of stuff when this works lstrcat(szWriteBuffer, _T("</config>")); WriteFile(hConfig, szWriteBuffer, lstrlen(szWriteBuffer) + 1, &dwWrittenBuffer, 0); CloseHandle(hConfig); }



LinkBack URL
About LinkBacks


