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.