Share via


IVsRunningDocumentTable2.QueryCloseRunningDocument Method

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)

Syntax

'Declaration
Function QueryCloseRunningDocument ( _
    pszMkDocument As String, _
    <OutAttribute> ByRef pfFoundAndClosed As Integer _
) As Integer
int QueryCloseRunningDocument(
    string pszMkDocument,
    out int pfFoundAndClosed
)
int QueryCloseRunningDocument(
    [InAttribute] String^ pszMkDocument, 
    [OutAttribute] int% pfFoundAndClosed
)
abstract QueryCloseRunningDocument : 
        pszMkDocument:string * 
        pfFoundAndClosed:int byref -> int
function QueryCloseRunningDocument(
    pszMkDocument : String, 
    pfFoundAndClosed : int
) : int

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.

Remarks

COM Signature

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.

.NET Framework Security

See Also

Reference

IVsRunningDocumentTable2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace