tags:

views:

43

answers:

1

I don't know what I have been done. I am making a program. If I rerun my program, an error occurred :

"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item"

My program use UAC manifest. I've tried to not use the manifest and got same error.

By using "Run as Administrator", I can rerun my program!

Have you ever face this problem? What's wrong with Windows? What kind of code should I look into my source code?

Because of this problem, myprogram have a mutex that created by Windows.. lol

+1  A: 

Your program is trying to create or open a file. The first time you ran your program as admin it created it, and now the ACL on that file is read-only for regular users and read-write for admins. Running your program as regular user fails with access denied when it tries to open the file for write.

Franci Penov
And so the solution is to correctly close the file, probably by wrapping the use of the file in `using` block.
Joel Coehoorn
@Joel Coehoorn - Lol, yes. I probably should've mentioned that.
Franci Penov
Yes my program often opens and creates a file. Sorry I don't understand your suggestion "using block". Is it C++ style? I don't code with it. Can you tell me more what should I do with my source code? What should I look for?
It might help if you actually post the code that creates the file. This would help us understand what language and what APIs you are using, so we can suggest the right solution to your problem.
Franci Penov
I am using Delphi. My example code FS := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); Every time I use that code then I have to do FS.free, is that what you mean?
Yes, you have to close the file when you're done with it. I don't know Delphi, but using FS.free sounds like the right thing here.
Franci Penov