Link to home
Start Free TrialLog in
Avatar of nitshv
nitshv

asked on

How to Add Desktop shortcut Icon

How do i Add Desktop shortcut Icon to my application?

Secondly, how do i add a program folder and shortcut in the Start Menu?

Thanks.





Avatar of noushadxp
noushadxp



hellow nitshv


        do the following
       


        1 right click the mouse
        2 select new ->shortcut->enter
        3 a window is displayed;enter path in the dis- layed window,if you know,else select brouse and find outthe
file

         4 then just click 'next' then 'finish'.

     prety ! you have created a shortcut
Hi,
If you want to create shortcut not by programming.Follow these steps.
CREATING A SHORTCUT TO A PROGRAM OR FILE

To create a shortcut on the desktop to a program or file, follow these steps:


Right-click an open area on the desktop, point to New, and then click Shortcut.

Click Browse.

Locate the program or file to which you want to create a shortcut, click the program or file, click Open, and then click Next.

Type a name for the shortcut. If a Finish button appears at the bottom of the dialog box, click it. If a Next button appears at the bottom of the dialog box, click it, click the icon you want to use for the shortcut, and then click Finish.

If you want to do it doing MFC programming there is another way.
Thanks
Keshav
Hi
If you want to create shortcut using programming in MFC.There is many article in MSDN. You can refer to IShelllink interface. Or even find "Create Shortcut" in search. You will get information.
SHORTCUT: A SampleThat Manipulates Shortcuts
This article gives one example to show that.
I hope this will help you.
Thanks
keshav
If you use InstallShield (free with VC++) you can easily create start-menu group and desktop icon.  Just ask.

--- Dan
Avatar of nitshv

ASKER

First of all this question is posted in MFC section so obviously i'm not talking abt right cliking and making a shortcut.

Dan, I would like to do all the stuff on my own and not use InstallShield for the installation part.So help...

btw, I'm through with the desktop icon part, I was able to code that. I need to know how to add the start menu group?

thanks.

Well, if you did the desktop part, then doing the start menu part is just as easy.
It's just another folder in the system.

You can use:

HRESULT SHGetFolderPath(HWND hwndOwner,
                        int nFolder,
                        HANDLE hToken,
                        DWORD dwFlags,
                        LPTSTR pszPath);

where:
nFolder = CSIDL_STARTMENU

Oren
Avatar of nitshv

ASKER

but How do i add a new folder in the start menu?
> but How do i add a new folder in the start menu?

use mkdir (make directory) or CreateDirectory(Ex)- the start menu is nothing more than the directory structure converted into a menu
Putting something in the StartMenu folder itself is not 2 kuel.  You should put a folder in the "Program Files" directory.  Its CSIDL value is:

   CSIDL_PROGRAMS
typically C:\Documents and Settings\<username>\Start Menu\Programs.
or C:\Windows\Start Menu\Programs
-- or --
  CSIDL_COMMON_PROGRAMS
typically C:\Documents and Settings\All Users\Start Menu\Programs

-- Dan
try this:


     CString strPathObj;
     CString strPathLink;
     IPersistFile* ppf;
     
     strPathObj = "c:\yourexefile.exe";
     LPITEMIDLIST plist;
     CString str;
     char pszPath[MAX_PATH];
     SHGetSpecialFolderLocation(NULL, CSIDL_PROGRAMS , &plist);
     SHGetPathFromIDList(
          plist,
          pszPath);
     
     IShellLink *psl;
     strPathLink = pszPath;
     strPathLink += "\\";
     strPathLink += "The name you want to appear";
     strPathLink += ".lnk";
     CoInitialize(NULL);
     if (SUCCEEDED( CoCreateInstance(CLSID_ShellLink,
          NULL,
          CLSCTX_INPROC_SERVER,
          IID_IShellLink,
          (LPVOID*) &psl))
          )
         
          //IPersistFile* ppf;
         
     psl->SetPath(strPathObj);
     psl->SetIconLocation("c:\\youricofile.ico", 0);
     psl->SetDescription("Description");
     if (SUCCEEDED(psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf)))
     {
         
          WORD wsz[MAX_PATH];
          MultiByteToWideChar(CP_ACP,
               MB_PRECOMPOSED,
               strPathLink,
               -1,
               wsz,
               MAX_PATH);
         
          if ( SUCCEEDED ( ppf->Save(wsz, TRUE) ) )
               blnError = FALSE;
         
          ppf->Release();
     }
     psl->Release();

hope helps..
Avatar of nitshv

ASKER

Are these functions SHGetSpecialFolderPathA, etc compatible in Windows NT also ?
ASKER CERTIFIED SOLUTION
Avatar of aponcealbuerne
aponcealbuerne

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: aponcealbuerne

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer