I am going to use this handle for WriteFile function but GetLastError gives me #5 . I know it is Access Denied but i don't know what to do. I check this for a while and i saw its about User Rights but i already in as Administrator .
And the other thing is : I'm coding at VS2010 and when i execute code GetLastError Gives me #5 but when i execute exe(C://blah/blah/PROJECT_NAME/debug/PROJECT.exe) it gives me #6 .
I just confused . Many thanks for your helps.
HANDLE hAndle = CreateFile("test.txt",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
char msge[]="\nsomething\n";
DWORD gb;
if( WriteFile(hAndle,msge,strlen(msge),&gb,NULL) != TRUE )
cout << GetLastError() << endl;
EDIT : what a stupid i am . I fixed that problem with this : GENERIC_WRITE | GENERIC_READ
Really thank you...
ERROR_ACCESS_DENIEDmeans you don't have sufficient rights. After all, you are trying to write to a handle that you only asked permission to read from.ERROR_INVALID_HANDLEmeans that your handle is invalid. That's a consequence of your failure to check for errors when callingCreateFile. - David Heffernan