File monitor
-
Hi, How can i get file status(ie. open, close, edit) using C or C++. Is there any API in windows. Thanks in advance Suzu
A file is either opened or closed by one or more processes. The mode in which it is open is a characteristic of the handle, which is owned by a process, not the file. (not all handles are owned by processes, but let's keep this simple.) The bad news is: there is no API. You could have a go at the object manager[^] name space, but this requires the openfiles global flag to be on. Turning it on or off will require a reboot. Short of that, you can only obtain the information in kernel mode, and that will require a device driver.
-
Hi, How can i get file status(ie. open, close, edit) using C or C++. Is there any API in windows. Thanks in advance Suzu
Do you mean the context menu of a file by this "file status(ie. open, close, edit)", or do you mean if a file can be accessed, opened for reading/writing, etc.? You can do that by calling _open[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Do you mean the context menu of a file by this "file status(ie. open, close, edit)", or do you mean if a file can be accessed, opened for reading/writing, etc.? You can do that by calling _open[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal
-
Hi, How can i get file status(ie. open, close, edit) using C or C++. Is there any API in windows. Thanks in advance Suzu
Accessing File Status (MFC) Also, you can try
CFile::GetStatus
CFile theFile;
char* szFileName = "X:\\TEXT.TXT";
BOOL bOpenOK;CFileStatus status;
if( CFile::GetStatus( szFileName, status ) ) bOpenOK = theFile.Open( szFileName, CFile::modeWrite );
else bOpenOK = theFile.Open( szFileName, CFile::modeCreate | CFile::modeWrite );http://msdn.microsoft.com/en-us/library/e3z63bza(VS.80).aspx[^] .
-
Accessing File Status (MFC) Also, you can try
CFile::GetStatus
CFile theFile;
char* szFileName = "X:\\TEXT.TXT";
BOOL bOpenOK;CFileStatus status;
if( CFile::GetStatus( szFileName, status ) ) bOpenOK = theFile.Open( szFileName, CFile::modeWrite );
else bOpenOK = theFile.Open( szFileName, CFile::modeCreate | CFile::modeWrite );http://msdn.microsoft.com/en-us/library/e3z63bza(VS.80).aspx[^] .
-
Sorry about that. This link below got truckloads of API's to hook your app on for "monitoring" http://win32-hook.vista-files.org/[^]
-
Just i want to get current status of the file. ie. 1) It is opend 2) It is Closed 3) It is modified Thanx
You need to be more clear. 1) A file might be opened in the sense that there are handles of that file opened by one or more processes. 2) I don't know what you mean by "closed", is it that no process has opened the file currently? 3) A file has always been modified somewhere in the past, it might be a minute ago or a month ago or 10 years ago. That's how you create a file, you create it empty and then modify it. Do you mean that you want to get the date of last modification? What do you mean by "it is modified"?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal