I'm using CreateFile/ReadFile/WriteFile for reading and writing to text files. I have the text files pre-saved as Unicode, but when I open them with CreateFile the text files then saves as an ANSI file. All my code uses Unicode strings and function calls. This is real embarrassing. I used to consider myself a decent Windows Developer but I've been hitting nothing but brick walls with Unicode. I know there has to be a way to change the file attribute to Unicode before I close the handle.
NEVERMIND!!! problem fixed. In case you are wondering here is the fixed test program:#include #include
INT _tmain(INT argc, TCHAR **argv)
HANDLE hFile = NULL;
DWORD numBytes = 0;
TCHAR szBuffer = TEXT("Hello World.");
hFile = CreateFile(TEXT("myfile.txt"),GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile == INVALID_HANDLE_VALUE)
MessageBoxEx(NULL,TEXT("Could not open specified file."),TEXT("Error"),MB_ICONERROR,LANG_ENGLISH);
hFile = NULL;
/* i'm still wondering if the sizeof(TCHAR)*_countof(szBuffer) is an error though. Should I use lstrlen instead of _countof?