Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Creating shortcuts

Creating shortcuts

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vini Deep
    wrote on last edited by
    #1

    Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini

    2 M 2 Replies Last reply
    0
    • V Vini Deep

      Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini

      2 Offline
      2 Offline
      224917
      wrote on last edited by
      #2

      http://www.codeproject.com/shell/create\_shortcut.asp


      greatest thing is to do wot others think you cant
      suhredayan@omniquad.com

      messenger :suhredayan@hotmail.com

      1 Reply Last reply
      0
      • V Vini Deep

        Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini

        M Offline
        M Offline
        Milton Karimbekallil
        wrote on last edited by
        #3

        hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly. CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize(); rgds... mil10.

        V S 2 Replies Last reply
        0
        • M Milton Karimbekallil

          hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly. CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize(); rgds... mil10.

          V Offline
          V Offline
          Vini Deep
          wrote on last edited by
          #4

          Got it... Thanks so much. :):rose: Vini

          1 Reply Last reply
          0
          • M Milton Karimbekallil

            hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly. CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize(); rgds... mil10.

            S Offline
            S Offline
            sysop HAL9K com
            wrote on last edited by
            #5

            What are the #include's needed for this code? I'm compiling for Win32 and I haven't been able to figure out the right combination of files thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups