다음을 통해 공유


IVsUserSettingsQuery.NeedExport(String, Int32) Method

Definition

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

public:
 int NeedExport(System::String ^ szCategoryGUID, [Runtime::InteropServices::Out] int % pfNeedExport);
int NeedExport(std::wstring const & szCategoryGUID, [Runtime::InteropServices::Out] int & pfNeedExport);
public int NeedExport (string szCategoryGUID, out int pfNeedExport);
abstract member NeedExport : string * int -> int
Public Function NeedExport (szCategoryGUID As String, ByRef pfNeedExport As Integer) As Integer

Parameters

szCategoryGUID
String

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

pfNeedExport
Int32

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

Returns

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

Examples

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

Remarks

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.

Applies to