Я используя код, найденный в документации Microsoft. Однако, когда я запускаю его, созданный им файл не является правильным файлом ярлыка.
[img]https://i.stack .imgur.com/Xo68G.png[/img]
Вот сам код:
Код: Выделить всё
HRESULT CreateLink(const LPCWSTR lpszPathObj, const LPCWSTR lpszPathLink, const LPCWSTR lpszDesc)
{
IShellLink* psl;
// Get a pointer to the IShellLink interface. It is assumed that CoInitialize
// has already been called.
auto hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast(&psl));
if (SUCCEEDED(hres))
{
IPersistFile* ppf;
// Set the path to the shortcut target and add the description.
std::ignore = psl->SetPath(lpszPathObj);
std::ignore = psl->SetDescription(lpszDesc);
// Query IShellLink for the IPersistFile interface, used for saving the
// shortcut in persistent storage.
hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast(&ppf));
if (SUCCEEDED(hres))
{
// Save the link by calling IPersistFile::Save.
hres = ppf->Save(lpszPathLink, TRUE);
ppf->Release();
}
psl->Release();
}
return hres;
}
Подробнее здесь: https://stackoverflow.com/questions/783 ... -file-in-c
Мобильная версия