Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreateFile(... hTemplateFile)

201 views
Skip to first unread message

Norman Bullen

unread,
Dec 14, 2008, 9:29:53 PM12/14/08
to
According to MSDN, the last argument in a call to CreateFile() may be a
handle to a file which is used as a template when creating a new file.
"The template file supplies file attributes and extended attributes for
the file that is being created."

I haven't been able to get this to work. None of the attributes that I'm
looking at (read-only, hidden, archive, indexing service, or file times)
are transferred to the file being created.

My template file was opened with GENERIC_READ as required by the
CreateFile() documentation and GENERIC_WRITE was specified in the call
to CreateFile() when creating the new file. Is there anything else that
needs to be specified?

I have be able to apply all of these attributes by using a combination
of GetFileAttributesEx(), SetFileTime(), and SetFileAttributes(). When
doing this, the only access modes required are FILE_READ_ATTRIBUTES and
FILE_READ_EA for the source file and FILE_WRITE_ATTRIBUTES and
FILE_WRITE_EA for the created file.

I would prefer not to use SetFileAttributes() as it requires a file name
string rather than a handle which implies an additional pass through the
file look-up system; this may cause an annoying loss of performance
because my application will be creating files on a remote system.
--
Norm

To reply, change domain to an adult feline.

Jujitsu Lizard

unread,
Dec 15, 2008, 12:09:55 AM12/15/08
to
"Norman Bullen" <no...@BlackKittenAssociates.com> wrote in message
news:HM-dnRB0irVpJtjU...@earthlink.com...

I'm naturally assuming you are specifying CREATE_NEW rather than
CREATE_ALWAYS. (Reason: if you ain't creating a new one ...)

> --
> Norm
>
> To reply, change domain to an adult feline.

You know, I had to think for about 10 seconds to figure out what you
probably meant. You have left the spammers behind, definitely. You almost
left me behind.

Your statement is a little ambiguous: do you mean blackXXXassociates or
XXX.com. I'm guessing the first one. I didn't want to put the actual name
there, in case some clever spam spider would pick it up.

The Lizard

0 new messages