Create a shortcut in the desktop (no left)

zhaozj2021-02-08  223

Create a shortcut to the desktop

This Article WAS Contributed by Sundar & Naresh

We want to build a shortcut on the desktop, we usually use the iShellLink interface to generate a .lnk file. Create in this way, we get on the desktop, one of the left side, also contains a small arrow, right-click it, you will see the normal pop-up menu (with copy, paste, etc.). But you see the shortcut on the desktop, you will see it is a normal icon (no small arrow), and the pop-up menu is also different. Let's build a shortcut to this style.

Execute this code, you will get a icon called "NetLinker" on the desktop, right-click it, you will see a custom menu (no cut, copy, paste, rename and other menu). You can't even delete it from the desktop, if you choose Properties, it will open the IE's Properties dialog

Choose an icon file CString Shtct_ico = _t ("C: //32x32.ico");

Displays the IE property dialog. CSTRING SHTCT_PROP = _T ("Rundll32.exe shell32.dll, control_rundll inetcpl.cpl, 0");

The name of the shortcut cstring shtct_name = _t ("NetLinker");

Find the path to IE and save it. CREGKEY M_KIEPATH;

CSTRING IE_PATH;

DWORD DWVAL;

M_kiepath.open (HKEY_LOCAL_MACHINE, "Software // Microsoft // Windows //" "currentversion // app paths // ipplore.exe");

M_kiepath.QueryValue (IE_Path.getBuffer ;;;;;;;;;;;;;;;;;;

m_kiepath.close ();

CSTRING SHTCT_TO = IE_PATH;

Create a GUID with Guidgen.exe and copy it here. This is used to express our shortcuts and its menu items. The GUID created with Guidgen.ext is 6270AEE4-AA41-11D4-A25D-008048B63F94. The following program creates this GUID key in HKCR / CLSID and sets the value of the shortcut to it.

CREGKEY M_KDSKTP;

m_kdsktp.create (HKEY_CLASS_ROOT, "CLSID / / {6270AEE4-AA41-11D4-A25D-" 008048B63F94} ");

m_kdsktp.setValue (SHTCT_NAME);

m_kdsktp.close ();

Create a Defaulton button under this GUID, which is the path to express the icon of the shortcut to the corresponding icon file.

M_kdsktp.create (HKEY_CLASS_ROOT, "CLSID / / {6270AEE4-AA41-11D4-A25D" "-008048B63F94} // default");

m_kdsktp.setValue (SHTCT_ICO);

m_kdsktp.close ();

Set the menu item right-click menu.

Set open menu items

M_kdsktp.create (HKEY_CLASES_ROOT, "CLSID / / {6270AEE4-AA41-11D4-A25D-" 008048B63F94} // shell // open // command "); m_kdsktp.setValue (SHTCT_TO);

m_kdsktp.close ();

Set the properties menu item. M_kdsktp.create (HKEY_CLASS_ROOT, "CLSID / / {6270AEE4-AA41-11D4-A25D-" 008048B63F94} // shell // "// command");

m_kdsktp.setValue (SHTCT_PROP);

m_kdsktp.close ();

Remove the original default menu item (such as copy paste, etc.).

BYTE * B;

Handle HEAP;

Char a [20];

M_kdsktp.create (HKEY_CLASES_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);

SSCANF (A, "% x.% x.% x.% x", & b [0], & b [1], & b [2], & b [3]);

RegSetValueex (m_kdsktp.m_hkey, "attributes", 0, reg_binary, b, 4);

HeapFree (HEAP, 0, B);

Heapdestroy (HEAP);

m_kdsktp.close ();

Next we add a reference to HKLM / Software / Microsoft / Windows / CurrentVersion / Explorer / Desktop / Namespace, which will only be displayed on the desktop.

M_kdsktp.create (HKEY_LOCAL_MACHINE, "Software // Microsoft // Windows //" "CurrentVersion // Explorer // Desktop //" "Namespace //////" "" Namespace ////// "" "Namespace //////" "" "" "

M_kdsktp.setValue ("NetLink");

m_kdsktp.close ();

We made the shell and we want to inform the system. This change will immediately appear.

Shchangenotify (shcne_assocchanged, shcnf_flushnowait, 0, 0);

转载请注明原文地址:https://www.9cbs.com/read-2579.html

New Post(0)