다음을 통해 공유


IVsRunningDocumentTable.FindAndLockDocument Method

Locates a document in the RDT using the document file name, then obtains a read or edit lock on that document.

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

Syntax

‘선언
Function FindAndLockDocument ( _
    dwRDTLockType As UInteger, _
    pszMkDocument As String, _
    <OutAttribute> ByRef ppHier As IVsHierarchy, _
    <OutAttribute> ByRef pitemid As UInteger, _
    <OutAttribute> ByRef ppunkDocData As IntPtr, _
    <OutAttribute> ByRef pdwCookie As UInteger _
) As Integer
‘사용 방법
Dim instance As IVsRunningDocumentTable
Dim dwRDTLockType As UInteger
Dim pszMkDocument As String
Dim ppHier As IVsHierarchy
Dim pitemid As UInteger
Dim ppunkDocData As IntPtr
Dim pdwCookie As UInteger
Dim returnValue As Integer

returnValue = instance.FindAndLockDocument(dwRDTLockType, _
    pszMkDocument, ppHier, pitemid, ppunkDocData, _
    pdwCookie)
int FindAndLockDocument(
    uint dwRDTLockType,
    string pszMkDocument,
    out IVsHierarchy ppHier,
    out uint pitemid,
    out IntPtr ppunkDocData,
    out uint pdwCookie
)
int FindAndLockDocument(
    [InAttribute] unsigned int dwRDTLockType, 
    [InAttribute] String^ pszMkDocument, 
    [OutAttribute] IVsHierarchy^% ppHier, 
    [OutAttribute] unsigned int% pitemid, 
    [OutAttribute] IntPtr% ppunkDocData, 
    [OutAttribute] unsigned int% pdwCookie
)
abstract FindAndLockDocument : 
        dwRDTLockType:uint32 * 
        pszMkDocument:string * 
        ppHier:IVsHierarchy byref * 
        pitemid:uint32 byref * 
        ppunkDocData:IntPtr byref * 
        pdwCookie:uint32 byref -> int 
function FindAndLockDocument(
    dwRDTLockType : uint, 
    pszMkDocument : String, 
    ppHier : IVsHierarchy, 
    pitemid : uint, 
    ppunkDocData : IntPtr, 
    pdwCookie : uint
) : int

Parameters

  • pszMkDocument
    Type: System.String
    [in] Path to the located document.
  • ppunkDocData
    Type: System.IntPtr%
    [out, optional] Returns the IUnknown interface. See Remarks for details.
  • pdwCookie
    Type: System.UInt32%
    [out, optional] Returns an abstract value for the document. See Remarks for details.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

FindAndLockDocumentEx is similar to this method but also allows the specification of a preferred hierarchy/itemid pair for the document in case an RDT_EditLock is desired and the document is currently registered with only a RDT_ReadLock with no hierarchy/itemid assigned.

COM Signature

From vsshell.idl:

HRESULT IVsRunningDocumentTable::FindAndLockDocument(
   [in] VSRDTFLAGS      dwRDTLockType,
   [in] LPCOLESTR       pszMkDocument,
   [out] IVsHierarchy **ppHier,
   [out] VSITEMID      *pitemid,
   [out] IUnknown     **ppunkDocData,
   [out] VSCOOKIE      *pdwCookie
);

punkDocData Parameter

If the document is registered, then the punkDocData value that is returned is always non-null because the environment will create a punkDocData on behalf of Editors that registered with a nulla null reference (Nothing in Visual Basic) value for punkDocData, as is the case when an Editor does not have data/view separation. This object represents the document data object associated with the registered document. Typically, the IVsPersistDocData and IVsDocDataFileChangeControl interfaces are obtained from this IUnknown object.

pdwCookie Parameter

The pdwCookie parameter returns a cookie representing the document. This cookie can be passed to the following methods:

.NET Framework Security

See Also

Reference

IVsRunningDocumentTable Interface

IVsRunningDocumentTable Members

Microsoft.VisualStudio.Shell.Interop Namespace