Forum Navigation
Create windows .lnk
Posted: 02/12/08 22:18:35Trying to create a windows .lnk file, the typical way is to use IShellLink... but can;t find it under sys.win32 heres some c++ code i've used in the past...
void CreateShortcut(LPWSTR root, LPWSTR link) { HRESULT hres; IShellLink *psl = NULL; IPersistFile *pPf = NULL; if (fileExists(link)) return; try{ hres = CoInitialize(NULL); hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); SetErrorMode(SEM_FAILCRITICALERRORS); try{ hres = psl->SetPath(root); }catch(int e){} hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&pPf); hres = pPf->Save(link, TRUE); }catch(int e) {} refreshDesktop(); }-wyverex