Jump to content

CreateFile() problem


Guest chris sjak

Recommended Posts

Guest chris sjak

Hi,

I have just started programming for the Smartphone OS. But I don't have that much experience in embedded c++. I have created a

dialog application, and I would like it to create a file. I have written the following code, but when I run the app, it says (first time run) GetLastError = 0, and (second time run) GetLastError = b7. When I afterwards uses smartexplorer to check if the file has been created, it doesn't show in the root :) . Anyone has an idea of what i'm doing wrong

HANDLE hFile;


	hFile = CreateFile( _T("	estfile.txt"),GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);


	TCHAR szError[512]; 


	wsprintf(szError, TEXT("%x"), GetLastError()); 


	MessageBox(szError,_T("File error"));

One last thing, where can i find a table (or something) where i can se the corresponding error-messages to the error id nr (eg. 0 and b7)?.

Any help is greatly appriciated,

best regards

Christian

Link to comment
Share on other sites

Try to use 0 instead of FILE_SHARE_READ to see if it's working better

For a better explanation of error codes, look for the FormatMessage function in the API, or check winerror.h :wink:

Link to comment
Share on other sites

Guest chris sjak

Hmm it didn't help to use 0 instead of FILE_SHARE_READ.

I understant that error 0 means error_success, which should mean that the file has been created. But howcome it doesn't show... weird

Christian

Link to comment
Share on other sites

Guest chris sjak

Sorted out, apparently there was nothing wrong. The problem was that it didn't show up in smartexplorer when i created the file, maybe because I had an smartexplorer instance running at the same time. But if i quit smartexplorer and opened it again the file shows. Silly me not to have checked that before... Doh. :roll:

Christian

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.