Hello everyone,
On Windows platform, which API could be used to check whether a file is opened (either by other thread or process or even the same thread) or not?
C++ is fine.
thanks in advance,
George
Printable View
Hello everyone,
On Windows platform, which API could be used to check whether a file is opened (either by other thread or process or even the same thread) or not?
C++ is fine.
thanks in advance,
George
You can try to open the file with "NO sharing", then it will fail if some other process has the file open.
--
Mats
ifstream is fine.
ifstream::open with appropriate open protection constants, which I don't know what they're called or located.
when you say a file do you mean a process or what , because your making it sound like a .txt file
I don't know, but I doubt it. The class takes its arguments from ios_base.
and to check if its open ?
i would check if the process notepad is open then use FindWindow to check is the string of the windowtext is matching your textfile description
George wants to find out if the file is open, not if a process is open. And this doesn't just include Notepad. What you describe is a really horrible way of doing it.