BSTR CTes::ReadUnicodeFile(CString strFileName)
{
CString szMsg;
CString sFileName;
BSTR MsgStr;
_finddata_t cfile;
long fHandle;
if ((fHandle = _findfirst(strFileName,&cfile)) != -1)
{
_findclose(fHandle);
// File Found....check for string
fHandle = open(strFileName,O_RDONLY|_O_U16TEXT);
long fLength = filelength(fHandle);
char *buf = new char[fLength+1];
int ReadChars = read(fHandle,buf,fLength);
buf[ReadChars] = '\0';
close(fHandle);
MsgStr = SysAllocString((BSTR)buf);
delete buf;
return MsgStr ;
}
else
{
return NULL;
}
}
No comments:
Post a Comment