Exemplo n.º 1
0
        private static void MarkDocumentAsTemporary(string moniker)
        {
            IVsRunningDocumentTable docTable = (IVsRunningDocumentTable)
                                               ServiceProvider.GlobalProvider.GetService(typeof(SVsRunningDocumentTable));

            uint lockType = (uint)_VSRDTFLAGS.RDT_DontAddToMRU
                            | (uint)_VSRDTFLAGS.RDT_NonCreatable
                            | (uint)_VSRDTFLAGS.RDT_VirtualDocument
                            | (uint)_VSRDTFLAGS.RDT_PlaceHolderDoc;
            IVsHierarchy hierarchy;
            uint         itemid;
            uint         documentCookie;
            IntPtr       docData;

            int hr = docTable.FindAndLockDocument(
                dwRDTLockType: lockType,
                pszMkDocument: moniker,
                ppHier: out hierarchy,
                pitemid: out itemid,
                ppunkDocData: out docData,
                pdwCookie: out documentCookie
                );

            CheckError(hr, "FindAndLockDocument");
            docTable.ModifyDocumentFlags(documentCookie, lockType, 1);
        }