|
// test.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "rsettings.h"
// Sample application configuration item
class CMySettingsItem : public CRegSettings
{
public:
DWORD Id;
CString Name;
BEGIN_REG_MAP(CMySettingsItem)
REG_ITEM(Id, 1)
REG_ITEM(Name, "Default Name Value")
END_REG_MAP()
};
// Sample application configuration
class CMySettings : public CRegSettings
{
public:
DWORD RootId; // DWORD option
CString RootName; // String option
std::string FullName;
// list of options (CMySettingsItem)
CSimpleArray<CMySettingsItem> MyItems; // ATL CSimpleArray
std::vector<CMySettingsItem> MyItems2; // STL vector
std::list<CMySettingsItem> MyItems3; // STL list
CMySettingsItem SubItem; // Subitem test
BEGIN_REG_MAP(CMySettings)
REG_ITEM(RootId, 1)
REG_ITEM(RootName, "Default Root Name")
REG_ITEM_STL(FullName, "Full Name")
REG_ITEM_SIMPLE_ARRAY(MyItems)
REG_ITEM_VECTOR(MyItems2)
REG_ITEM_LIST(MyItems3)
REG_ITEM_SUBKEY(SubItem)
END_REG_MAP()
};
int _tmain(int argc, _TCHAR* argv[])
{
CMySettings configuration(HKEY_CURRENT_USER, "Software\\RegSetings Test\\test\\%i.%i", 1, 0);
// Load configuration
if(configuration.Load() != ERROR_SUCCESS)
printf("failed to load\n");
// Use loaded configuration
configuration.RootId++;
CMySettingsItem item;
item.Id = configuration.RootId;
configuration.MyItems.Add(item); // CSimpleArray
configuration.MyItems2.push_back(item); // vector
configuration.MyItems3.push_back(item); // list
// Save new configuration
if(configuration.Save() != ERROR_SUCCESS)
printf("failed to save\n");
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.