Compartir a través de


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

'Declaración
<InterfaceTypeAttribute()> _
<GuidAttribute("334E1F15-7D97-4231-81B0-998E4A960E69")> _
Public Interface IVsUserSettingsQuery
'Uso
Dim instance As IVsUserSettingsQuery
[InterfaceTypeAttribute()]
[GuidAttribute("334E1F15-7D97-4231-81B0-998E4A960E69")]
public interface IVsUserSettingsQuery
[InterfaceTypeAttribute()]
[GuidAttribute(L"334E1F15-7D97-4231-81B0-998E4A960E69")]
public interface class IVsUserSettingsQuery
public interface IVsUserSettingsQuery

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

Concepts

Persisting Settings

How to: Use Interop Assemblies to Import Settings

Working with Settings

Reference

IVsUserSettingsQuery Members

Microsoft.VisualStudio.Shell.Interop Namespace

IVsUserSettings