当前位置:网站首页>Generate shortcut
Generate shortcut
2022-04-23 06:43:00 【The old man is outside the door】
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;
// Here is the original file address where we want to create the shortcut
pisl->SetPath("E:\\test\\xxx.exe");
hr = pisl->QueryInterface(IID_IPersistFile, (void**)&pIPF);
if (SUCCEEDED(hr))
{
// convert to 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);
// Here is the destination address where we want to create the shortcut
pIPF->Save(wcs1, FALSE);
pIPF->Release();
}
pisl->Release();
}
CoUninitialize();
}
}
版权声明
本文为[The old man is outside the door]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230548038943.html
边栏推荐
猜你喜欢
Collection of practical tips for C language (continuously updated)
CUDA环境安装
【UDS统一诊断服务】四、诊断典型服务(5)— 功能/元件测试功能单元(例行程序功能单元0x31)
cuda工程更换环境(电脑)后遇到的一系列编译问题
CUDA environment installation
Opencv uses genericindex for KNN search
[ThreadX] h743 + ThreadX + Filex migration record
[UDS unified diagnostic service] III. application layer protocol (1)
cv_bridge 与opencv 版本不匹配的解决
【UDS统一诊断服务】二、网络层协议(1)— 网络层概述与功能
随机推荐
Swagger2 generates API documents
[UDS unified diagnostic service] II. Network layer protocol (2) - data transmission rules (single frame and multi frame)
【UDS统一诊断服务】一、诊断概述(2)— 主要诊断协议(K线和CAN)
Running QT program in visual Stdio
[UDS] unified diagnostic service (UDS)
CUDA环境安装
Notes on advanced points of C language 2
【UDS统一诊断服务】二、网络层协议(1)— 网络层概述与功能
静态成员
C语言进阶要点笔记5
Programmers can also write novels
Graduation project, curriculum link, student achievement evaluation system
C语言进阶要点笔记2
四元数乘法
类和对象
undefined reference to `Nabo::NearestNeighbourSearch
[UDS unified diagnostic service] IV. typical diagnostic service (5) - function / component test function unit (routine function unit 0x31)
Round up a little detail of the round
深蓝学院激光slam理论与实践 -第二章(里程计标定)作业
Matlab标定板角点检测原理