Desktop Bridge向けWin32アプリのショートカットを生成するには

Create a shortcut file for Desktop Bridge Win32 App
Windowsデスクトップアプリにおいて、自身のショートカットリンクを作成するにはIWshShortcutを使いますが、ストアアプリとしてパッケージングしたDesktop Bridgeアプリでは、アクセス制限のため、exeファイルへのショートカットの実行は拒否されてしまいます。

そのため、ストアアプリへのショートカットリンクは「shell:Appsfolder + アプリID」で指定することになります。
shortcut.cs
[ComImport, TypeLibType((short)0x1040), Guid("F935DC23-1CF0-11D0-ADB9-00C04FD58A0B")]
public interface IWshShortcut
{
	[DispId(0)]
	string FullName { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0)] get; }
	[DispId(0x3e8)]
	string Arguments { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e8)] set; }
	[DispId(0x3e9)]
	string Description { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3e9)] set; }
	[DispId(0x3ea)]
	string Hotkey { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ea)] set; }
	[DispId(0x3eb)]
	string IconLocation { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3eb)] set; }
	[DispId(0x3ec)]
	string RelativePath { [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ec)] set; }
	[DispId(0x3ed)]
	string TargetPath { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ed)] set; }
	[DispId(0x3ee)]
	int WindowStyle { [DispId(0x3ee)] get; [param: In] [DispId(0x3ee)] set; }
	[DispId(0x3ef)]
	string WorkingDirectory { [return: MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] get; [param: In, MarshalAs(UnmanagedType.BStr)] [DispId(0x3ef)] set; }
	[TypeLibFunc((short)0x40), DispId(0x7d0)]
	void Load([In, MarshalAs(UnmanagedType.BStr)] string PathLink);
	[DispId(0x7d1)]
	void Save();
}
public static void Create(string destPath, string targetPath, string arguments, string iconPath = null)
{
	IWshShortcut shortcut = (IWshShortcut)m_type.InvokeMember("CreateShortcut", System.Reflection.BindingFlags.InvokeMethod, null, m_shell, new object[] { destPath });
	shortcut.TargetPath = targetPath;
	shortcut.Arguments = arguments;
	shortcut.IconLocation = (iconPath == null) ? App.ExecutablePath : iconPath;
	shortcut.Save();
}

public static async void CreateForExe(string arg)
{
	var applist = await Package.Current.GetAppListEntriesAsync();
	string target_path = "shell:Appsfolder\\" + applist[0].AppUserModelId;

	Shortcut.Create(sdlg.FileName, target_path, arg);
}
2021/03/04