IVsUserSettingsQuery::NeedExport Method (String^, Int32)

 

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)

int NeedExport(
	String^ szCategoryGUID,
	[OutAttribute] int% pfNeedExport
)

Parameters

szCategoryGUID
Type: System::String^

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

pfNeedExport
Type: System::Int32

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

Return Value

Type: System::Int32

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

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.

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;
}
Return to top
Show: