IVsRunningDocumentTable2::QueryCloseRunningDocument Method (String^, Int32)

 

Closes the specified document, with possible confirmation, if it is open in an incompatible editor.

Namespace:   Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop.8.0 (in Microsoft.VisualStudio.Shell.Interop.8.0.dll)

int QueryCloseRunningDocument(
	String^ pszMkDocument,
	[OutAttribute] int% pfFoundAndClosed
)

Parameters

pszMkDocument
Type: System::String^

[in] The path to the document to close.

pfFoundAndClosed
Type: System::Int32

[out] Returns non-zero (TRUE) if the document was found and closed; otherwise, returns zero (FALSE). See Remarks.

Return Value

Type: System::Int32

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

From vsshell80.idl:

HRESULT QueryCloseRunningDocument(
   [in] LPCOLESTR pszMkDocument,
   [out] BOOL *pfFoundAndClosed
);

This method is called after a document has been opened in an editor that turns out to be incompatible with the document. This method closes the document automatically unless certain conditions exist, in which case, the user is prompted to close the document. The following list indicates what happens when this method is called.

  • If the document is not in the running document table (RDT), then this method sets the pfFoundAndClosed parameter to zero (FALSE) and returns S_OK.

  • If the document is in the RDT and has only read locks, then the document is automatically closed.

  • If the document is in the RDT and has edit locks, then the user is prompted to close the file.

  • If the user chooses not to close the document, then this method sets the pfFoundAndClosed parameter to zero (FALSE) and returns OLE_E_PROMPTSAVECANCELLED.

  • If the document is actually closed, then this method sets the pfFoundAndClosed parameter to non-zero (TRUE) and returns S_OK.

Return to top
Show: