Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Vista Newsgroups > Vista security

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

Reply
 
Old 02-26-2007   #1 (permalink)
Michael Harvey
Guest


 
 

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

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 System SpecsSystem Spec
Old 02-28-2007   #2 (permalink)
Michael Harvey
Guest


 
 

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

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 System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Tape Drives - Allow or Deny Read and Write Access Tutorials
DVD and CD Drive - Allow or Deny Read and Write Access Tutorials
Directory where my software is installed must permit write access Vista General
Write files in directory tree PowerShell
File permissions in the Program Files directory Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46