zoukankan      html  css  js  c++  java
  • C++实现在桌面创建程序的快捷方式

    C++实现在桌面创建程序的快捷方式
    
    #include "atlconv.h"
    
    
    bool CreatLinkToStartMenu(char * pszPeFileName)
    {
    
     HRESULT hr = CoInitialize(NULL);
     if (SUCCEEDED(hr))
     {
      IShellLink *pisl;
      hr = CoCreateInstance(CLSID_ShellLink, NULL,
       CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pisl);
      if (SUCCEEDED(hr))
      {
       IPersistFile* pIPF;
    
       /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
       //这里是我们要创建快捷方式的原始文件地址
       pisl->SetPath(pszPeFileName);
       hr = pisl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
       if (SUCCEEDED(hr))
       {
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
        //这里是我们要创建快捷方式的目标地址
        char szStartPath[MAX_PATH] = {0};
        SHGetSpecialFolderPath(NULL,szStartPath, CSIDL_STARTUP, 0);
        strcat(szStartPath,"\Windows Message.lnk");
        
        USES_CONVERSION;
        LPCOLESTR lpOleStr = A2COLE(szStartPath);
        
        pIPF->Save(lpOleStr, FALSE);
        
        pIPF->Release();
       }
       pisl->Release();
      }
      CoUninitialize();
     }
    
     return true;
    }
    
    来源网站:http://blog.csdn.net/i_like_cpp/article/details/8689664
  • 相关阅读:
    ZOJ3414Trail Walk(计算几何)
    ZOJ-3410Layton's Escape(优先队列+贪心)
    爬虫之requests
    爬虫
    flsk-SQLALchemy
    flask--Wtform
    flask---信号
    flask-session
    单例模式
    Python-flask中数据库连接池DBUtils
  • 原文地址:https://www.cnblogs.com/lovelyx/p/4867136.html
Copyright © 2011-2022 走看看