Qt写注册表

Qt写注册表

通过写入注册表,使“.dcj”文件可关联使用默认工具“Converter.exe”打开。

QString strPath = QDir::currentPath();
strPath.replace("/", "\\");
QSettings* settings = new QSettings("HKEY_CLASSES_ROOT\\Converter.dcj\\shell\\open\\command", QSettings::NativeFormat);
settings->setValue("Default", strPath + "\\Converter.exe " + "%1");

if(settings)
{
    settings->deleteLater();
    settings = nullptr;
}

settings = new QSettings("HKEY_CLASSES_ROOT\\.dcj", QSettings::NativeFormat);
settings->setValue("Default", "Converter.dcj");

if(settings)
{
    settings->deleteLater();
    settings = nullptr;
}

你可能感兴趣的:(Qt写注册表)