IVsUserSettingsQuery Interface
Assembly: Microsoft.VisualStudio.Shell.Interop.8.0 (in microsoft.visualstudio.shell.interop.8.0.dll)
Notes for Implementers
Implement if a VSPackage must control whether its settings are saved to a Visual Studio settings file.
Notes for Callers
This interface should be implemented only if a VSPackage must control whether its settings are saved. For instance, a VSPackage may let a user change settings for the current session, but will only update stored information if the user clicks 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 its settings category argument, to determine whether a particular group of settings must be saved.For instance, in the following example, the VSPackage always requests that its command bar state be saved, but it only requests that its key binding state be saved if 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;
}