How to create a file shortcut programatically under windows?
-
wrote on 13 Jul 2015, 19:51 last edited by xalam
I want to create my applications's shortcut programatically in start menu >> startup group. I also need to be deleted it based on the option in application if user doesn't want auto start feature. I see QFile::link() but could this do the job? I don't know how to use it.
If that is not possible, is the any other way I enable auto-start my application when windows boots up?
-
Hi,
AFAIK, link is the right choice, note the requirement for Windows.
Create a QFile for the file you want to link to, then call link and pass it the link name. The name can be the full path to were you want to have that link.
-
@SGaist do you happen to know if it is possible to add command line arguments to the .lnk ?
If not, I guess it's better to use some OS specific code.
wrote on 12 Feb 2022, 06:43 last edited by@Megamouse
I would think that is not possible from a Qt call. @SGaist'sQFile::link(const QString &linkName)
is all there is from Qt, and that does not accept extra arguments. Plus Qt and that call is cross-platform, and UNIX soft links don't have any such arguments. So I would think you need to drop down to a Windows-specific call.