please HELP! Trouble with unicode - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

please HELP! Trouble with unicode

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:


INT _tmain(INT argc, TCHAR **argv[])
DWORD numBytes = 0;
TCHAR szBuffer[] = TEXT("Hello World.");


MessageBoxEx(NULL,TEXT("Could not open specified file."),TEXT("Error"),MB_ICONERROR,LANG_ENGLISH);
return 1;


hFile = NULL;
return 0;

/* i'm still wondering if the sizeof(TCHAR)*_countof(szBuffer) is an error though. Should I use lstrlen instead of _countof?
Sign In or Register to comment.