IShellLink*pShellLink;hres=::CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(void**)&pShellLink);if(SUCCEEDED(hres)){pShellLink->SetPath(csExePath);if(PathFileExists(csIconPath))pShellLink->SetIconLocation(csIconPath,0);pShellLink->SetHotkey(MAKEWORD('R',HOTKEYF_SHIFT|HOTKEYF_CONTROL));CStringcsWorkingDir;csWorkingDir=csExePath.Left(2);csWorkingDir.Append(FILE_SEPARATOR);TRACE_CS(csWorkingDir);pShellLink->SetWorkingDirectory(csWorkingDir);
IPersistFile*pPersistFile;hres=pShellLink->QueryInterface(IID_IPersistFile,(void**)&pPersistFile);if(SUCCEEDED(hres)){hres=pPersistFile->Save(csLinkPath,TRUE);pPersistFile->Release();}pShellLink->Release();}::CoUninitialize();}}
复制代码代码如下:voidCInstall_ProgressDlg::CreateStartMenu(){TCHARchStartupFolder[MAX_PATH];/**parm1:hwnd*parm2:pathbuffer*parm3:CSIDL_PROGRAMS0x0002/StartMenu\Programs*parm4:true:iffile!existtocreate,false:notcreate*/SHGetSpecialFolderPath(this->GetSafeHwnd(),chStartupFolder,CSIDL_PROGRAMS,FALSE);CStringcsStartupFolder=chStartupFolder;csStartupFolder.Append(FILE_SEPARATOR);csStartupFolder.Append(FOLDER_APP_NAME);if(!PathFileExists(csStartupFolder)){g_InstallHelper.CreateInstallFolder(csStartupFolder);}
CStringcsInstallPath;csInstallPath=g_InstallInfo.chInstallPath;
CStringcsEXEFilePath;csEXEFilePath=csInstallPath;csEXEFilePath.Append(FILE_SEPARATOR);csEXEFilePath.Append(FILE_APP_NAME);CStringcsUnExeFilePath;csUnExeFilePath=csInstallPath;csUnExeFilePath.Append(FILE_SEPARATOR);csUnExeFilePath.Append(FILE_UNINSTALL_NAME);CStringcsLinkFileName=csStartupFolder;csLinkFileName.Append(FILE_SEPARATOR);csLinkFileName.Append(LINK_NAME);csLinkFileName.Append(LINK_EXT);CStringcsUnlinkFileName=csStartupFolder;csUnlinkFileName.Append(FILE_SEPARATOR);csUnlinkFileName.Append(LINK_UNINSTALL_NAME);csUnlinkFileName.Append(LINK_EXT);
//geticonpathCStringcsExeIconPath;csExeIconPath=csInstallPath;csExeIconPath.Append(FILE_SEPARATOR);csExeIconPath.Append(ICON_APP_EXE_NAME);CStringcsUnExeIconPath;csUnExeIconPath=csInstallPath;csUnExeIconPath.Append(FILE_SEPARATOR);csUnExeIconPath.Append(ICON_UNINSTALL_EXE_NAME);
TRACE_CS(csLinkFileName);TRACE_CS(csEXEFilePath);TRACE_CS(csExeIconPath);TRACE_CS(csUnlinkFileName);TRACE_CS(csUnExeFilePath);TRACE_CS(csUnExeIconPath);CreateShortCut(csLinkFileName,csEXEFilePath,csExeIconPath);CreateShortCut(csUnlinkFileName,csUnExeFilePath,csUnExeIconPath);}
如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。