Solved

How to Add Desktop shortcut Icon

Posted on 2001-08-08
14
591 Views
Last Modified: 2013-11-20
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.





0
Comment
Question by:nitshv
  • 3
  • 2
  • 2
  • +6
14 Comments
 

Expert Comment

by:noushadxp
ID: 6366872


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
0
 
LVL 1

Expert Comment

by:kkarunakar
ID: 6366927
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
0
 
LVL 1

Expert Comment

by:kkarunakar
ID: 6366933
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
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 31

Expert Comment

by:Zoppo
ID: 6367046
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6367116
If you use InstallShield (free with VC++) you can easily create start-menu group and desktop icon.  Just ask.

--- Dan
0
 

Author Comment

by:nitshv
ID: 6367393
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.

0
 

Expert Comment

by:orenlev
ID: 6370276
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
0
 

Author Comment

by:nitshv
ID: 6373298
but How do i add a new folder in the start menu?
0
 
LVL 9

Expert Comment

by:ShaunWilde
ID: 6376170
> 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
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6376537
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
0
 
LVL 4

Expert Comment

by:aponcealbuerne
ID: 6385581
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..
0
 

Author Comment

by:nitshv
ID: 6407870
Are these functions SHGetSpecialFolderPathA, etc compatible in Windows NT also ?
0
 
LVL 4

Accepted Solution

by:
aponcealbuerne earned 300 total points
ID: 6407992
Yes, they are, i think you'll need the following includes:


#include "windows.h"
#include "windef.h"
#include "lmcons.h"
#include "lmapibuf.h"
#include "lmshare.h"
#include "lmerr.h"
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9521162
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
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 135
ODBC Connection Logging, ADO.NET 6 64
MaxSpan challenge 9 95
fix34  challenge 9 117
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question