News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

CreateFile OPEN_ALWAYS flag doesn't work

Started by ecube, May 02, 2010, 04:19:05 AM

Previous topic - Next topic

ecube

can't get the 'OPEN_ALWAYS' flag to work, it suppose to open the file if it exists otherwise create.

invoke CreateFile,addr filename,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,0


MichaelW

OPEN_ALWAYS works for me, just as it is documented to work. If the file does not exist then the function returns a handle and GetLastError returns zero. If the file does exist then the function returns a handle and GetLastError returns ERROR_ALREADY_EXISTS. If the function fails (returns INVALID_HANDLE_VALUE) then the problem is elsewhere.
eschew obfuscation

ecube

herm...not workin correctly on my xp, works on win7 :\ same code,both places have write permission for the directory they're in.

MichaelW

How is it failing, and what does GetLastError return?
eschew obfuscation