I am trying to create a file under C:\ in Masm code. but can never success. I don't know where is wrong with the code.
INCLUDE Irvine32.inc
.data
fileName BYTE "C:\\haha.txt",0
fileHandle HANDLE ?
.code
main PROC
INVOKE CreateFile,
ADDR filename, GENERIC_WRITE, DO_NOT_SHARE, null, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,0
exit
main ENDP
END main
if I change the
fileName BYTE "haha.txt",0
it will success write the file haha.txt on the program's folder. i dont understand why it does not write out to C:\ also, i am using visual studio 2013 and i run the program by run it under debug,start without debugging.
It is a permission problem. If you run the program as administrator, you will see that the file is created. Just tested it with your code and it works.