No worries there. I only use magic numbers for temporary or debug code which I would delete in 10 minutes anyway. :)
Actually, I've run into error 5 so much, I know what it means, even from month to month or year to year. Kind of like everyone knows what 0xC0000005 means.Quote:
And even if it's just you that will be maintaining it; unless you have an extremely good memory, you'll probably forget what the magic number meant a few weeks/months later.
But that's besides the point, why would this happen? Does anyone know of any previous API calls that could do this?
I would suggest that you check the security properties of the Documents and Settings folder on your Win2k machine to verify that you have the necessary permissions to modify (write to) TESTFILE.txtCode:
C:\\Documents and Settings\\Yarin\\Desktop\\TESTFILE.txt");
Yes, full rights, all are set to allow.
Both code paths have beeps. Are you sure you're hearing the one you think you're hearing?
Well, considering that you are invoking so many API calls (which can clear and set an error themselves) after CreateFile before calling GetLastError, the code you're getting may not relate to CreateFile at all...
CreateFile() would set the last error to 0 (ERROR_SUCCESS) then.
the docs say that some functions set ERROR_SUCCESS, and some don't. CreateFile doesn't say whether it does or doesn't, so it might not.
If the function succeeds with CREATE_ALWAYS or OPEN_ALWAYS and the file already existed, GetLastError() returns ERROR_ALREADY_EXISTS, though the function has succeeded. Otherwise, on success, it returns 0. On failure it always returns the error code.
ok, right you are, except if it's not a valid path.