MCPcopy Create free account
hub / github.com/bumptop/BumpTop / createShortcut

Method createShortcut

trunk/win/Source/BT_FileSystemManager.cpp:662–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

660}
661
662void FileSystemManager::createShortcut(QString shortcutFilePath, QString pathToTarget, QString desc)
663{
664 HRESULT hres = NULL;
665 IShellLink * psl = NULL;
666 IPersistFile * ppf = NULL;
667
668 QDir workingDirectory = scnManager->getWorkingDirectory();
669 QDir linkPath = workingDirectory / shortcutFilePath;
670
671 // Get a pointer to the IShellLink interface.
672 hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &psl);
673
674 if (SUCCEEDED(hres))
675 {
676 // Set the path to the shortcut target
677 psl->SetPath((LPCWSTR) pathToTarget.utf16());
678 psl->SetDescription((LPCWSTR) desc.utf16());
679
680 // Query IShellLink for the IPersistFile interface for
681 // saving the shortcut in persistent storage.
682 hres = psl->QueryInterface(IID_IPersistFile, (void **) &ppf);
683
684 if (SUCCEEDED(hres))
685 {
686 // Save the link by calling IPersistFile::Save.
687 hres = ppf->Save((LPCOLESTR) native(linkPath).utf16(), TRUE);
688 ppf->Release();
689 }
690
691 psl->Release();
692 }
693}
694
695void FileSystemManager::onFileAdded(LPCWSTR strFileName)
696{

Callers

nothing calls this directly

Calls 5

getWorkingDirectoryMethod · 0.80
SaveMethod · 0.80
nativeFunction · 0.70
QueryInterfaceMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected