How to lock a file

Hi,
I want to use File Stream Objects to write some infomation in a txt file.
I need to lock the file when I write,because I don't hope other processes access to it.

There is a function:
http://msdn.microsoft.com/en-us/library/8w5bsb4f(v=vs.80).aspx

But it want to use File Stream Objects to write to the file,
does File Stream provide a function which can lock a file?
Or other function I can use to lock?

Thanks for the help in advance.
Dose anyone know ?
From what I see, locking a file is independent from editing the file. You have to use the old FILE pointer approach to do it. More information you can find here:

http://www.cplusplus.com/reference/clibrary/cstdio/FILE/
Thanks! I have solved! Use the last parameter of the fstream::open
Topic archived. No new replies allowed.