Results 1 to 3 of 3

Thread: Qt app LNK: Icon in taskbar is the LNK icon, not app icon

  1. #1
    Join Date
    Apr 2013
    Posts
    61
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt app LNK: Icon in taskbar is the LNK icon, not app icon

    Hi,

    I have a Qt app and I need to save in runtime a LNK to my .exe file in user desktop
    The LNK icon must be a pixmap I have in runtime, different from my .EXE icon
    When I use that LNK (there can be more than one with different icons), my app is launched but the icon in taskbar is the LNK icon, not my app icon

    How can I solve that?

    I am creating a link with this snipped code:

    Qt Code:
    1. QString sPathTarget = [MY_EXE_PATH];
    2. QString sLinkName = "link name";
    3. QString sLinkArguments = "link arguments";
    4. QString sLinkIcon = [MY_ICON_PATH]; // This icon will be the LNK icon, but also the icon my app has in the taskbar when launched from the LNK
    5.  
    6. WCHAR pathDesktop[MAX_PATH];
    7. HRESULT result = SHGetFolderPathW(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, pathDesktop);
    8.  
    9. if (SUCCEEDED(result)) {
    10. QString linkPath = QDir(QString::fromWCharArray(pathDesktop)).absoluteFilePath(QString("%1.lnk").arg(sLinkName));
    11.  
    12. CoInitialize(NULL);
    13. IShellLinkW* shellLink = NULL;
    14. result = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_ALL, IID_IShellLinkW, (void**)&shellLink);
    15. if (SUCCEEDED(result)) {
    16. shellLink->SetPath(sPathTarget.toStdWString().c_str());
    17. shellLink->SetArguments(sLinkArguments.toStdWString().c_str());
    18. shellLink->SetIconLocation(sLinkIcon.toStdWString().c_str(), 0);
    19. IPersistFile* persistFile;
    20. result = shellLink->QueryInterface(IID_IPersistFile, (void**)&persistFile);
    21.  
    22. if (SUCCEEDED(result)) {
    23. result = persistFile->Save(linkPath.toStdWString().c_str(), TRUE);
    24.  
    25. persistFile->Release();
    26.  
    27. bRet = true;
    28. }
    29. shellLink->Release();
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 
    Thanks,
    Diego

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,836
    Thanks
    269
    Thanked 785 Times in 775 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt app LNK: Icon in taskbar is the LNK icon, not app icon

    These are Windows questions, not Qt questions. You need to find a Windows forum to post them. Please do not post non-Qt questions here.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Apr 2013
    Posts
    61
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt app LNK: Icon in taskbar is the LNK icon, not app icon

    Quote Originally Posted by d_stranz View Post
    These are Windows questions, not Qt questions. You need to find a Windows forum to post them. Please do not post non-Qt questions here.
    Sorry, I thought something I am doing in the Qt app was the cause...

Similar Threads

  1. Different Icon for each widget in taskbar
    By Ini in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2016, 09:31
  2. Propper dimension for a taskbar icon.
    By robgeek in forum Newbie
    Replies: 1
    Last Post: 11th February 2016, 21:38
  3. Replies: 1
    Last Post: 3rd January 2016, 23:35
  4. Creating a list with icon and text in the center of icon
    By prophet0 in forum Qt Programming
    Replies: 2
    Last Post: 15th December 2011, 04:03
  5. Couple of questions: main window icon + toolbar icon
    By bpackard in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2008, 20:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.