共用方式為


IVsPersistHierarchyItem2.SaveItem Method

Saves the hierarchy item to disk.

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

Syntax

'Declaration
Function SaveItem ( _
    dwSave As VSSAVEFLAGS, _
    pszSilentSaveAsName As String, _
    itemid As UInteger, _
    punkDocData As IntPtr, _
    <OutAttribute> ByRef pfCanceled As Integer _
) As Integer
int SaveItem(
    VSSAVEFLAGS dwSave,
    string pszSilentSaveAsName,
    uint itemid,
    IntPtr punkDocData,
    out int pfCanceled
)
int SaveItem(
    [InAttribute] VSSAVEFLAGS dwSave, 
    [InAttribute] String^ pszSilentSaveAsName, 
    [InAttribute] unsigned int itemid, 
    [InAttribute] IntPtr punkDocData, 
    [OutAttribute] int% pfCanceled
)
abstract SaveItem : 
        dwSave:VSSAVEFLAGS * 
        pszSilentSaveAsName:string * 
        itemid:uint32 * 
        punkDocData:IntPtr * 
        pfCanceled:int byref -> int
function SaveItem(
    dwSave : VSSAVEFLAGS, 
    pszSilentSaveAsName : String, 
    itemid : uint, 
    punkDocData : IntPtr, 
    pfCanceled : int
) : int

Parameters

  • pszSilentSaveAsName
    Type: String

    [in] File name to be applied when dwSave is set to VSSAVE_SilentSave.

  • itemid
    Type: UInt32

    [in] Item identifier of the hierarchy item saved from VSITEMID.

  • punkDocData
    Type: IntPtr

    [in] Pointer to the IUnknown interface of the hierarchy item saved.

  • pfCanceled
    Type: Int32%

    [out] true if the save action was canceled.

Return Value

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

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsPersistHierarchyItem2::SaveItem(
   [in] VSSAVEFLAGS dwSave,
   [in] LPCOLESTR pszSilentSaveAsName,
   [in] VSITEMID itemid,
   [in] IUnknown *punkDocData,
   [out] BOOL *pfCanceled
);

The caller of this method is responsible for determining whether the document is in the Running Document Table and should pass in the correct punkDocData parameter. It is not necessary for the implementer of this method to call the FindAndLockDocument method when punkDocData is nulla null reference (Nothing in Visual Basic).

When a document is saved, this method is called to enable the owning hierarchy to establish control. Then the hierarchy can use any private mechanism to persist the document. For hierarchies that use standard editors, the implementation of SaveItem method is to call the following:

.NET Framework Security

See Also

Reference

IVsPersistHierarchyItem2 Interface

Microsoft.VisualStudio.Shell.Interop Namespace