I'm trying to read data from file into a Unicode string, and even though that according to dwRead ,
it does read bytes from the file, the szUnicode string is still empty.
here is the code:
anyone has any idea?Code:wchar_t *getFile(char *fname) { HANDLE hFile=CreateFile(fname, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); int num; wchar_t *szUnicode; DWORD dwRead; if(hFile==INVALID_HANDLE_VALUE) return NULL; num=GetFileSize(hFile,NULL); szUnicode=(wchar_t*)malloc(sizeof(wchar_t) * num); ReadFile(hFile,(LPVOID)szUnicode,num,&dwRead,NULL); wprintf(szUnicode); CloseHandle(hFile); return szUnicode; }
thanks in advance.




Reply With Quote