Hello everybody,

When I use ShellExecuteEx in my program to open files which have the system file attribute set these files end up having file attribute normal set, not system.

I'm using the system attribute as a marker and setting it myself elsewhere in the program. It would be nice if it wasn't being changed.

Following is my SHELLEXECUTEINFO and the call to ShellExecuteEx.


;;;;;;;;;;;;;;;;;;;;;;;;;;
mov ShExecInfo.cbSize,sizeof(SHELLEXECUTEINFO)
mov ShExecInfo.fMask,NULL
mov ShExecInfo.hwnd,NULL
mov ShExecInfo.lpVerb,NULL
mov ShExecInfo.lpFile,offset szFileName
mov ShExecInfo.lpParameters,NULL
mov ShExecInfo.lpDirectory,NULL
mov ShExecInfo.nShow,SW_SHOWNORMAL
mov ShExecInfo.hInstApp,NULL

invoke GetFileAttributes,ADDR szFileName
push eax

invoke ShellExecuteEx,ADDR ShExecInfo
pop eax
and eax,FILE_ATTRIBUTE_SYSTEM

.if eax==FILE_ATTRIBUTE_SYSTEM
invoke SetFileAttributes,ADDR szFileName,\
FILE_ATTRIBUTE_SYSTEM


.endif

I tried setting the file attribute after the call and although return values indicate no errors the attribute is not being re-set.

I couldn't find anything in the SDK indicating a value to set in SHELLEXECUTEINFO regarding this nor anything on google. Any ideas or suggestions appreciated.

Btw, how do you use that code thingy?

best regards,

czDrillard
Posted on 2003-09-09 22:24:03 by czDrillard
Maybe that's because the file you're trying to set attributes to is locked by the process spawned by ShellExecuteEx? ShellExecuteEx does not wait until the process spawned by it ends - it returns immediately.
Posted on 2003-09-10 00:56:14 by Morris
Hello Morris,

Thanks for your ideas. I think you are probably right. But what is the solution. Is normal behaviour of ShellExecuteEx to change file attributes?

best regards,

czDrillard
Posted on 2003-09-10 01:18:13 by czDrillard
you shouldn't use system (or any other attributes) for this purpose.

It's treated special by windows (which you really see on the later versions) and can hinder you in changes you make, file moves, whatever you wish to do with the file... because you declared it 'system'.

can't you hold a mini-database or flat file listing all your changes? :| Or use the archive attribute, that one doesn't *do* anything. It has meaning but is not actively used by windows.
Posted on 2003-09-10 03:59:26 by Hiroshimator
Hello Hiro,

Thanks for your reply. I'm marking files in Temporary Internet Folders. These files are normally deleted anyways so warning messages when deleting, etc aren't important to me. Still you are right and it would be better if I didn't use System attribute for a marker. The problem with archive (normal) is it's too common. Creating a data base will waste resources; it's bad enough having one copy of Temporary Internet Files.

best regards,

czDrillard
Posted on 2003-09-10 09:09:24 by czDrillard