IVsUserSettingsQuery IVsUserSettingsQuery IVsUserSettingsQuery Interface


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

public interface IVsUserSettingsQuery
type IVsUserSettingsQuery = interface
Public Interface IVsUserSettingsQuery


STDMETHOD(NeedExport)(WCHAR* pszCategoryGUID, BOOL *pfNeedExport)  
    if (!pfNeedExport)  
        return E_INVALIDARG;  

    CLSID clsidCategory;  
    HRESULT hr= S_OK;  

    hr = CLSIDFromString(pszCategoryGUID, &clsidCategory);  
    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.  
        hr = E_UNEXPECTED;  
    return hr;  


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.


NeedExport(String, Int32) NeedExport(String, Int32) NeedExport(String, Int32)

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

Applies to