How to put an icon on file extensions of a Qt program on Windows Explorer
Hello,
Here is the program. On the Web I found:
Code:
QSettings reg
("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
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?
Re: How to put an icon on file extensions of a Qt program on Windows Explorer
Quote:
Originally Posted by
franky
Hello,
Here is the program. On the Web I found:
Code:
QSettings reg
("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\.sp\\DefaultIcon",
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.
Re: How to put an icon on file extensions of a Qt program on Windows Explorer
Do you have a book on that to suggest?
Re: How to put an icon on file extensions of a Qt program on Windows Explorer
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
Re: How to put an icon on file extensions of a Qt program on Windows Explorer
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.