5,696,038 members and growing! (14,545 online)
Email Password   helpLost your password?
Desktop Development » Shell and IE programming » General     Advanced

Creating Internet Explorer style desktop shortcut.

By Parasuraman SundarRajan

Describes in detail how to create a desktop item with customized menu and icon.
VC6, C++Windows, NT4, Win2K, Visual Studio, MFC, Dev

Posted: 23 Jan 2001
Updated: 5 Sep 2001
Views: 99,504
Bookmarked: 22 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
19 votes for this Article.
Popularity: 4.48 Rating: 3.50 out of 5
2 votes, 33.3%
1
1 vote, 16.7%
2
0 votes, 0.0%
3
1 vote, 16.7%
4
2 votes, 33.3%
5

Introduction

Whenever we want to create shortcuts for our programs on the desktop, what we do normally is, we create .lnk files for our programs using IShellLink. When we create it in such a way, what we get is an icon on the desktop with an arrow on its bottom left corner, and if you right click it, you'll get the normal menu, with the cut, copy, paste, delete etc. items. But if you see the Internet Explorer's shortcut icon on the desktop, it's a normal icon without the arrow on its corner and with a different menu also. (If you see Microsoft's Connection Manager, you'll see the difference more than Internet Explorer). Now lets see how to create such a shortcut on the desktop with your own customized menu items.

When you execute this code, you'll get an icon on the desktop with 'Netlinker'; as its shortcut name. If you double click it, it'll open the Internet Explorer and if you right click, you can see a customized menu with no cut, copy, paste, rename items. You also cannot delete this shortcut from the desktop. If you select the properties for this icon, it'll open the Internet Properties dialog box.

Implementing

Choose a 32x32 icon and specify its path:

CString shtct_ico=_T("C:\\32x32.ico");

This is to show the Internet Explorer properties dialog box.

CString shtct_prop=_T("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,0");

This is the shortcut name to be displayed on the desktop

CString shtct_name=_T("Netlinker");

Catch the path of the Internet Explorer and store it:

CRegKey m_Kiepath;
CString ie_path;
DWORD dwval;
m_Kiepath.Open(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppPaths\\IEXPLORE.EXE");
m_Kiepath.QueryValue(ie_path.GetBuffer(1000),NULL,&dwval);
m_Kiepath.Close();
String shtct_to=ie_path;

Create a GUID using guidgen.exe and copy it to the clipboard and paste it here. This is the GUID that we are going to use for the representation of our shortcut and its menu items. Here, the GUID that we have generated is 6270AEE4-AA41-11d4-A25D-008048B63F94.

Create this GUID key under the HKCR\CLSID and set the shortcut name as its value:

CRegKey m_kdsktp;
m_kdsktp.Create(HKEY_CLASSES_ROOT,"CLSID\\{6270AEE4-AA41-11d4-A25D-008048B63F94}");
m_kdsktp.SetValue(shtct_name);
m_kdsktp.Close();

Under this GUID, create the DefaultIcon key, which represents the icon for the shortcut, so set its value with the path of the icon:

m_kdsktp.Create(HKEY_CLASSES_ROOT,"CLSID\\{6270AEE4-AA41-11d4-A25D-008048B63F94}\\DefaultIcon");
m_kdsktp.SetValue(shtct_ico);
m_kdsktp.Close();

Now set the menu items for the right click menu. Here is the Open menu item, and its executable is set:

m_kdsktp.Create(HKEY_CLASSES_ROOT,
                     "CLSID\\{6270AEE4-AA41-11d4-A25D-008048B63F94}\\Shell\\Open\\Command");
m_kdsktp.SetValue(shtct_to);
m_kdsktp.Close();

Set the properties menu item and its executable:

m_kdsktp.Create(HKEY_CLASSES_ROOT,"CLSID\\{6270AEE4-AA41-11d4-A25D-008048B63F94}\\Shell\\Properties\\Command");
m_kdsktp.SetValue(shtct_prop);
m_kdsktp.Close();

Now set the attributes of the menu so that the default menu items such as cut, copy, paste, rename, delete etc are removed.

BYTE *b;
HANDLE heap;
char a[20];
m_kdsktp.Create(HKEY_CLASSES_ROOT,"CLSID\\{6270AEE4-AA41-11d4-A25D-008048B63F94}\\ShellFolder");
strcpy(a,"00.00.00.00");
heap=HeapCreate(0,0,0);
b=(BYTE*)HeapAlloc(heap,0,30);
scanf(a,"%x.%x.%x.%x",&b[0],&b[1],&b[2],&b[3]);19/08/2001
RegSetValueEx(m_kdsktp.m_hKey,"Attributes",0,REG_BINARY,b,4);
HeapFree(heap,0,b);
HeapDestroy(heap);
m_kdsktp.Close();

Now we have to create a reference for this GUID under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\Namespace. Then only it'll appear on the desktop.

m_kdsktp.Create(HKEY_LOCAL_MACHINE,
     "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\{6270AEE4-AA41-11d4-A25D-008048B63F94}");
m_kdsktp.SetValue("Netlink");
m_kdsktp.Close();

Since we've played with the shell, we must notify it. Then only the changes will reflect immediately.

SHChangeNotify(SHCNE_ASSOCCHANGED,SHCNF_FLUSHNOWAIT,0, 0);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Parasuraman SundarRajan


Sundar is having 6 years of experience in VC++. and .NET for 2+ year. Has developed the Internet Dialer for Asia's No.1 leading ISP. Involved in developing Video Surveillance components for worlds leading Security Surveillance Software Company. Worked and working on various domains such as Internet Networking, Video Codecs, CCTV Surveillance Software, Video Portals, Windows Mobile, PDAs etc. Also working on various projects which involves RAS, TCP/IP, FTP, COM, XML, .NET, Remoting, Embedded programming.
Occupation: Web Developer
Location: India India

Other popular Shell and IE programming articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 18 of 18 (Total in Forum: 18) (Refresh)FirstPrevNext
GeneralDRAG n DROPmemberjay_dubal4:30 23 Aug '07  
Questioni can get the sourcememberkcselvaraj20:28 27 Nov '06  
GeneralThanks. Helpful InformationmemberGautam Jain21:50 13 Jul '05  
GeneralAdd Shell menu in List view!memberR.selvam13:46 24 Dec '03  
Generalhow to have popu for a shellfolder objectmemberKevin12:19 13 Feb '01  
GeneralRe: how to have popu for a shellfolder objectmemberedgar8:59 20 Aug '01  
GeneralDrag and drop not working ?memberAnonymous4:19 30 Jan '01  
GeneralRe: Drag and drop not working ?!!!!!memberSundarRajan5:21 30 Jan '01  
GeneralRe: Drag and drop not working ?!!!!!memberAnonymous6:31 31 Jan '01  
GeneralRe: Drag and drop not working ?!!!!!memberedgar7:49 20 Aug '01  
QuestionRe: Drag and drop not working ?!!!!!memberjay_dubal4:26 23 Aug '07  
GeneralWhat's the point of a private heap in this context?memberAnonymous19:58 24 Jan '01  
GeneralOr you could do it in a .reg filememberSimon Capewell0:21 24 Jan '01  
Generalwhy was used this?memberreal name23:36 23 Jan '01  
GeneralRe: why was used this?memberParsuraman SundarRajan1:19 24 Jan '01  
GeneralRe: why was used this?memberreal name2:09 24 Jan '01  
GeneralRe: why was used this?memberSimon Capewell2:31 24 Jan '01  
GeneralNice article, but...memberThomas Freudenberg22:10 23 Jan '01  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 5 Sep 2001
Editor: Chris Maunder
Copyright 2001 by Parasuraman SundarRajan
Everything else Copyright © CodeProject, 1999-2008
Web12 | Advertise on the Code Project