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
'Déclaration
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
'Utilisation
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
)
function FindAndLockDocument(
dwRDTLockType : uint,
pszMkDocument : String,
ppHier : IVsHierarchy,
pitemid : uint,
ppunkDocData : IntPtr,
pdwCookie : uint
) : int
Parameters
dwRDTLockType
Type: System.UInt32[in] Flags whose values are taken from the _VSRDTFLAGS enumeration.
pszMkDocument
Type: System.String[in] Path to the located document.
ppHier
Type: Microsoft.VisualStudio.Shell.Interop.IVsHierarchy%[out, optional] Returns the IVsHierarchy interface for the located document.
pitemid
Type: System.UInt32%[out, optional] Returns an item identifier of the located document. This is a unique identifier or it can be one of the following values: VSITEMID_NIL, VSITEMID_ROOT, or VSITEMID_SELECTION.
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:
Permissions
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
IVsRunningDocumentTable Interface