zoukankan      html  css  js  c++  java
  • 创建快捷方式

     1 void CInstall_ProgressDlg::CreateShortCut(CString csLinkPath, CString csExePath, CString csIconPath)
     2 {
     3     HRESULT hres;
     4     hres = ::CoInitialize(NULL);
     5     if(S_OK == hres)
     6     {
     7         //delete old link
     8         CFileFind cfind;
     9         if(cfind.FindFile(csLinkPath)){
    10             CFile::Remove(csLinkPath);
    11         }
    12         IShellLink * pShellLink ;
    13         hres = ::CoCreateInstance( CLSID_ShellLink, NULL,CLSCTX_INPROC_SERVER, IID_IShellLink,(void **)&pShellLink);
    14         if( SUCCEEDED( hres))
    15         {
    16             pShellLink -> SetPath(csExePath);
    17             if(PathFileExists(csIconPath))
    18                 pShellLink -> SetIconLocation(csIconPath, 0); 
    19             pShellLink -> SetHotkey( MAKEWORD( 'R', HOTKEYF_SHIFT | HOTKEYF_CONTROL));
    20             CString csWorkingDir;
    21             csWorkingDir = csExePath.Left(2);
    22             csWorkingDir.Append(FILE_SEPARATOR);
    23             TRACE_CS(csWorkingDir);
    24             pShellLink -> SetWorkingDirectory(csWorkingDir);
    25             IPersistFile *pPersistFile;
    26             hres = pShellLink -> QueryInterface( IID_IPersistFile, (void **)&pPersistFile) ;
    27             if( SUCCEEDED(hres))
    28             {
    29                 hres = pPersistFile -> Save(csLinkPath, TRUE);
    30                 pPersistFile -> Release();
    31             }
    32             pShellLink -> Release();
    33         }
    34         ::CoUninitialize();
    35     }    
    36 } 
    View Code
     1 void CInstall_ProgressDlg::CreateStartMenu()
     2 {
     3     TCHAR chStartupFolder[MAX_PATH];
     4     /*
     5     *parm1: hwnd
     6     *parm2: path buffer
     7     *parm3: CSIDL_PROGRAMS 0x0002  / Start MenuPrograms
     8     *parm4: true:if file !exist to create, false:not create
     9     */
    10     SHGetSpecialFolderPath(this->GetSafeHwnd(), chStartupFolder,CSIDL_PROGRAMS,FALSE);
    11     CString csStartupFolder = chStartupFolder;
    12     csStartupFolder.Append(FILE_SEPARATOR);
    13     csStartupFolder.Append(FOLDER_APP_NAME);
    14     if(!PathFileExists(csStartupFolder)){
    15         g_InstallHelper.CreateInstallFolder(csStartupFolder);
    16     }
    17     CString csInstallPath;
    18     csInstallPath = g_InstallInfo.chInstallPath;
    19     CString csEXEFilePath;
    20     csEXEFilePath = csInstallPath;
    21     csEXEFilePath.Append(FILE_SEPARATOR);
    22     csEXEFilePath.Append(FILE_APP_NAME);
    23     CString csUnExeFilePath;
    24     csUnExeFilePath = csInstallPath;
    25     csUnExeFilePath.Append(FILE_SEPARATOR);
    26     csUnExeFilePath.Append(FILE_UNINSTALL_NAME);
    27     CString csLinkFileName = csStartupFolder;
    28     csLinkFileName.Append(FILE_SEPARATOR);
    29     csLinkFileName.Append(LINK_NAME);
    30     csLinkFileName.Append(LINK_EXT);
    31     CString csUnlinkFileName = csStartupFolder;
    32     csUnlinkFileName.Append(FILE_SEPARATOR);
    33     csUnlinkFileName.Append(LINK_UNINSTALL_NAME);
    34     csUnlinkFileName.Append(LINK_EXT);
    35     //get icon path
    36     CString csExeIconPath;
    37     csExeIconPath = csInstallPath;
    38     csExeIconPath.Append(FILE_SEPARATOR);
    39     csExeIconPath.Append(ICON_APP_EXE_NAME);
    40     CString csUnExeIconPath;
    41     csUnExeIconPath = csInstallPath;
    42     csUnExeIconPath.Append(FILE_SEPARATOR);
    43     csUnExeIconPath.Append(ICON_UNINSTALL_EXE_NAME);
    44     TRACE_CS(csLinkFileName);
    45     TRACE_CS(csEXEFilePath);
    46     TRACE_CS(csExeIconPath);
    47     TRACE_CS(csUnlinkFileName);
    48     TRACE_CS(csUnExeFilePath);
    49     TRACE_CS(csUnExeIconPath);
    50     CreateShortCut(csLinkFileName, csEXEFilePath, csExeIconPath);
    51     CreateShortCut(csUnlinkFileName, csUnExeFilePath, csUnExeIconPath);
    52 }
    View Code
  • 相关阅读:
    Unity3d 4.3 通过代码动态更改SpriteRender的Sprite
    使用Unity3D的50个技巧:Unity3D最佳实践
    仿照wtform自定义Form组件
    flask-script
    Django中的信号
    浅淡python中with的用法,上下文管理器
    类和对象的创建过程(元类,__new__,__init__,__call__)
    flask-wtforms
    flask-session组件
    Flask-信号(blinker)
  • 原文地址:https://www.cnblogs.com/guozht/p/9645189.html
Copyright © 2011-2022 走看看