cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
pfsjmiller
Level 3

Creating shortcut to folder

I want to create a shortcut to a folder that gets installed. I've searched and done what was suggested but still no shortcut.
I have a directory named "Reports" in TARGETDIR.
I want to create a shortcut to "Reports" in a folder named "MyApp" on the desktop.
This is what I tried. It creates a shortcut, but the shortcut is a file type shortcut and not a folder shortcut.
szFolder = TARGETDIR ^ "Reports";

LongPathToQuote(szFolder,TRUE);

AddFolderIcon(
FOLDER_DESKTOP ^ "MyApp",
"Reports Shortcut",
szFolder,
"",
"",
0,
"",
NULL);
Labels (1)
0 Kudos
(6) Replies
Not applicable

Remove "MyApp" from your code:

AddFolderIcon(
FOLDER_DESKTOP,
"Reports Shortcut",
szFolder,
"",
"",
0,
"",
NULL);
0 Kudos
pfsjmiller
Level 3

How will that put the shortcut in a desktop folder?

In my install I need to create a folder named "MyApp" on the desktop. Inside this folder I want a shortcut to another folder named "Reports".
0 Kudos
MSIYER
Level 8

szProgramFolder = FOLDER_DESKTOP ^ "MyApp";
szCommandLine = TARGETDIR^"Reports";
szItemName = "Reports Shortcut";
szWorkingDir = TARGETDIR^"Reports";
szIconPath = WINDIR^"system32\\SHELL32.dll";
nIcon = 4;
szShortCutKey = "";
nFlag = REPLACE|RUN_MAXIMIZED; //can be anything according to your wish
nResult = AddFolderIcon (szProgramFolder, szItemName, szCommandLine,
szWorkingDir, szIconPath, nIcon,
szShortCutKey, nFlag);

I avoided LongPathToQuote(szFolder,TRUE) and it still worked.Try with that too...

Hope this helps...
0 Kudos
MSIYER
Level 8

Have you resolved the issue?
0 Kudos
pfsjmiller
Level 3

No it has not. It creates a shortcut and it looks like a folder shortcut, but when I double-click it is actually looking for a program. When I go to the Properties of the shortcut the Target Type is still 'File'.

Is I manually create a shortcut to that folder, the Target Type is 'File folder'.
0 Kudos
MSIYER
Level 8

I will surely look further into this issue. Initial tests were working on my side. That was the reason for me posting the snippet.
0 Kudos