0

Anyone know the fix for creating a shortcut to a folder. According to the article at the link below, all you need to do is change the first parameter to CoCreateInstance to CLSID_FolderShortcut and it will create a folder shortcut instead of a file shortcut. This isn't the case, it does create the shortcut but it doesn't work.

When you view the properties of the shortcut, "Target type" is empty, it should be "File folder". I am trying this on Windows 7. Creating file shortcuts works fine using the sample code.

http://msdn.microsoft.com/en-us/library/bb776891(VS.85).aspx#Shellink_Creating_Shortcut

Code Monkey
  • 889
  • 3
  • 11
  • 27
tool4scs
  • 73
  • 5
  • Figured it out, the issue was the filename passed to SetPath() contained a space in it so I thought it needed to have quotes around it, well that isn't the case. Removed the quotes and now it works. – tool4scs Oct 04 '12 at 03:30
  • At least in my testing, leaving it as CLSID_ShellLink works fine to produce a link to either a file or a folder. – Jerry Coffin Oct 04 '12 at 03:35
  • You are right, it was the quoted path that screwed me up from the beginning. Plus using your suggestion allows the link to show up under the Favorites list in My Computer which is an added bonus. CLSID_FolderShortcut didn't have that same result. Thanks for the tip. – tool4scs Oct 04 '12 at 13:35
  • Voting to close as lacking a [mcve]. The issue also proved to be irrelevant to what is written in the question, so it's useless as it is. – ivan_pozdeev May 28 '18 at 17:37
  • Does this answer your question? [How to create shortcut for virtual folder in C++ on windows 7?](https://stackoverflow.com/questions/46961149/how-to-create-shortcut-for-virtual-folder-in-c-on-windows-7) – Simon Mourier Sep 07 '20 at 11:03

0 Answers0