Okay. I am trying to read a file in VC++ MFC using API. I don't want to use all of this stupid C++ built in commands. I am trying to obtain a handle to a file so that I can read it later on, however It wont give me a valid handle. It keeps returning -1. I thought it might be the filename so I tried "\\" as directory changes but still didnt work. Here is the source I am trying, Its messy... but I figure it should work.
HANDLE hHandle;
HANDLE hTemp;
long lHandle;
char *sHandle;
SECURITY_ATTRIBUTES blah;
//UNDER HERE IS MY PROBLEMS:
blah.nLength = sizeof(SECURITY_ATTRIBUTES);
hHandle = CreateFile("C:\documents and settings\xei\desktop\StudyGuide.txt",
GENERIC_READ,
0,
&blah,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
//UP THERE IS MY PROBLEMS;
//This messages the Handle of the file. It seems to be -1 all of the time.
lHandle = (long)hHandle;
sHandle = new char[10];
sHandle[9] = (char)0;
ltoa(lHandle,sHandle,10);
MessageBox(sHandle,NULL,MB_OK);
CloseHandle(hHandle);
delete [] sHandle;



LinkBack URL
About LinkBacks


