Cant save in register
-
Hello!
I have this code:
@ QSettings settings("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
, QSettings::NativeFormat);
qDebug() << settings.status();
settings.setValue("RizekFatser", "123"));@
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run - is exist register path
settings.status() return no error
But program dont write any data in this register path.
I try to use / instead of \ - program also dont work!
Why does it happend? -
Is this mistake in qt or my fault?
-
Its your fault. This should work:
@
QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "Microsoft", "Windows");
settings.beginGroup("CurrentVersion");
settings.beginGroup("run");...
settings.endGroup();
settings.endGroup();
@ -
As far i know, QSettings only allow you to write under your application namespace
@
HKEY_LOCAL_MACHINE\Software\MySoft
@Check he "QSettings documentation":http://qt-project.org/doc/qt-4.8/qsettings.html
-
try QSettings::SystemScope for HKEY_LOCAL_MACHINE
QSettings::UserScope is for HKEY_CURRENT_USER -
Are you sure you have permission to write in that part of the registry, and that windows is not playing clever tricks on you diverting the write call to another location?
-
@QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "Microsoft", "Windows");
settings.beginGroup("CurrentVersion");
settings.beginGroup("run");...
settings.endGroup();
settings.endGroup();@Works fine for HKCU
-
Maybe he should launch the app with admin privileges.
-
[quote author="AcerExtensa" date="1334736682"]Its your fault. This should work:
QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "Microsoft", "Windows");
settings.beginGroup("CurrentVersion");
settings.beginGroup("run");...
settings.endGroup();
settings.endGroup();
[/quote]It is dont work too.
bq. As far i know, QSettings only allow you to write under your application namespace
I think you dont right.
For example there is code from Qt Assistant:
QSettings settings("HKEY_CURRENT_USER\Software\Microsoft\Office",
QSettings::NativeFormat);
Or this: HKEY_LOCAL_MACHINE\Software\MySoft\Starbq. Are you sure you have permission to write in that part of the registry, and that windows is not playing clever tricks on you diverting the write call to another location?
I am administrator of computer and, for example, i can edit this path of registry with standart register editor.
Because i have 64bit Windows, i see WOW6432node too.
-
It is my full code:
@ QSettings settings(QSettings::NativeFormat, QSettings::SystemScope, "Microsoft", "Windows");
settings.beginGroup("CurrentVersion");
settings.beginGroup("run");
settings.setValue("RizekFatser", QDir::toNativeSeparators(QDir::currentPath() + "/RizekFaster.exe"));
settings.endGroup();
settings.endGroup();@
I want to add file in startup.
String QDir::toNativeSeparators(QDir::currentPath() + "/RizekFaster.exe" construct right -
This dont work too:
@ QSettings settings; settings.setValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\RizekFaster", "123");@ -
Please stop replying to yourself. If you're the last poster, and you have something to add, please just edit your previous message instead. There is an edit link next to each of your postings.
-
[quote author="Andre" date="1334744554"]Please stop replying to yourself. If you're the last poster, and you have something to add, please just edit your previous message instead. There is an edit link next to each of your postings. [/quote]
Ok, sorry for many messages.
AcerExtensa i was wrong, your code was worked, but only with HKEY_CURRENT_USER, not MACHINE.
I dont make code to write in HKEY_LOCAL_MACHINE despite the fact that i am admin on my computer.Thank you all for your help!