Delen via


CSettingsStoreSP Class

The CSettingsStoreSP class is a helper class that you can use to create instances of the CSettingsStore Class.

class CSettingsStoreSP

Members

Public Constructors

Name

Description

CSettingsStoreSP::CSettingsStoreSP

Constructs a CSettingsStoreSP object.

Public Methods

Name

Description

CSettingsStoreSP::Create

Creates an instance of a class that is derived from CSettingsStore.

CSettingsStoreSP::SetRuntimeClass

Sets the runtime class. The Create method uses the runtime class to determine what class of objects to create.

Data Members

Name

Description

m_dwUserData

Custom user data that is stored in the CSettingsStoreSP object. You supply this data in the constructor of the CSettingsStoreSP object.

m_pRegistry

The CSettingsStore-derived object that the Create method creates.

Remarks

You can use the CSettingsStoreSP class to redirect all MFC registry operations to other locations, such as an XML file or a database. To do this, follow these steps:

  1. Create a class (such as CMyStore) and derive it from CSettingsStore.

  2. Use DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros with your custom CSettingsStore class to enable dynamic creation.

  3. Override the virtual functions and implement the Read and Write functions in your custom class. Implement any other functionality to read and write data to your desired location.

  4. In your application, call CSettingsStoreSP::SetRuntimeClass and pass in a pointer to the CRuntimeClass Structure obtained from your class.

Whenever the framework would typically access the registry, it will now dynamically instantiate your custom class and use it to read or write data.

CSettingsStoreSP::SetRuntimeClass uses a global static variable. Therefore, only one custom store is available at a time.

Requirements

Header: afxsettingsstore.h

See Also

Reference

Hierarchy Chart

CSettingsStore Class

Other Resources

MFC Classes