PDA

View Full Version : How to put an icon on file extensions of a Qt program on Windows Explorer



franky
18th September 2017, 17:40
Hello,

Here (https://www.dropbox.com/s/ebv4qvol49rrqd3/SP.rar?dl=0) is the program. On the Web I found:


QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\Defaul tIcon",
QSettings::NativeFormat);
reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
"\\packages\\com.vendor.product\\data\\Spreadsheet. ico");

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);

I put this in void MainWindow::writeSettings() and void MainWindow::readSettings() in the code. And then created an installer using Qt Installer Framework and installed it on Windows.
No icon!
Any idea?

GeneCode
19th September 2017, 01:01
Hello,

Here (https://www.dropbox.com/s/ebv4qvol49rrqd3/SP.rar?dl=0) is the program. On the Web I found:


QSettings reg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\Defaul tIcon",
QSettings::NativeFormat);
reg.setValue("Default", "C:\\Users\\Tomy\\Desktop\\package_directory"
"\\packages\\com.vendor.product\\data\\Spreadsheet. ico");

SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);

I put this in void MainWindow::writeSettings() and void MainWindow::readSettings() in the code. And then created an installer using Qt Installer Framework and installed it on Windows.
No icon!
Any idea?

Just find a book and learn it.

franky
19th September 2017, 21:10
Do you have a book on that to suggest?

Ginsengelf
20th September 2017, 07:24
Hi, there are multiple possible errors:
- the code never got executed
- the path is incorrect (e.g. the fix user name)
- the icon file Spreadsheet.ico does not exist

Can you see in regedit that the value got changed?

Ginsengelf

d_stranz
20th September 2017, 17:14
On current Windows platforms (Windows 7+) ordinary users are generally not permitted to write to HKEY_LOCAL_MACHINE except with elevated permissions (such as occurs at program install time or when running as administrator).

Even if you have permission, I am not sure if QSettings will create the registry path if it does not already exist. If it does, then see Ginsengelf's comments too.