RegistryHelper::saveToFile
void RegistryHelper::saveToFile(wstring key, vector<wstring> valuenames, wstring filepath)
{
wofstream stream(filepath);
if (!stream.good())
throw RegistryException(L"Error while opening file " + filepath + L" for writing");
stream << L"Windows Registry Editor Version 5.00\n" << endl;
stream << L"[HKEY_LOCAL_MACHINE\\" << key << L"]" << endl;
for (vector<wstring>::iterator it = valuenames.begin(); it != valuenames.end(); it++)
{
wstring& valuename = *it;
wstring value = readValue(key, valuename);
stream << L"\"" << valuename << L"\"=\"" << value << L"\"" << endl;
}
stream << endl;
stream.close();
}
随手分享,手有余香