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. How to Add Start menu shortcut in Setup program

How to Add Start menu shortcut in Setup program

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxhelptutorialquestion
4 Posts 2 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.
  • A Offline
    A Offline
    a3gupta
    wrote on last edited by
    #1

    Hello, I am using Installshield for VC++ 6.0 to build a setup program for my program. I was wondering how can I add a shortcut in the startmenu for my programs exe file in the start menu. Right now .. I am using the follwing code to make the icon in the startmenu svPath = TARGETDIR ^ "TDMS2000.exe"; LongPathToQuote ( svPath , TRUE ); AddFolderIcon (FOLDER_PROGRAMS^SHELL_OBJECT_FOLDER , "TDMS2000" , svPath , "" , "" , 0 , "" , REPLACE ); But there is a problem with this code. My program needs a .dat file to start that resides in the same directory as the exe file. So when I follow the link created in my start meny using the code above .. the program fails to see that .dat file. When I create a shortcut manually and place it in the start menu .. the program works file. I will really appreciate any solution to this problem. Thanks! Sincerely, Anjum.

    S 1 Reply Last reply
    0
    • A a3gupta

      Hello, I am using Installshield for VC++ 6.0 to build a setup program for my program. I was wondering how can I add a shortcut in the startmenu for my programs exe file in the start menu. Right now .. I am using the follwing code to make the icon in the startmenu svPath = TARGETDIR ^ "TDMS2000.exe"; LongPathToQuote ( svPath , TRUE ); AddFolderIcon (FOLDER_PROGRAMS^SHELL_OBJECT_FOLDER , "TDMS2000" , svPath , "" , "" , 0 , "" , REPLACE ); But there is a problem with this code. My program needs a .dat file to start that resides in the same directory as the exe file. So when I follow the link created in my start meny using the code above .. the program fails to see that .dat file. When I create a shortcut manually and place it in the start menu .. the program works file. I will really appreciate any solution to this problem. Thanks! Sincerely, Anjum.

      S Offline
      S Offline
      super
      wrote on last edited by
      #2

      I think the problem is not with the insatalshield but in ur application code.. Ur reading for sat file may be wrong..(i.e)The path u have given for reading the .dat file is relative with ur exe....So the application is searching is the oath where start menu short cut resides.... U have to explictily give the full path of ur exe dor reading the .dat file.. If u can give the code for reading of .dat file and i can clearly analaysis the problem :-D cheers, Super ------------------------------------------ Too much of good is bad,mix some evil in it

      A 1 Reply Last reply
      0
      • S super

        I think the problem is not with the insatalshield but in ur application code.. Ur reading for sat file may be wrong..(i.e)The path u have given for reading the .dat file is relative with ur exe....So the application is searching is the oath where start menu short cut resides.... U have to explictily give the full path of ur exe dor reading the .dat file.. If u can give the code for reading of .dat file and i can clearly analaysis the problem :-D cheers, Super ------------------------------------------ Too much of good is bad,mix some evil in it

        A Offline
        A Offline
        a3gupta
        wrote on last edited by
        #3

        Mani, Thanks for your response. Yes, I am using a relative path, but I was doing it thinking that since the user may choose to install the my program under any folder, I should give a relative so that it will be able to open the my .dat file as long as they are together in one folder regardless of the folder chosen by the user during installation. When I manually create a short cut of my EXE file and put it on the desktop or in the start menu .. it reads the .dat file fine. I was thinking that an icon created by the setup program should work the same way. I am attaching my code. Thanks for looking into it. //open config file to read institute name information; char *pszFileName="config.dat"; char pszIName[256]; CFile myFile; CFileException fileException; if ( !myFile.Open( pszFileName, CFile::modeRead, &fileException )) { ::MessageBox(NULL, "File doesnt exist ","Warning",MB_OK); } Also I have a trivial question. Why do I have to put :: before Messagebox function sometimes to make it work. Sometimes it is works without the dots. As you can probably see that I do lack some of basic knowledge of MFC. :-) Thanks for your help! Sincerely, Anjum.

        S 1 Reply Last reply
        0
        • A a3gupta

          Mani, Thanks for your response. Yes, I am using a relative path, but I was doing it thinking that since the user may choose to install the my program under any folder, I should give a relative so that it will be able to open the my .dat file as long as they are together in one folder regardless of the folder chosen by the user during installation. When I manually create a short cut of my EXE file and put it on the desktop or in the start menu .. it reads the .dat file fine. I was thinking that an icon created by the setup program should work the same way. I am attaching my code. Thanks for looking into it. //open config file to read institute name information; char *pszFileName="config.dat"; char pszIName[256]; CFile myFile; CFileException fileException; if ( !myFile.Open( pszFileName, CFile::modeRead, &fileException )) { ::MessageBox(NULL, "File doesnt exist ","Warning",MB_OK); } Also I have a trivial question. Why do I have to put :: before Messagebox function sometimes to make it work. Sometimes it is works without the dots. As you can probably see that I do lack some of basic knowledge of MFC. :-) Thanks for your help! Sincerely, Anjum.

          S Offline
          S Offline
          super
          wrote on last edited by
          #4

          Yeah thats the problem....... U should nver give the relative path..I will not work...In this code when u run with start menu it will search the folder of startmenu and never the exe..So its better u use Absolute path of exe... So use this piece of code.. CString StrLaunched; TCHAR szFullPath[MAX_PATH]; TCHAR szDir[_MAX_DIR]; TCHAR szDrive[_MAX_DRIVE]; ::GetModuleFileName(NULL,szFullPath,MAX_PATH); _splitpath(szFullPath, szDrive, szDir, NULL, NULL); StrLaunched.Format(_T("%s%s"), szDrive, szDir); char *pszFileName=StrLaunched+"config.dat"; This will work..... Then :: means ur calling an Windows Sdk function :-D cheers, Super ------------------------------------------ Too much of good is bad,mix some evil in it

          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