Creating shortcuts
-
Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini
-
Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini
http://www.codeproject.com/shell/create\_shortcut.asp
greatest thing is to do wot others think you cant
suhredayan@omniquad.commessenger :suhredayan@hotmail.com
-
Hi, I want to copy the shortcut of an executable to a different location, from my program. Is there any function to do that? I have used CopyFile() to copy the exe, but how to create the shortcut to the exe and send/paste it to a particular location? Kindly help. Thanks.. Vini
hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly.
CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize();
rgds... mil10. -
hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly.
CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize();
rgds... mil10. -
hi, you can use the following code to create a shortcut instead of copying an existing one. below code will create a shortcut for notepad in c:\ . Change the path accordingly.
CString strFile("notepad.exe"); IShellLink* pLink; IPersistFile* pPersistFile; if(FAILED(CoInitialize(NULL))) throw CString("Failed to initialize COM Library."); if(FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink))) throw CString("Failed to initialize COM Library."); pLink->SetPath((LPCTSTR)strFile); pLink->SetDescription("Notepad fooooooooooo"); pLink->SetShowCmd(SW_SHOW); if(FAILED(pLink->QueryInterface(IID_IPersistFile, (void **)&pPersistFile))) throw CString("Failed to query IID_IPersistFile."); CString str("c:\\notepad.lnk"); CComBSTR path; path = str.AllocSysString(); pPersistFile->Save(path, true); pPersistFile->Release(); pLink->Release(); CoUninitialize();
rgds... mil10.What are the #include's needed for this code? I'm compiling for Win32 and I haven't been able to figure out the right combination of files thanks