Compartilhar via


IVsUserSettingsQuery Interface

Allows a VSPackage to indicate if its settings need to be saved or not.

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

Syntax

'Declaration
<GuidAttribute("334E1F15-7D97-4231-81B0-998E4A960E69")> _
<InterfaceTypeAttribute()> _
Public Interface IVsUserSettingsQuery
[GuidAttribute("334E1F15-7D97-4231-81B0-998E4A960E69")]
[InterfaceTypeAttribute()]
public interface IVsUserSettingsQuery
[GuidAttribute(L"334E1F15-7D97-4231-81B0-998E4A960E69")]
[InterfaceTypeAttribute()]
public interface class IVsUserSettingsQuery
[<GuidAttribute("334E1F15-7D97-4231-81B0-998E4A960E69")>]
[<InterfaceTypeAttribute()>]
type IVsUserSettingsQuery =  interface end
public interface IVsUserSettingsQuery

The IVsUserSettingsQuery type exposes the following members.

Methods

  Name Description
Public method NeedExport Indicates whether the specified category requires an export of its settings.

Top

Remarks

Notes for Implementers

Implement if a VSPackage needs to control its settings being saved to a Visual Studio settings file.

Notes for Callers

This interface should only be implemented if a VSPackage needs to control the savings of its settings.

For instance, a VSPackage may allow users to change settings for the current session, but only update stored information when they click a Save button.

If a VSPackage does not implement this interface, its state is always exported.

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.

For instance, in the example below, the VSPackage always requests that its command bar state is saved, but only requests its key binding state be saved if a flag has been set.

Examples

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;
}

See Also

Reference

Microsoft.VisualStudio.Shell.Interop Namespace

IVsUserSettings

Other Resources

Persisting Settings

How to: Use Interop Assemblies to Import Settings

Working with Settings