• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

How to open a file for read/write access in Program Files directory

M

Michael Harvey

#1
Hi,

How should I open a file in the Program Files directory for read/write
access?

In Vista Business 32-bit as administrator with UAC turned on, the OpenFile
API call fails when trying to open a file for read/write in the Program
Files directory. The call is

OpenFile(FileName, &OpenBuff, OF_READWRITE);

returning HFILE_ERROR.

When accessing the file with Explorer, I can do anything I want with the
file.

Should I be using CreateFile with certain parameters instead of OpenFile?
 

My Computer

M

Michael Harvey

#2
I've got an answer for this. It has to do with running as an Administrator.

"Michael Harvey" <michaelharvey@nospam.sympatico.ca> wrote in message
news:%23fnb50cWHHA.1200@TK2MSFTNGP02.phx.gbl...
> Hi,
>
> How should I open a file in the Program Files directory for read/write
> access?
>
> In Vista Business 32-bit as administrator with UAC turned on, the OpenFile
> API call fails when trying to open a file for read/write in the Program
> Files directory. The call is
>
> OpenFile(FileName, &OpenBuff, OF_READWRITE);
>
> returning HFILE_ERROR.
>
> When accessing the file with Explorer, I can do anything I want with the
> file.
>
> Should I be using CreateFile with certain parameters instead of OpenFile?
>
>
 

My Computer