Logo Search packages:      
Sourcecode: inkscape version File versions

bool RegistryTool::setStringValue ( const Glib::ustring &  keyNameArg,
const Glib::ustring &  valueName,
const Glib::ustring &  value 
)

Set the string value of a key/name registry entry

Definition at line 57 of file registrytool.cpp.

References KeyTableEntry::key.

Referenced by setPathInfo().

{
    Glib::ustring keyName = keyNameArg;

    HKEY rootKey = HKEY_LOCAL_MACHINE; //default root
    //Trim out the root key if necessary
    for (KeyTableEntry *entry = keyTable; entry->key; entry++)
        {
        if (keyName.compare(0, entry->strlen, entry->str)==0)
            {
            rootKey = entry->key;
            keyName = keyName.substr(entry->strlen);
            }
        }
    //printf("trimmed string: '%s'\n", keyName.c_str());

    //Get or create the key
    HKEY key;
    if (RegCreateKeyEx(rootKey, keyName.c_str(),
                       0, NULL, REG_OPTION_NON_VOLATILE,
                       KEY_WRITE, NULL, &key, NULL))
       {
       fprintf(stderr, "RegistryTool: Could not create the registry key '%s'\n", keyName.c_str());
       return false;
       }

    //Set the value
    if (RegSetValueEx(key, valueName.c_str(),
          0,  REG_SZ, (LPBYTE) value.c_str(), (DWORD) value.size()))
       {
       fprintf(stderr, "RegistryTool: Could not set the value '%s'\n", value.c_str());
       RegCloseKey(key);
       return false;
       }


    RegCloseKey(key);

    return true;
}


Generated by  Doxygen 1.6.0   Back to index