Skip to content

Add FlagsToEnable property to JumpTask to allow JumpList to set the SHELL_LINK_DATA_FLAGS enumeration on the shell link #996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ internal static class IID
public const string ShellFolder = "000214E6-0000-0000-C000-000000000046";
/// <summary>IID_IShellLink</summary>
public const string ShellLink = "000214F9-0000-0000-C000-000000000046";
/// <summary>IID_IShellLinkDataList</summary>
public const string ShellLinkDataList = "45E2B4AE-B1C3-11D0-B92F-00A0C90312E1";
/// <summary>IID_IShellItem</summary>
public const string ShellItem = "43826d1e-e718-42ee-bc55-a1e261c37bfe";
/// <summary>IID_IShellItem2</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,30 @@ internal interface IShellLinkW
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}

/// <SecurityNote>
/// Critical: Suppresses unmanaged code security.
/// </SecurityNote>
[SecurityCritical(SecurityCriticalScope.Everything), SuppressUnmanagedCodeSecurity]
[
ComImport,
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown),
Guid(IID.ShellLinkDataList),
]
internal interface IShellLinkDataList
{
[PreserveSig]
Int32 AddDataBlock(IntPtr pDataBlock);

[PreserveSig]
Int32 CopyDataBlock(uint dwSig, out IntPtr ppDataBlock);

[PreserveSig]
Int32 RemoveDataBlock(uint dwSig);

void GetFlags(out uint pdwFlags);
void SetFlags(uint dwFlags);
}

/// <SecurityNote>
/// Critical: Suppresses unmanaged code security.
/// </SecurityNote>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,17 @@ private static IShellLinkW CreateLinkFromJumpTask(JumpTask jumpTask, bool allowS
link.SetDescription(jumpTask.Description);
}

if (jumpTask.FlagsToEnable != null)
{
var shellLinkDataList = (IShellLinkDataList)link;
shellLinkDataList.GetFlags(out uint flags);
foreach (uint flagToEnable in jumpTask.FlagsToEnable)
{
flags |= flagToEnable;
}
shellLinkDataList.SetFlags(flags);
}

IPropertyStore propStore = (IPropertyStore)link;
var pv = new PROPVARIANT();
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@ public JumpTask() : base()
public string IconResourcePath { get; set; }

public int IconResourceIndex { get; set; }

/// <summary>
/// Shell link data flags to enable. For more details see the SHELL_LINK_DATA_FLAGS documentation
/// https://docs.microsoft.com/windows/desktop/api/shlobj_core/ne-shlobj_core-shell_link_data_flags
/// </summary>
public int[] FlagsToEnable { get; set; }
}
}