Handmade Hero»Forums»Code
CJ Nelson
8 posts
Day 25 CreateFile error
Edited by CJ Nelson on
Hey person reading this!

I could use some help working through a problem I encountered while following along with Day 25. My CreateFileA returns error 32 which means "The process cannot access the file because it is being used by another process.". Does anyone know what could be making it this way?

Please and thanks in advance.
511 posts
Day 25 CreateFile error
close any program that has the file open
Mārtiņš Možeiko
2562 posts / 2 projects
Day 25 CreateFile error
What is file path you are passing to CreateFile? For what file does this happen?

And you really shouldn't post on forums complete handmade hero source code you bought.
CJ Nelson
8 posts
Day 25 CreateFile error
Thank you for the fast reply, I appreciate it.

Here's the file path W:\\build\\loop_edit_1.hmi. It's for the create file calls in the loop editing features.

Also thank you for letting me know that I shouldn't upload that project. I'll remember that in future posts.
Mārtiņš Možeiko
2562 posts / 2 projects
Day 25 CreateFile error
Do you have this file present on disk? If yes, can you trey opening it in some hexeditor and see it succeeds? What if you open it as read-only vs read-write?

Does this error happen every time you call loop editing code, or maybe it succeeds first time and fails later (which would indicate you are not closing file properly).

Is the path really with \\ characters, or you are showing simply escaped \ character?
CJ Nelson
8 posts
Day 25 CreateFile error
Thank you for the suggestions.

I've tried opening it in a hex editor and I receive an error for the file size being too big.

The error does happen during the first time calling the CreateFile function.

The path passed into CreateFile does use the \\ characters.

Again thanks for posting a response to my question. Do you have any other ideas/does this information help?
Mārtiņš Možeiko
2562 posts / 2 projects
Day 25 CreateFile error
Wait, how can this error happen on first call to CreateFile and file already exists? Who creates file if first call to create fails?

Try opening file with different hexeditor who can open the file. I want to see if other programs can open this hmi file. Other than that I have no idea what is wrong.

Using \\ is wrong, that shouldn't work, it should be just \. Of course looking in the debugger it should show \\ which is escaped \ character, which is fine.
CJ Nelson
8 posts
Day 25 CreateFile error
Thank you I figured it out. There was another line of code creating the same hmi file on a loop.