当前位置:网站首页>生成快捷方式
生成快捷方式
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
边栏推荐
猜你喜欢
随机推荐
拷贝构造函数
【UDS统一诊断服务】三、应用层协议(2)
Swagger2 generates API documents
Conversion between JS object and string
猜數字遊戲
Installation of GCC, G + +, GDB
日志
爬取蝉妈妈数据平台商品数据
[ThreadX] h743zi + lan8720 + ThreadX + netx duo transplantation
爬西瓜视频url
【无标题】
Rust: Tcp 服务器与客户端的一个简单例子
Detailed arrangement of knowledge points of University probability theory and mathematical statistics
PM2 deploy nuxt project
word排版遇到的格式问题
搭建jpress个人博客
函数的调用过程
sqlite3加密版
如何安装jsonpath包
[untitled]









