PDA

View Full Version : change txt file type default icon



mismael85
20th February 2008, 15:21
hello everybody,
i want to change the default icon of the txt file type on windows this can done if we chabged the following registry Key using QSettings
HKEY_CLASSES_ROOT\txtfile\DefaultIcon\Default value
and set it's value to the path of my program.
how can i do that ???
thank you.

jpn
20th February 2008, 15:56
But what's the problem? You know the registry path and you know QSettings. If you don't know how to use QSettings, go read its great docs full of examples:
http://doc.trolltech.com/latest/qsettings.html#accessing-the-windows-registry-directly.

mismael85
20th February 2008, 18:53
i just did as described in the documentation.
it is said in the documentation that windows keys can have default value and to change it just refer to the key as follows

settings.setValue("HKEY_CLASSES_ROOT\\txtfile\\DefaultIcon", "D:\\Work space\\MY Projects\\executable\\MyEditor.exe");

when i did that nothing happens.
where is the wrong?

jpn
20th February 2008, 19:00
What does mean "nothing happens"? Did you check the value with Regedit? Shoudn't "DefaultIcon" refer to an icon file?

bender86
20th February 2008, 19:24
Try with
settings.setValue("HKEY_CLASSES_ROOT\\txtfile\\DefaultIcon", "\"D:\\Work space\\MY Projects\\executable\\MyEditor.exe,0\"");

mismael85
20th February 2008, 21:41
i tried but nothing happens the defaultIcon Key is still as it was . it was
%SystemRoot%\system32\shell32.dll,-152
and it is still.
note that i tried settings.contains() to be sure that the Key is exist and be shown by
my program and it returns true which means that the program see the Key but can not
change it i dont know why!!!

mismael85
20th February 2008, 21:44
What does mean "nothing happens"?
i mean that the key did not changed.

Did you check the value with Regedit?
yes, i checked it . it is still as it was.

bender86
20th February 2008, 22:52
How did you create QSettings object? It should be done this way:

QSettings settings("HKEY_CLASSES_ROOT\\txtfile",QSettings::NativeFormat);
// Then edit subkeys.
settings.setValue("DefaultIcon", "\"D:\\Work space\\MY Projects\\executable\\MyEditor.exe,0\"");

mismael85
20th February 2008, 23:22
when i did that a new key called DefaultIcon is added in the Path
HKEY_CLASSES_ROOT\\txtfile
with the value
"D:\Work space\MY Projects\executable\MyEditor.exe,0"
note the double quotation.
and thank you for your co-operation.