Compartir a través de


IVsUserSettingsQuery.NeedExport Method

Indicates whether the specified category requires an export of its settings.

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

Syntax

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

Parameters

  • szCategoryGUID
    Type: String

    [in] GUID identifying the particular settings category (defined by a Custom Settings Point) being queried.

  • pfNeedExport
    Type: Int32%

    [out] Boolean value returned to indicate if the IDE should call the VSPackage's export settings implementation.

Return Value

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

Remarks

A single VSPackage can support more than one Custom Settings Point (settings category). Therefore, implementations of NeedExport must check the supplied Custom Settings Point's identifying GUID or settings category argument, to determine if a particular group of settings needs to be saved.

Examples

In this example, the VSPackage always requests that its command bar state is saved, but only requests its key binding state be saved it a flag has been set.

STDMETHOD(NeedExport)(WCHAR* pszCategoryGUID, BOOL *pfNeedExport)
{
    if (!pfNeedExport)
        return E_INVALIDARG;
    
    CLSID clsidCategory;
    HRESULT hr= S_OK;
    
    hr = CLSIDFromString(pszCategoryGUID, &clsidCategory);
    IfFailGo(hr);
    if (GUID_Profiles_CommandBars == clsidCategory) {
        *pfNeedExport = TRUE; //Always export Command Bar Configuration
    }else if (GUID_Profiles_KeyBindings == clsidCategory) {
        *pfNeedExport = FALSE; //By Default don't export key bindings
        if (m_fMake_Permanent)
            *pfNeedExport = TRUE; //Export if user wants current configuration saved.
    }else{
        hr = E_UNEXPECTED;
    }
 Error:
    return hr;
}

.NET Framework Security

See Also

Reference

IVsUserSettingsQuery Interface

Microsoft.VisualStudio.Shell.Interop Namespace

IVsUserSettings

ImportSettings

Other Resources

Persisting Settings

How to: Use Interop Assemblies to Import Settings

Working with Settings