使用IShellLink 创建快捷方式

Windows 7程序开发系列之二(JumpList篇1 - User Task)       相对于上一篇中任务栏特性的开发,JumpList的开发显得稍微麻烦一些。JumpList将分为两次讲解,这次先讲解如何添加用户任务(User Task)。同样以foobar2000为例,当右键点击任务栏按钮时,显示程序的JumpList。       最下方3个项目为系统任务,一般不需要我们去操作。上方的两个任务:播放、参数选项,即为自定义的用户任务。用 阅读详情

用IShellLink解析快捷方式(ShortCut)

前几天要写一个解析快捷方式的程序,发现MSDN上有篇文章,转了过来 

本想翻译一下的,想想英语比较弱,作罢。

Using Shell Links in Windows 95

Nancy Winnick Cluts
Microsoft Developer Network Technology Group

October 1994
Revised: June 1995 (Added "Using MFC" section; added information about per-user profiles; changed second parameter of IPersistFile::Savemethod from STGM_READ to TRUE)
Revised: July 1996 (Updated section covering creation of shortcuts to support per-user profiles)
Revised: October 1996 (Updated the sample application and its build information)

 

Abstract

The next version of the Microsoft® Windows® operating system, Windows 95, has a new shell and a way to create shell links (also known as shortcuts) to items or objects in the shell. Shell links provide an easy method for users to access and manipulate objects regardless of the location and name of the object. For example, if a shell link is created to a text file, and if the original text file is subsequently renamed, the original shell link is updated by the shell without needing user intervention (that is, the user does not have to recreate the shell link). Creating a shell link from the standpoint of the end user is as easy as clicking the mouse; however, creating such a link from the standpoint of an application takes a bit more work. This is the first of two articles covering shell links. This article contains background information about shell links and discusses the method used to create and resolve them using the built-in menus from the shell and programmatically. The second article, "The IShellLink Interface," covers some of the underpinnings the system has put in place to implement shell links: the IShellLink interface and how the shell preserves links.

What Are Shell Links?

Shell links (also known as shortcuts) are a convenient way to reference objects within the shell name space (the hierarchical structure of objects in the Microsoft® Windows® 95 shell) without having to keep track of the name and the location of the original object. Shell links are referred to as shortcuts in the context menu (the menu that pops up when you click the object with the right mouse button) of shell objects; however, they are implemented internally via the IShellLink interface. As a result, when I refer to shell links I am also referring to shortcuts: They are the same thing. There are many objects to which you can create shell links. Some examples of objects to which you can create shell links within the shell name space are:

  • Files
  • Directories
  • Control Panel
  • Printers
  • Mail
  • Your application

When you install the beta release of Windows 95, a shell link is automatically created and placed on the desktop for the README file that comes with the system (as shown in Figure 1). You know you are looking at a shell link by the small arrow in the lower-left corner of the icon. Clicking this icon once brings up WordPad with the Windows 95 Beta Release Notes initially loaded.

 

Figure 1. A shell link

Some Benefits of Shell Links

One benefit of shell links is the inherent transparency to the user of the original object's name and location. For example, if you were to create a shell link for a file and were to place that shell link on the desktop, then when the user clicked that file, the file would be activated (the default action would occur for that file). So, if the file were a Microsoft Word document, clicking the shell link would execute Word with the file specified as the current working document. When you create a shell link to one of the objects that resides in the shell name space, you are creating a reference to that item within the context of the shell name space. Although I suspect that the most common shell objects for which end users and application developers can create shell links are files and folders, you can also create shell links to printers or to Control Panel. If you create a shell link to a printer and then change the network location for the printer, the link will still work (you will still be able to print to that printer using the link) and the user would never know that the server has changed: The location is transparent to the user.

Shell links are also useful for installation applications. The Windows 95 Setup program uses shell links itself when it places the shell link to its README on the desktop. Another place to use shell links is for a "last opened document." For example, let's say that you have a multiple-document interface (MDI) application and you want to keep track of the last document that was opened for the user. One way to do this is to create a shell link for the user, who can subsequently click that shell link whenever she wants to run your application again in the context of that document.

How an End User Creates a Shell Link

The shell has a built-in mechanism for creating shell links via the right-click context menu it provides for objects within the shell name space. End users may use this mechanism to create shell links of their own. To create a shell link and put it on the desktop, for instance, the user performs the following steps

  1. Find the object (folder, printer, program, computer) that is the target of the shell link.
  2. Click the object with the right mouse button and click Create Shortcut on the context menu (or click Create Shortcut on the File menu in Explorer as shown in Figure 2). This creates the shell link.

    Figure 2. Create Shortcut menu item

  3. Drag the shell link to the desktop and drop it to place the shell link on the desktop.

Some Background About IShellLink

Okay, so the shell has this functionality built in. But what if you are writing your own application and want to be able to programmatically create a shell link for the end user? Can this be done?

Of course it can. Besides, would I even ask the question if the answer were no?

Because shell links are implemented via the IShellLink interface, it is helpful to understand some of the basic concepts of OLE when programming a shell link; however, it is by no means mandatory to be an OLE guru to do so. If it were, I never would have been able to create a link. The most important area you should read up on to understand and use shell links is the Component Object Model. Reading the first four chapters of Inside OLE by Kraig Brockschmidt (MSDN Library, Books) should give you sufficient background.

For those of you, though, who aren't going to read those first four chapters (I know who you are, and you should be ashamed of yourselves!), I will give you a very brief overview of the Component Object Model.

Component Object Model

The Component Object Model is a specification that describes the process of communicating through interfaces, acquiring access to interfaces through the QueryInterface method, determining pointer lifetime through reference counting, and reusing objects by extending them.

An object is an item in the system that exposes interfaces (groups of related functions) to manipulate the data or properties of the object. It is created directly or indirectly by calling the CoCreateInstance function, which creates a new instance of the object and returns a pointer to the interface for the object. When two objects within the system want to communicate with one another, they call functions within the object's interface via a pointer to the interface. This interface pointer is the one that was returned by the call to CoCreateInstance. A typical time when two objects may want to communicate with each other is during a drag-and-drop operation. During this operation, the object to be dropped on the other object calls into the other object's interface to request acceptance of the drop.

All interfaces used in the Component Object Model, including the one we will use to manipulate shell links (IShellLink), support the base interface,IUnknown. The IUnknown interface supports three methods (or functions):

  • QueryInterface: Determines whether a specific interface is supported for the object.
  • AddRef: Increments the reference count on an interface.
  • Release: Decrements the reference count on an interface. Once an interface's reference count goes to zero, the object deletes itself and the pointer to that interface is no longer valid. If the reference count on all of an object's interfaces is zero, the object can be freed because there are no longer any pointers to the object.

The Tools I Used to Create a Shell Link

The sample that accompanies this technical article, SHORTCUT.EXE, is a Microsoft Foundation Class Library (MFC) application that was created with Microsoft Visual C++® version 4.2  and the Win32 SDK.

Initialization

There are some OLE basics that you need to do to create and resolve your shell links. The first thing that your application must do upon startup is to initialize the component object library with a call to CoInitialize or OleInitialize. I put this call in my sample code, SHORTCUT.CPP, in myInitInstance handler before I called anything else. Each call to CoInitialize needs to be balanced with a call to CoUninitialize. CoUninitializeshould be called when an application shuts down. It ensures that the application won't quit until it has received all of its pending messages. I put my call to CoUninitialize in my ExitInstance handler.

Creating a Shell Link to a File

To demonstrate how to create a shell link, I created a very simple MFC application that allows the user to choose a file from the current directory to which a shell link is to be created. For example, if you want to create a shell link to a text file named README, you would choose README.TXT from the list. When the user chooses the Create Shortcut menu item, a dialog box displays a list of the files in the current directory (Figure 3).

Figure 3. Dialog box for creating a shortcut in the SHORTCUT sample

The following code makes use of the handy-dandy DlgDirList function to fill my list box in the dialog box.

BOOL CreateShortCut::OnInitDialog() 
{
  DWORD cchCurDir;
  char szCurDir[MAX_PATH];

  CDialog::OnInitDialog();
  
  // Initialize the list box by filling it with files from
  // the current directory.
  GetCurrentDirectory(cchCurDir, szCurDir);
  DlgDirList(szCurDir, ID_LBOX, 0, DDL_READWRITE);
  
  return TRUE;
}

After the user chooses a file from the list and clicks the OK button, a check is made to determine whether the link is targeted to the desktop or to the current directory. The user indicates whether to target the shell link to the desktop by checking the "Place shortcut on desktop" option in the dialog box. If it is targeted to the desktop, its default location will be in a subdirectory (called DESKTOP) of the current directory that contains Windows 95. This subdirectory is hidden; you can find it by opening a command prompt and typing attrib desktop.

If your system is configured to use a different profile per user, the location of the shortcut is different. You can set up a different profile per user by using the Password applet in Control Panel. Click the User Profiles tab, and then check the "Include desktop icons and Network Neighborhood contents in user settings" option. This will cause the desktop icons (and your desktop shortcut) to be stored in the Desktop subdirectory in the registration database under HKEY_CURRENT_USER\Software\Microsoft\Windows\Current Version\Explorer\Shell Folders. The Desktop key will contain the fully qualified path to the desktop icons. So, for example, if I set up my computer to support per-user profiles, the Desktop key will be under C:\WINDOWS\PROFILES\NANCYCL\DESKTOP.

The link name is completed by retrieving the selected file via a call to DlgDirSelect, stripping off the file extension, and replacing it with the .LNK file extension.

void CreateShortCut::OnOK() 
{
  char szFileSel[MAX_PATH];
  char szFile[MAX_PATH];
  char szDesc[MAX_PATH];
  char szLink[MAX_PATH];
  DWORD cchCurDir;
  char* pDot;

  // First get the path to the link.
  // Should this shortcut be put on the desktop?
  if (IsDlgButtonChecked(IDC_CHECK1))
  {
    // Yes. Get the directory for Windows Desktop. This is
    // stored in the Registry under HKEY_CURRENT_USER\Software\
    // Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop.
    HKEY hCU;
    DWORD lpType;
    ULONG ulSize = MAX_PATH;

    if (RegOpenKeyEx(HKEY_CURRENT_USER, 
      "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 
      0,KEY_QUERY_VALUE,
      &hCU) == ERROR_SUCCESS)
    {
      RegQueryValueEx( hCU,
        "Desktop",
        NULL,
        &lpType,
        (unsigned char *)&szLink,
        &ulSize);

      RegCloseKey(hCU);
    }
  }
else
    // Get the current directory.
    GetCurrentDirectory(cchCurDir, szLink);

  // Get the selected item in the list box.
  DlgDirSelect(szFile, ID_LBOX);

  // Get the description.
  lstrcpy(szDesc, "Shortcut to ");
  lstrcat(szDesc, strupr(szFile));

  // Add the forward slash for the path.
  lstrcat (szLink, "\\");

  // Add the file name.
  lstrcat (szLink, strupr(szFile));

  // Strip off the extension, if any.
  if (pDot = strstr(szLink, "."))
    *pDot = (char)NULL;

  // Add in the .LNK extension.
  lstrcat (szLink, ".LNK");

  // Get the path to the target.
  GetCurrentDirectory(cchCurDir, szFileSel);
  lstrcat(szFileSel, "\\");
  lstrcat(szFileSel, strupr(szFile));

  // Make call to CreateShortcut() here...
  CreateIt(szFileSel, szLink, szDesc);

  // Call the default handler.
  CDialog::OnOK();
}

Next, we get down to the "real" work of creating the shell link. The CreateIt function actually does the work and takes three parameters:

  • pszShortcutFile: The file that you want the shell link to point to.
  • pszLink: The shell link that you are creating with a .LNK extension.
  • pszDesc: The description of the file. This is the string "Shortcut to <filename>", where filename is the name of the link target.

Because this function makes a call to CoCreateInstance, it is assumed that CoInitialize has already been called. As you can see by the following code, this function uses both the IPersistFile interface for the actual saving of the shell link in the system and the IShellLink interface for storing the path and description information of the link target.

HRESULT CreateShortCut::CreateIt(LPCSTR pszShortcutFile, LPSTR pszLink, 
  LPSTR pszDesc)
{
    HRESULT hres;
    IShellLink* psl;

    // Get a pointer to the IShellLink interface.
    hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                            IID_IShellLink, &psl);
    if (SUCCEEDED(hres))
    {
       IPersistFile* ppf;

       // Query IShellLink for the IPersistFile interface for 
       // saving the shell link in persistent storage.
       hres = psl->QueryInterface(IID_IPersistFile, &ppf);
       if (SUCCEEDED(hres))
       {   
         WORD wsz[MAX_PATH];

         // Set the path to the shell link target.
         hres = psl->SetPath(pszShortcutFile);

         if (!SUCCEEDED(hres))
           AfxMessageBox("SetPath failed!");

         // Set the description of the shell link.
         hres = psl->SetDescription(pszDesc);

         if (!SUCCEEDED(hres))
           AfxMessageBox("SetDescription failed!");

         // Ensure string is ANSI.
         MultiByteToWideChar(CP_ACP, 0, pszLink, -1, wsz, MAX_PATH);

         // Save the link via the IPersistFile::Save method.
         hres = ppf->Save(wsz, TRUE);
    
         // Release pointer to IPersistFile.
         ppf->Release();
       }
       // Release pointer to IShellLink.
       psl->Release();
    }
    return hres;
}

One thing to bear in mind is that if you create a shell link to another shell link, the system will simply copy the shell link—it won't create a new shell link. This is important if you are assuming that the shell links will remain independent of each other.

Resolving a Shell Link

Once you have created the shell link, you may need to gain access to and manipulate that link programmatically. This is referred to as "resolving" the shortcut. I added a function to my sample that demonstrates how you can resolve a shell link. Being ever so creative, I decided to use the same type of dialog box that I used for creating the shell link. As such, I used almost exactly the same code to fill the dialog box with the names of the files in the current directory and prompt the user for the link to resolve. The only difference was a simple check to ensure that the user actually picked a .LNK file.

void ResolveShortCut::OnOK() 
{
  char szFile[MAX_PATH];
  char szPath[MAX_PATH];

  // Get the current directory.
  GetCurrentDirectory(MAX_PATH, szPath);

  // Get the selected item in the list box.
  DlgDirSelect( szFile, IDC_LIST1);

  // Find out if it is a .LNK file or not.
  if (strstr(szFile, ".lnk") != NULL)
    // Make call to ResolveShortcut here.
    ResolveIt(m_hWnd, szFile, szPath );

  CDialog::OnOK();
}

This shortcut resolving function takes three parameters:

  • hwnd: The handle to the current focus window. We need this in case the shell needs to display a message box prompting the user to do something. This box will be displayed if the user needs to insert a floppy disk, if the link is on unshared media, or if there are network problems during the resolution of the shell link.
  • SzShortcutFile: The fully qualified path to the shell link.
  • CchPath: The size of the return buffer.

As with my function that created the shell link, this function calls CoCreateInstance and assumes that CoInitialize has been called already. Notice that the code below needs to call into the IPersistFile interface. This interface is implemented by the IShellLink object to store link information. To get the path information that I query later in the code, I need to have the link information loaded first. Failing to load the link information would cause my calls to GetPath and GetDescription to fail.

HRESULT ResolveShortCut::ResolveIt(HWND hwnd, LPCSTR pszShortcutFile, LPSTR 
  pszPath)
{
  HRESULT hres;
  IShellLink* psl;
  char szGotPath[MAX_PATH];
  char szDescription[MAX_PATH];
  WIN32_FIND_DATA wfd;

  *pszPath = 0;   // assume failure

  // Get a pointer to the IShellLink interface.
  hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
                            IID_IShellLink, &psl);
  if (SUCCEEDED(hres))
  {
    IPersistFile* ppf;

    // Get a pointer to the IPersistFile interface.
    hres = psl->QueryInterface(IID_IPersistFile, &ppf);
    if (SUCCEEDED(hres))
    {
      WORD wsz[MAX_PATH];

      // Ensure string is Unicode.
      MultiByteToWideChar(CP_ACP, 0, pszShortcutFile, -1, wsz,
                                 MAX_PATH);

     // Load the shell link.
     hres = ppf->Load(wsz, STGM_READ);
     if (SUCCEEDED(hres))
     {
       // Resolve the link.
       hres = psl->Resolve(hwnd, SLR_ANY_MATCH);

       if (SUCCEEDED(hres))
       {
          strcpy(szGotPath, pszShortcutFile);
          // Get the path to the link target.
          hres = psl->GetPath(szGotPath, MAX_PATH, (WIN32_FIND_DATA *)&wfd, 
                 SLGP_SHORTPATH );
          if (!SUCCEEDED(hres)
             AfxMessageBox("GetPath failed!");
                   
          // Get the description of the target.         
          hres = psl->GetDescription(szDescription, MAX_PATH);
          if (!SUCCEEDED(hres))
             AfxMessageBox("GetDescription failed!");
        }
      }
      // Release pointer to IPersistFile interface.
      ppf->Release();
    }
    // Release pointer to IShellLink interface.
    psl->Release();
  }
  return hres;
}

Creating a Link to Something Other Than a File

The above code demonstrates how you can programmatically create a link to a file, but it does not cover the steps that you must take to create a link to something that does not have a filename, such as a printer or Control Panel. From the standpoint of creating the shell link, the major difference lies in the fact that rather than setting the path to the link, you will instead be setting the identification list (ID List) to the printer. This is done by calling the IShellLink::SetIDList method and providing a pointer to an ID List (pidl).

I know what you are thinking. "What the heck is an ID List?"

All objects within the shell name space have an item identifier, known as an Item ID. This identifier is a variable-length byte stream containing information that identifies the object within a folder. The shell often concatenates Item IDs together to form a list of IDs, known as ID Lists. These lists may contain one or many Item IDs and are NULL terminated.

Using MFC

If you plan to use the CreateIt function from the SHORTCUT sample in your MFC-based application, you may run into problems with the conversion from multibyte to wide characters. If you do, search for "Technical Note 49: MFC/OLE MBCS to Unicode Translation Layer (MFCANS32)" in the MSDN Library. The MFCANS32 DLL provides ANSI interfaces to 32-bit OLE, which is primarily Unicode. This technical note will show you what you need to do if you experience this problem.

Summary

This article gives you the bare-bones information you need to create and resolve shell links within an application. It is by no means an all-encompassing work, though. If you would like to learn more about the underpinnings of shell links, my advice is to read the next article in the series on shell links, "The IShellLink Interface."

< src="MS-ITS://dsmsdn.chm">

 
具体实现:
// Class which contains all the parameters related to shortcut
class  CShellLinkInfo :  public  CObject
{
public:
//Constructors / Destructors
  CShellLinkInfo();
  CShellLinkInfo(
const CShellLinkInfo& sli);
  
~CShellLinkInfo();

//Methods 
  CShellLinkInfo& operator=(const CShellLinkInfo& sli);

//Diagnostic support
#ifdef _DEBUG
  
virtual void Dump(CDumpContext& dc);
#endif

//Variables
  CString      m_sTarget;
  LPITEMIDLIST m_pidl;
  CString      m_sArguments;
  CString      m_sDescription;
  WORD         m_wHotkey;
  CString      m_sIconLocation;
  
int          m_nIconIndex;
  
int          m_nShowCmd;
  CString      m_sWorkingDirectory;
}
;


// Class which wraps standard shortcuts i.e. IShellLink
class  CShellLink
{
public:
//Constructors / Destructors
  CShellLink();
  
virtual ~CShellLink();

//Methods
  BOOL Create(const CShellLinkInfo& sli);
  BOOL Load(
const CString& sFilename);
  BOOL Save(
const CString& sFilename);
  BOOL Resolve(CWnd
* pParentWnd, DWORD dwFlags);

//Accessors
  CString      GetPath() const;
  LPITEMIDLIST GetPathIDList() 
const;
  CString      GetArguments() 
const;
  CString      GetDescription() 
const;
  WORD         GetHotKey() 
const;
  CString      GetIconLocation() 
const;
  
int          GetIconLocationIndex() const;
  
int          GetShowCommand() const;
  CString      GetWorkingDirectory() 
const;

//Mutators
  void SetPath(const CString& sPath);
  
void SetPathIDList(LPITEMIDLIST pidl);
  
void SetArguments(const CString& sArguments);
  
void SetDescription(const CString& sDescription);
  
void SetHotKey(WORD wHotkey);
  
void SetIconLocation(const CString& sIconLocation);
  
void SetIconLocationIndex(int nIconIndex);
  
void SetShowCommand(int nShowCmd);
  
void SetWorkingDirectory(const CString& sWorkingDirectory);

protected:
  BOOL Initialise();
  CShellLinkInfo m_sli;
  IShellLink
*    m_psl;
  IPersistFile
*  m_ppf;
  BOOL           m_bAttemptedInitialise;
}
;


// Class which wraps internet shortcuts i.e. IUniformResourceLocator
class  CUrlShellLink :  public  CShellLink
{
public:
//Constructors / Destructors
  CUrlShellLink();
  
virtual ~CUrlShellLink();

//Methods
  BOOL Create(const CShellLinkInfo& sli);
  BOOL Load(
const CString& sFilename);
  BOOL Save(
const CString& sFilename);
  BOOL Invoke(CWnd
* pParentWnd, DWORD dwFlags, const CString& sVerb);

//Following 4 functions just ASSERT if called
  CString GetArguments() const;
  LPITEMIDLIST GetPathIDList() 
const;
  
void SetArguments(const CString& sArguments);
  
void SetPathIDList(LPITEMIDLIST pidl);

protected:
  BOOL Initialise();
  IUniformResourceLocator
* m_pURL;
}
;
C++实现Windows快捷方式创建:IShellLink接口与COM编程实战 在Windows桌面应用开发中,程序安装与部署是产品化的重要环节,其中创建桌面和开始菜单快捷方式是提升用户体验的基础需求。从技术原理看,Windows快捷方式(.lnk文件)并非普通文本文件,而是具有特定结构的二进制数据,因此无法通过简单的文件操作生成。其标准创建方法依赖于Windows Shell提供的COM组件模型,通过IShellLink接口设置目标路径、工作目录等属性,再借助IPersistFile接口持久化保存。这一机制体现了Windows系统对Shell扩展和对象持久化的设计思想。在工程实践中, 阅读详情

相关推荐

C语言或C++通过IShellLinkA创建或解析lnk快捷方式(使用char字符数组)

请注意因为函数参数的类型不为BSTR,所以这两个接口可直接传char *或wchar_t *字符串,不需要提前转化为BSTR类型。本例程用到的COM接口有IShellLinkA和IPersistFile。

ZLK1214的专栏 1212

创建快捷方式 IShellLink

http://blog.youkuaiyun.com/ntwilford/article/details/5635381 HRESULT AddShellLink(  ) { HRESULT hr; //创建ShellLink IShellLink *pSLAutoRun = NULL; hr = CoCreateInstance(CLSID_ShellLink, NULL,  CL

jiht594的专栏 918

Delphi读取快捷方式中的图标和路径信息.rar

Delphi读取快捷方式中的图标和路径信息,将包含在快捷方式中的图标和路径信息以及执行文件目录、热键等读取出来,适用于Windwos中所有的快捷方式。

C# 使用 WIN32API IShellLink 创建 快捷方式

C# 使用 WIN32API IShellLink 创建 快捷方式

csdn_ad986ad的博客 761

创建快捷方式

windows 创建快捷方式,有源码提供

vc++使用IShellLink ATL接口来控制快捷方式文件.zip

visual c++ vc++使用IShellLink ATL接口来控制快捷方式文件.zip

使用IShellLink和IPersistFile在windows下创建文件快捷方式

转载:http://www.cnblogs.com/lzjsky/archive/2011/01/17/1937525.html 二个操作:新建和解析 主要用到的是COM组件。IShellLink和IPersistFile 需要添加的头函数 #include <shobjidl.h> IPersistFile主要用到两个成员函数: 1、Save。保存内容到文件中去 2、Load。读取...

prerfect_cat的博客 1324

数字IC后端时钟树综合实战:OCC电路优化与时钟树平衡策略

本文深入探讨了数字IC后端设计中时钟树综合的关键挑战,重点分析了OCC电路时钟树优化的必要性。通过实战案例,详细阐述了如何通过手动干预、时钟分组与分段长树等策略,避免工具自动平衡导致的时序违例和资源浪费,从而有效实现时钟树平衡并提升设计质量。

weixin_29306261的博客 331

使用Visual C++创建Windows快捷方式:IShellLink与IPersistFile接口详解

在Windows桌面应用开发中,快捷方式(.lnk文件)是提升用户体验的重要功能,它通过封装目标路径、参数和图标等元数据,为用户提供便捷的程序访问入口。其核心原理基于Windows Shell的COM组件模型,通过IShellLink接口配置属性,再借助IPersistFile接口持久化保存。这项技术不仅增强了软件的专业性,还广泛应用于绿色软件、内部工具和安装后配置等场景。本文聚焦Visual C++开发,深入解析如何通过COM接口动态创建快捷方式,并针对路径处理、权限管理及常见错误提供实战解决方案,帮助开

weixin_34236869的博客 287

ECC椭圆曲线加解密原理详解(配图)

椭圆曲线加解密原理详解 本文主要参照:ECC椭圆曲线详解(有具体实例)[1] 前言: 椭圆曲线(ECC)加密原理跟RSA加解密原理比起来,可真是晦涩难懂。拜读了大神Kalafinaian文章“ECC椭圆曲线详解(有具体实例)”,终于看到了参透的曙光。 由于原文中有微小的瑕疵,也为了便于阅读起来更加流畅,我重新整理了一下这篇文章。 为什么使用椭圆曲线加密算法? RSA的解决分解整数问题需要亚指数...

Mark的博客 7万+

QT实现HTTP文件(夹)下载的完整流程与实战技巧

本文详细介绍了使用QT框架实现HTTP文件和文件夹下载的完整流程与实战技巧。通过QNetworkAccessManager等核心类,讲解了从单文件下载、大文件处理、进度显示、暂停/取消功能,到复杂的文件夹下载策略。文章重点剖析了断点续传、错误处理与网络健壮性等关键问题,为C++桌面应用集成稳定高效的下载功能提供了专业指导。

weixin_29239279的博客 280

IShellLink应用(创建快捷方式)

VC操作Windows快捷方式(自己总结) 二个操作:新建和解析 主要用到的是COM组件。IShellLink和IPersistFile 需要添加的头函数shobjidl.h IPersistFile主要用到两个成员函数:1、Save。保存内容到文件中去2、Load。读取Load的函数原型HRESULT Load(LPCOLSTR pszFileName, //...

dizhi5320的博客 248

555时基芯片的5种经典电路设计:从方波发生器到PWM调光实战

本文深入解析了555时基芯片的5种经典电路设计,从基础的无稳态方波发生器、单稳态触发器,到实用的占空比可调PWM信号源,并重点介绍了如何引入TVS保护电路增强系统鲁棒性。最后通过一个带保护的PWM LED调光台灯实战项目,综合展示了信号生成、功率驱动与电路保护的核心技术,是电子爱好者掌握模拟电路设计与应用的绝佳指南。

weixin_29207439的博客 492

用delphi创建桌面快捷方式

转自http://blog.youkuaiyun.com/yangvszi/article/details/3438533 有许多程序在首次安装或运行的时候都会自动地子桌面上创建 个快捷方式图标。但是这个自动创建桌面快捷方式的在程序中是如 何实现的呢?众所周知 在windows中要给应用程序创建一个快捷方 式 只需要你右键单击 其应用程序的图标 然后 点击创建快捷方式 ,将其快捷方式 复制到桌面上就

找个地方放一下 1319

【自动驾驶端到端5:VADv2: End-to-End Vectorized Autonomous Driving via Probabilistic Planning】

从大规模人类驾驶演示中学习类人驾驶策略是有希望的。但是,规划的不确定性使得从驾驶演示中提取驾驶知识是有挑战性的。从统计学习的角度来看,动作(包括实际和速度)是高度随机的,受许多无法建模的潜在因素影响。

weixin_40000560的博客 1405

MQTT阿里云OTA 调试记录

2.验证,这个验证是什么意思呢,就是阿里云会把你包的信息,比如包大小,streamid(相当于包的识别码),版本号发送给你的设备,然后如果你没发送升级成功的包给阿里云,这里会是一直验证中的状态,那你的设备每次重新连接阿里云,发送connect包给阿里云的时候,阿里云就会发送一次这个验证(upgrade)包。提取到了之后就可以发送请求包了,这个请求包比较坑,也可能是我没付费,他的包一次最多只有1024个字节的数据。之前说了,验证状态下,设备发送connect包给阿里云,阿里云就会发一个upgrade包给你。

qq_42585211的博客 1231

VC 快捷方式

VC操作Windows快捷方式(自己总结) 二个操作:新建和解析 主要用到的是COM组件。IShellLink和IPersistFile 需要添加的头函数 shobjidl.h IPersistFile主要用到两个成员函数: 1、Save。保存内容到文件中去 2、Load。读取  Load的函数原型  HRESULT Load(    LPCOLSTR pszF

软件开发 1116

为什么你的SSE连接总断?深入对比EventSource与fetch-event-source的5大差异点

本文深入对比了原生EventSource与@microsoft/fetch-event-source库在SSE连接稳定性上的五大关键差异。重点剖析了后者在请求能力、连接控制、错误处理、数据解析及性能优化方面的优势,特别是其支持POST请求、自定义Header、精细化的重连策略与生命周期管理,为解决生产环境中SSE连接频繁断开的问题提供了专业方案。

weixin_28077113的博客 494

用IShellLink解析快捷方式(ShortCut)

前几天要写一个解析快捷方式的程序,发现MSDN上有篇文章,转了过来 本想翻译一下的,想想英语比较弱,作罢。Using Shell Links in Windows 95Nancy Winnick ClutsMicrosoft Developer Network Technology GroupOctober 1994Revised: June 1995 (Added "Using

流云轩 2035

YOLOv8魔改系列:将CIoU替换成Wise-IoU,飞速涨点

将YOLOv8中CIoU替换成Wise-IoU,实现飞速涨点

qq_66386046的博客 2679

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

VC创建快捷方式

VC操作Windows快捷方式 总结主要有二个操作:新建和解析主要用到的是COM组件。IShellLink和IPersistFile需要添加的头函数shobjidl.hIPersistFile主要用到两个成员函数: 1、Save。保存内容到文件中去 2、Load。读取Load的函数原型 HRESULT Load( LPCOLSTR pszFileName, //快捷

Koma的主页 2519

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

运用IShellLink和IPersistFile创建快捷方式,设置或读取快捷方式信息

先介绍一下这两个类:IShellLinkThe IShellLink interface allows Shell links to be created, modified, and resolved. MethodsIShellLink supports the following methods:GetArgumentsRetrieves the

xiaohuaidan717的专栏 3190

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

windows程序启动快捷方式探究

对于大部分程序来说,程序的运行都需要众多文件的组成,我们可以打开任意一个安装过的程序的安装文件夹,可以看到基本都会包含很多exe或者dll文件,这是因为一个程序可能包含有主程序和次要程序,在用户用不到次要程序的时候就不会启动相关文件,减小运行内存,还有常见的为了实现模块化、减少代码量而创建的dll动态库。而快捷方式相当于一个指针,指向了需要启动的文件,而快捷方式的位置是可以随意移动的,且本身占用空间较小,一般为几k,非常方便用户的统一管理以及编辑。在通过已有对象创建快捷方式时,必须要对象存在才能创建。

qq_32527567的博客 4634
上一篇: Visual Studio 调试常用20个小技巧
下一篇: COM组件设计与应用之四---简单调用COM组件
htt9931
博客等级 码龄24年 43粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值