当前位置:网站首页>生成快捷方式
生成快捷方式
2022-04-23 05:48:00 【老朽在门外】
void MakeShortCut()
{
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("E:\\test\\xxx.exe");
hr = pisl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
if (SUCCEEDED(hr))
{
//转换成unicode
char path[512] = {
0 };
SHGetSpecialFolderPath(0, path, CSIDL_DESKTOPDIRECTORY, 0);
std::string convertStr;
convertStr += path;
convertStr += "\\";
convertStr += "xxxx.lnk";
int lengthOfWcs1 = MultiByteToWideChar(CP_ACP, 0, convertStr.c_str(), -1, NULL, 0);
wchar_t* wcs1 = new wchar_t[lengthOfWcs1 + 1];
MultiByteToWideChar(CP_ACP, 0, convertStr.c_str(), -1, wcs1, lengthOfWcs1);
//这里是我们要创建快捷方式的目标地址
pIPF->Save(wcs1, FALSE);
pIPF->Release();
}
pisl->Release();
}
CoUninitialize();
}
}
版权声明
本文为[老朽在门外]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_41167925/article/details/122358713
边栏推荐
- Rust:如何 match 匹配 String 字符串?
- Robocode教程7——雷达锁定
- Figure guessing game
- C语言进阶要点笔记5
- 产生随机数
- 1007 go running (hdu6808) in the fourth game of 2020 Hangzhou Electric Multi school competition
- 【UDS统一诊断服务】四、诊断典型服务(1)— 诊断和通信管理功能单元
- 根据SQL语句查询出的结果集,将其封装为json
- Linux 用rpm的方式安装mysql(超简单)
- Graduation project, viewing screenshots of epidemic psychological counseling system
猜你喜欢
copy constructor
类的继承与派生
文件查看命令和用户管理命令
Class inheritance and derivation
Opencv uses genericindex for KNN search
Cross domain issues - allow origin header contains multiple values but only one is allowed
如何安装jsonpath包
【UDS统一诊断服务】四、诊断典型服务(2)— 数据传输功能单元
Initialization of classes and objects (constructors and destructors)
Solution to the trial of ycu Blue Bridge Cup programming competition in 2021
随机推荐
类的继承与派生
【无标题】
sqlite3加密版
Jeu de devinettes
Dynamic creation and release, assignment and replication of objects
【踩坑】Win11 WSL2 中 meld 无法正常使用问题修复
PM2 deploy nuxt project
vs中的多字节与unicode
【UDS统一诊断服务】四、诊断典型服务(1)— 诊断和通信管理功能单元
【UDS统一诊断服务】一、诊断概述(1)— 诊断概述
Flask - 中间件
File viewing commands and user management commands
定位器
爬取蝉妈妈数据平台商品数据
C语言输入和输出(printf和scanf函数、putchar和getchar函数)
识别验证码
vs中能编译通过,但是会有红色下划线提示未定义标示符问题
SQL sorts according to the specified content
A solution to replace not in in SQL
带默认模板实参的类模板与模板模板形参的匹配