Exposes methods that can be called to get information on or close a file that is in use by another application. When an application attempts to access a file and finds that file already in use, it can use the methods of this interface to gather information to present to the user in a dialog box.
The IFileIsInUse interface has these methods.
|IFileIsInUse::CloseFile||Closes the file currently in use.|
|IFileIsInUse::GetAppName||Retrieves the name of the application that is using the file.|
|IFileIsInUse::GetCapabilities||Determines whether the file can be closed and whether the UI is capable of switching to the window of the application that is using the file.|
|IFileIsInUse::GetSwitchToHWND||Retrieves the handle of the top-level window of the application that is using the file.|
|IFileIsInUse::GetUsage||Gets a value that indicates how the file in use is being used.|
In versions of Windows before Windows Vista, when a user attempted to access a file that was open in another application, the user would simply receive a dialog box with a message stating that the file was already open. The message instructed that the user close the other application, but did not identify it. Other than that suggestion, the dialog box provided no user action to address the situation. This interface provides methods that can lead to a more informative dialog box from which the user can take direct action.
Perform these steps to add a file to the ROT:
- Call the GetRunningObjectTable function to retrieve an instance of IRunningObjectTable.
- Create an IFileIsInUse object for the file that is currently in use.
- Create an IMoniker object for the file that is currently in use.
- Insert the IFileIsInUse and IMoniker objects into the ROT by calling IRunningObjectTable::Register.
In the call to Register, specify the ROTFLAGS_ALLOWANYCLIENT flag. This allows the ROT entry to work across security boundaries. Use of this flag requires the calling application to have an explicit Application User Model ID (AppUserModelID) (System.AppUserModel.ID). An explicit AppUserModelID allows the Component Object Model (COM) to inspect the application's security settings. An attempt to call Register with ROTFLAGS_ALLOWANYCLIENT and no explicit AppUserModelID will fail. You can call Register without the ROTFLAGS_ALLOWANYCLIENT flag and the application will work correctly, but only within its own security level.
The value retrieved in the Register method's [out] parameter is used to identify the entry in later calls to retrieve or remove it from the ROT.File Is in Use sample, which demonstrates how to implement IFileIsInUse and register a file with the ROT. It then shows how to customize the File In Use dialog to display additional information and options for files currently opened in an application.
|Minimum supported client||Windows Vista [desktop apps only]|
|Minimum supported server||Windows Server 2008 [desktop apps only]|
|Header||shobjidl_core.h (include Shobjidl.h)|