├── .gitignore ├── JumpListExplorer.sln ├── JumpListExplorer ├── GlobalSuppressions.cs ├── Interop │ ├── BHID.cs │ ├── ComError.cs │ ├── DROPEFFECT.cs │ ├── GETPROPERTYSTOREFLAGS.cs │ ├── HRESULT.cs │ ├── HRESULTS.cs │ ├── IEnumShellItems.cs │ ├── IFileSystemBindData2.cs │ ├── IImageList.cs │ ├── IParentAndItem.cs │ ├── IPersist.cs │ ├── IPropertyBag.cs │ ├── IPropertyStore.cs │ ├── IShellItem.cs │ ├── IShellItem2.cs │ ├── KNOWNFOLDERID.cs │ ├── KNOWN_FOLDER_FLAG.cs │ ├── Native.cs │ ├── PROPERTYKEY.cs │ ├── PROPVARIANT.cs │ ├── SFGAO.cs │ ├── SHCONTF.cs │ ├── SHIL.cs │ ├── SICHINTF.cs │ ├── SIGDN.cs │ ├── VARTYPE.cs │ └── WIN32_FIND_DATAW.cs ├── JumpListExplorer.csproj ├── JumpListExplorer.ico ├── Main.Designer.cs ├── Main.cs ├── Main.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ └── AssemblyVersionInfo.cs ├── Resources.Designer.cs ├── Resources.resx ├── Shell │ ├── AutomaticDestinationList.cs │ ├── Folder.cs │ └── Item.cs └── Utilities │ ├── AssemblyUtilities.cs │ ├── Conversions.cs │ ├── Extensions.cs │ ├── IconUtilities.cs │ ├── WindowsUtilities.cs │ └── WinformsUtilities.cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.tlog 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.) 298 | *.vbp 299 | 300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project) 301 | *.dsw 302 | *.dsp 303 | 304 | # Visual Studio 6 technical files 305 | *.ncb 306 | *.aps 307 | 308 | # Visual Studio LightSwitch build output 309 | **/*.HTMLClient/GeneratedArtifacts 310 | **/*.DesktopClient/GeneratedArtifacts 311 | **/*.DesktopClient/ModelManifest.xml 312 | **/*.Server/GeneratedArtifacts 313 | **/*.Server/ModelManifest.xml 314 | _Pvt_Extensions 315 | 316 | # Paket dependency manager 317 | .paket/paket.exe 318 | paket-files/ 319 | 320 | # FAKE - F# Make 321 | .fake/ 322 | 323 | # CodeRush personal settings 324 | .cr/personal 325 | 326 | # Python Tools for Visual Studio (PTVS) 327 | __pycache__/ 328 | *.pyc 329 | 330 | # Cake - Uncomment if you are using it 331 | # tools/** 332 | # !tools/packages.config 333 | 334 | # Tabs Studio 335 | *.tss 336 | 337 | # Telerik's JustMock configuration file 338 | *.jmconfig 339 | 340 | # BizTalk build output 341 | *.btp.cs 342 | *.btm.cs 343 | *.odx.cs 344 | *.xsd.cs 345 | 346 | # OpenCover UI analysis results 347 | OpenCover/ 348 | 349 | # Azure Stream Analytics local run output 350 | ASALocalRun/ 351 | 352 | # MSBuild Binary and Structured Log 353 | *.binlog 354 | 355 | # NVidia Nsight GPU debugger configuration file 356 | *.nvuser 357 | 358 | # MFractors (Xamarin productivity tool) working folder 359 | .mfractor/ 360 | 361 | # Local History for Visual Studio 362 | .localhistory/ 363 | 364 | # Visual Studio History (VSHistory) files 365 | .vshistory/ 366 | 367 | # BeatPulse healthcheck temp database 368 | healthchecksdb 369 | 370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 371 | MigrationBackup/ 372 | 373 | # Ionide (cross platform F# VS Code tools) working folder 374 | .ionide/ 375 | 376 | # Fody - auto-generated XML schema 377 | FodyWeavers.xsd 378 | 379 | # VS Code files for those working on multiple tools 380 | .vscode/* 381 | !.vscode/settings.json 382 | !.vscode/tasks.json 383 | !.vscode/launch.json 384 | !.vscode/extensions.json 385 | *.code-workspace 386 | 387 | # Local History for Visual Studio Code 388 | .history/ 389 | 390 | # Windows Installer files from build outputs 391 | *.cab 392 | *.msi 393 | *.msix 394 | *.msm 395 | *.msp 396 | 397 | # JetBrains Rider 398 | *.sln.iml 399 | -------------------------------------------------------------------------------- /JumpListExplorer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.8.34309.116 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JumpListExplorer", "JumpListExplorer\JumpListExplorer.csproj", "{6C4E69A1-1DBA-4D55-81CD-425274BD34C9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6C4E69A1-1DBA-4D55-81CD-425274BD34C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6C4E69A1-1DBA-4D55-81CD-425274BD34C9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6C4E69A1-1DBA-4D55-81CD-425274BD34C9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6C4E69A1-1DBA-4D55-81CD-425274BD34C9}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {DBDB3EEF-9985-4B2C-84EE-D0C97C9B4D32} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /JumpListExplorer/GlobalSuppressions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.CodeAnalysis; 2 | 3 | [assembly: SuppressMessage("Style", "IDE0066:Convert switch statement to expression", Justification = "Nope")] 4 | [assembly: SuppressMessage("Style", "IDE0270:Use coalesce expression", Justification = "No thanks")] 5 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/BHID.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | public static class BHID 6 | { 7 | public static readonly Guid BHID_AssociationArray = new("bea9ef17-82f1-4f60-9284-4f8db75c3be9"); 8 | public static readonly Guid BHID_DataObject = new("b8c0bd9f-ed24-455c-83e6-d5390c4fe8c4"); 9 | public static readonly Guid BHID_EnumAssocHandlers = new("b8ab0b9c-c2ec-4f7a-918d-314900e6280a"); 10 | public static readonly Guid BHID_EnumItems = new("94f60519-2850-4924-aa5a-d15e84868039"); 11 | public static readonly Guid BHID_FilePlaceholder = new("8677dceb-aae0-4005-8d3d-547fa852f825"); 12 | public static readonly Guid BHID_Filter = new("38d08778-f557-4690-9ebf-ba54706ad8f7"); 13 | public static readonly Guid BHID_LinkTargetItem = new("3981e228-f559-11d3-8e3a-00c04f6837d5"); 14 | public static readonly Guid BHID_PropertyStore = new("0384e1a4-1523-439c-a4c8-ab911052f586"); 15 | public static readonly Guid BHID_RandomAccessStream = new("f16fc93b-77ae-4cfe-bda7-a866eea6878d"); 16 | public static readonly Guid BHID_SFObject = new("3981e224-f559-11d3-8e3a-00c04f6837d5"); 17 | public static readonly Guid BHID_SFUIObject = new("3981e225-f559-11d3-8e3a-00c04f6837d5"); 18 | public static readonly Guid BHID_SFViewObject = new("3981e226-f559-11d3-8e3a-00c04f6837d5"); 19 | public static readonly Guid BHID_Storage = new("3981e227-f559-11d3-8e3a-00c04f6837d5"); 20 | public static readonly Guid BHID_StorageEnum = new("4621a4e3-f0d6-4773-8a9c-46e77b174840"); 21 | public static readonly Guid BHID_StorageItem = new("404e2109-77d2-4699-a5a0-4fdf10db9837"); 22 | public static readonly Guid BHID_Stream = new("1cebb3ab-7c10-499a-a417-92ca16c4cb83"); 23 | public static readonly Guid BHID_ThumbnailHandler = new("7b2e650a-8e20-4f4a-b09e-6597afc72fb0"); 24 | public static readonly Guid BHID_Transfer = new("d5e346a1-f753-4932-b403-4574800e2498"); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/ComError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | namespace JumpListExplorer.Interop 6 | { 7 | public static class ComError 8 | { 9 | public static void SetError(string description, [CallerMemberName] string? source = null) 10 | { 11 | ArgumentNullException.ThrowIfNull(description); 12 | 13 | CreateErrorInfo(out var info).ThrowOnError(); 14 | info.SetDescription(description).ThrowOnError(); 15 | 16 | if (source != null) 17 | { 18 | info.SetSource(source).ThrowOnError(); 19 | } 20 | 21 | var ei = (IErrorInfo)info; 22 | SetErrorInfo(0, ei).ThrowOnError(); 23 | } 24 | 25 | public static Exception? GetError() 26 | { 27 | GetErrorInfo(0, out var info); 28 | if (info == null) 29 | return null; 30 | 31 | COMException error; 32 | info.GetDescription(out var description); 33 | info.GetSource(out var source); 34 | if (!string.IsNullOrWhiteSpace(source)) 35 | { 36 | if (description == null) 37 | { 38 | description = source; 39 | } 40 | else 41 | { 42 | description = source + ": " + description; 43 | } 44 | } 45 | 46 | if (string.IsNullOrWhiteSpace(description)) 47 | { 48 | error = new COMException(); 49 | } 50 | else 51 | { 52 | error = new COMException(description); 53 | } 54 | 55 | info.GetHelpFile(out var help); 56 | if (!string.IsNullOrWhiteSpace(help)) 57 | { 58 | error.HelpLink = help; 59 | } 60 | return error; 61 | } 62 | 63 | [ComImport, Guid("22F03340-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 64 | private interface ICreateErrorInfo 65 | { 66 | [PreserveSig] 67 | HRESULT SetGUID([MarshalAs(UnmanagedType.LPStruct)] Guid rguid); 68 | 69 | [PreserveSig] 70 | HRESULT SetSource([MarshalAs(UnmanagedType.LPWStr)] string szSource); 71 | 72 | [PreserveSig] 73 | HRESULT SetDescription([MarshalAs(UnmanagedType.LPWStr)] string szDescription); 74 | 75 | [PreserveSig] 76 | HRESULT SetHelpFile([MarshalAs(UnmanagedType.LPWStr)] string szHelpFile); 77 | 78 | [PreserveSig] 79 | HRESULT SetHelpContext(int dwHelpContext); 80 | } 81 | 82 | [ComImport, Guid("1CF2B120-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 83 | private interface IErrorInfo 84 | { 85 | [PreserveSig] 86 | HRESULT GetGUID(out Guid pguid); 87 | 88 | [PreserveSig] 89 | HRESULT GetSource([MarshalAs(UnmanagedType.BStr)] out string pBstrSource); 90 | 91 | [PreserveSig] 92 | HRESULT GetDescription([MarshalAs(UnmanagedType.BStr)] out string pBstrDescription); 93 | 94 | [PreserveSig] 95 | HRESULT GetHelpFile([MarshalAs(UnmanagedType.BStr)] out string pBstrHelpFile); 96 | 97 | [PreserveSig] 98 | HRESULT GetHelpContext(out int pdwHelpContext); 99 | } 100 | 101 | [DllImport("oleaut32")] 102 | private static extern HRESULT GetErrorInfo(int dwReserved, out IErrorInfo perrinfo); 103 | 104 | [DllImport("oleaut32")] 105 | private static extern HRESULT SetErrorInfo(int dwReserved, IErrorInfo perrinfo); 106 | 107 | [DllImport("oleaut32")] 108 | private static extern HRESULT CreateErrorInfo(out ICreateErrorInfo errInfo); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/DROPEFFECT.cs: -------------------------------------------------------------------------------- 1 | namespace JumpListExplorer.Interop 2 | { 3 | public enum DROPEFFECT 4 | { 5 | DROPEFFECT_NONE = 0, 6 | DROPEFFECT_COPY = 1, 7 | DROPEFFECT_MOVE = 2, 8 | DROPEFFECT_LINK = 4, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/GETPROPERTYSTOREFLAGS.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | [Flags] 6 | public enum GETPROPERTYSTOREFLAGS : uint 7 | { 8 | GPS_DEFAULT = 0, 9 | GPS_HANDLERPROPERTIESONLY = 0x1, 10 | GPS_READWRITE = 0x2, 11 | GPS_TEMPORARY = 0x4, 12 | GPS_FASTPROPERTIESONLY = 0x8, 13 | GPS_OPENSLOWITEM = 0x10, 14 | GPS_DELAYCREATION = 0x20, 15 | GPS_BESTEFFORT = 0x40, 16 | GPS_NO_OPLOCK = 0x80, 17 | GPS_PREFERQUERYPROPERTIES = 0x100, 18 | GPS_EXTRINSICPROPERTIES = 0x200, 19 | GPS_EXTRINSICPROPERTIESONLY = 0x400, 20 | GPS_VOLATILEPROPERTIES = 0x800, 21 | GPS_VOLATILEPROPERTIESONLY = 0x1000, 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/HRESULT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.ComponentModel; 4 | using System.Globalization; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.InteropServices; 9 | 10 | namespace JumpListExplorer.Interop 11 | { 12 | [StructLayout(LayoutKind.Sequential)] 13 | internal readonly struct HRESULT : IEquatable, IFormattable 14 | { 15 | private static readonly ConcurrentDictionary _names = new(); 16 | 17 | public HRESULT(uint value) 18 | { 19 | Value = value; 20 | } 21 | 22 | public HRESULT(int value) 23 | { 24 | Value = (uint)value; 25 | } 26 | 27 | public HRESULT(HRESULTS value) 28 | : this((uint)value) 29 | { 30 | } 31 | 32 | public uint Value { get; } 33 | public int IValue => (int)Value; 34 | public readonly string Name => ToString("n", null); 35 | public readonly bool IsError => Value < 0; 36 | public readonly bool IsSuccess => Value >= 0; 37 | public readonly bool IsOk => Value == (int)HRESULTS.S_OK; 38 | public readonly bool IsFalse => Value == (int)HRESULTS.S_FALSE; 39 | 40 | public uint ThrowOnError(bool throwOnError = true) 41 | { 42 | if (!throwOnError || Value == 0) 43 | return Value; 44 | 45 | if (Value == (uint)HRESULTS.DISP_E_EXCEPTION) 46 | { 47 | var error = ComError.GetError(); 48 | if (error != null) 49 | throw error; 50 | } 51 | 52 | if (Value == (uint)HRESULTS.STG_E_FILENOTFOUND) 53 | throw new FileNotFoundException(); 54 | 55 | if (Value == (uint)HRESULTS.STG_E_PATHNOTFOUND) 56 | throw new DirectoryNotFoundException(); 57 | 58 | if (Value < 0) 59 | throw new Win32Exception((int)Value); 60 | 61 | return Value; 62 | } 63 | 64 | public readonly HRESULT ToHRESULT() => new(Value); 65 | public readonly int ToInt32() => (int)Value; 66 | public readonly uint ToUInt32() => Value; 67 | public readonly HRESULTS ToHRESULTS() => (HRESULTS)Value; 68 | 69 | public override readonly bool Equals(object? obj) => Value.Equals(obj); 70 | public override readonly int GetHashCode() => Value.GetHashCode(); 71 | public readonly bool Equals(HRESULT other) => Value.Equals(other.Value); 72 | 73 | public override readonly string ToString() => ToString(null, null); 74 | public readonly string ToString(string? format, IFormatProvider? formatProvider) 75 | { 76 | switch (format?.ToUpperInvariant()) 77 | { 78 | case "I": 79 | return Value.ToString(CultureInfo.InvariantCulture); 80 | 81 | case "N": 82 | if (!_names.TryGetValue(Value, out var text)) 83 | { 84 | var value = Value; 85 | text = typeof(HRESULTS).GetFields(BindingFlags.Static | BindingFlags.Public).FirstOrDefault(f => (int)(HRESULTS)f.GetValue(null)! == value)?.Name; 86 | _names[Value] = text; 87 | } 88 | return text ?? string.Empty; 89 | 90 | case "U": 91 | return Value.ToString(CultureInfo.InvariantCulture); 92 | 93 | case "X": 94 | return "0x" + Value.ToString("X8", CultureInfo.InvariantCulture); 95 | 96 | default: 97 | var name = ToString("n", formatProvider); 98 | if (name != null) 99 | return name + " (0x" + Value.ToString("X8", CultureInfo.InvariantCulture) + ")"; 100 | 101 | return "0x" + Value.ToString("X8", CultureInfo.InvariantCulture); 102 | } 103 | } 104 | 105 | public static bool operator ==(HRESULT left, HRESULT right) => left.Value == right.Value; 106 | public static bool operator !=(HRESULT left, HRESULT right) => left.Value != right.Value; 107 | public static implicit operator HRESULT(int value) => new(value); 108 | public static implicit operator HRESULT(uint result) => new(result); 109 | public static implicit operator HRESULT(HRESULTS result) => new(result); 110 | public static explicit operator uint(HRESULT hr) => hr.Value; 111 | public static explicit operator int(HRESULT hr) => hr.IValue; 112 | public static explicit operator HRESULTS(HRESULT hr) => (HRESULTS)hr.Value; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/HRESULTS.cs: -------------------------------------------------------------------------------- 1 | namespace JumpListExplorer.Interop 2 | { 3 | public enum HRESULTS : uint 4 | { 5 | S_OK = 0, 6 | S_FALSE = 1, 7 | E_FAIL = 0x80004005, 8 | E_NOINTERFACE = 0x80004002, 9 | E_INVALIDARG = 0x80070057, 10 | E_ACCESSDENIED = 0x80070005, 11 | E_NOTIMPL = 0x80004001, 12 | E_UNEXPECTED = 0x8000FFFF, 13 | DISP_E_EXCEPTION = 0x80020009, 14 | STG_E_FILENOTFOUND = 0x80030002, 15 | STG_E_PATHNOTFOUND = 0x80030003, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IEnumShellItems.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("70629033-e363-4a28-a567-0db78006e6d7"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IEnumShellItems 8 | { 9 | [PreserveSig] 10 | HRESULT Next(int celt, out IShellItem rgelt, out int pceltFetched); 11 | 12 | [PreserveSig] 13 | HRESULT Skip(int celt); 14 | 15 | [PreserveSig] 16 | HRESULT Reset(); 17 | 18 | [PreserveSig] 19 | HRESULT Clone(out IEnumShellItems ppenum); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IFileSystemBindData2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("3acf075f-71db-4afa-81f0-3fc4fdf2a5b8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IFileSystemBindData2 8 | { 9 | void SetFindData(ref WIN32_FIND_DATAW pfd); 10 | void GetFindData(out WIN32_FIND_DATAW pfd); 11 | void SetFileID(long liFileID); 12 | void GetFileID(out long pliFileID); 13 | void SetJunctionCLSID([MarshalAs(UnmanagedType.LPStruct)] Guid clsid); 14 | void GetJunctionCLSID(out Guid pclsid); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IImageList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("46eb5926-582e-4017-9fdf-e8998daa0950"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IImageList 8 | { 9 | #pragma warning disable IDE1006 // Naming Styles 10 | void _VtblGap1_7(); // skip 7 methods we don't need 11 | #pragma warning restore IDE1006 // Naming Styles 12 | 13 | [PreserveSig] 14 | int GetIcon(int i, int flags, out IntPtr picon); 15 | 16 | // the rest is undefined 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IParentAndItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("b3a4b685-b685-4805-99d9-5dead2873236"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IParentAndItem 8 | { 9 | #pragma warning disable IDE1006 // Naming Styles 10 | void _VtblGap1_1(); // skip 1 methods we don't need 11 | #pragma warning restore IDE1006 // Naming Styles 12 | 13 | [PreserveSig] 14 | int GetParentAndItem(IntPtr ppidlParent, out IntPtr ppsf, out IntPtr ppidlChild); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IPersist.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("0000010c-0000-0000-c000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IPersist 8 | { 9 | [PreserveSig] 10 | HRESULT GetClassID(out Guid pClassID); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IPropertyBag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("55272A00-42CB-11CE-8135-00AA004BB851"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal interface IPropertyBag 8 | { 9 | [PreserveSig] 10 | HRESULT Read([MarshalAs(UnmanagedType.LPWStr)] string pszPropName, out object pVar, IntPtr pErrorLog); 11 | 12 | [PreserveSig] 13 | HRESULT Write([MarshalAs(UnmanagedType.LPWStr)] string gpszPropName, ref object pVar); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IPropertyStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [ComImport, Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 7 | internal partial interface IPropertyStore 8 | { 9 | [PreserveSig] 10 | HRESULT GetCount(out int cProps); 11 | 12 | [PreserveSig] 13 | HRESULT GetAt(int iProp, out PROPERTYKEY pkey); 14 | 15 | [PreserveSig] 16 | HRESULT GetValue(ref PROPERTYKEY key, [Out] PROPVARIANT pv); 17 | 18 | [PreserveSig] 19 | HRESULT SetValue(ref PROPERTYKEY key, PROPVARIANT propvar); 20 | 21 | [PreserveSig] 22 | HRESULT Commit(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IShellItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.InteropServices.ComTypes; 4 | 5 | namespace JumpListExplorer.Interop 6 | { 7 | [ComImport, Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 8 | internal interface IShellItem 9 | { 10 | [PreserveSig] 11 | HRESULT BindToHandler(IBindCtx? pbc, [MarshalAs(UnmanagedType.LPStruct)] Guid bhid, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 12 | 13 | [PreserveSig] 14 | HRESULT GetParent(out IShellItem ppsi); 15 | 16 | [PreserveSig] 17 | HRESULT GetDisplayName(SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName); 18 | 19 | [PreserveSig] 20 | HRESULT GetAttributes(SFGAO sfgaoMask, out SFGAO psfgaoAttribs); 21 | 22 | [PreserveSig] 23 | HRESULT Compare(IShellItem psi, SICHINTF hint, out int piOrder); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/IShellItem2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.InteropServices.ComTypes; 4 | 5 | namespace JumpListExplorer.Interop 6 | { 7 | [ComImport, Guid("7e9fb0d3-919f-4307-ab2e-9b1860310c93"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 8 | internal interface IShellItem2 : IShellItem 9 | { 10 | // IShellItem 11 | [PreserveSig] 12 | new HRESULT BindToHandler(IBindCtx pbc, [MarshalAs(UnmanagedType.LPStruct)] Guid bhid, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 13 | 14 | [PreserveSig] 15 | new HRESULT GetParent(out IShellItem ppsi); 16 | 17 | [PreserveSig] 18 | new HRESULT GetDisplayName(SIGDN sigdnName, [MarshalAs(UnmanagedType.LPWStr)] out string ppszName); 19 | 20 | [PreserveSig] 21 | new HRESULT GetAttributes(SFGAO sfgaoMask, out SFGAO psfgaoAttribs); 22 | 23 | [PreserveSig] 24 | new HRESULT Compare(IShellItem psi, SICHINTF hint, out int piOrder); 25 | 26 | // IShellItem2 27 | [PreserveSig] 28 | HRESULT GetPropertyStore(GETPROPERTYSTOREFLAGS flags, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 29 | 30 | [PreserveSig] 31 | HRESULT GetPropertyStoreWithCreateObject(GETPROPERTYSTOREFLAGS flags, [MarshalAs(UnmanagedType.IUnknown)] object punkCreateObject, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 32 | 33 | [PreserveSig] 34 | HRESULT GetPropertyStoreForKeys([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PROPERTYKEY[] rgKeys, int cKeys, GETPROPERTYSTOREFLAGS flags, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 35 | 36 | [PreserveSig] 37 | HRESULT GetPropertyDescriptionList(ref PROPERTYKEY keyType, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 38 | 39 | [PreserveSig] 40 | HRESULT Update(IBindCtx pbc); 41 | 42 | [PreserveSig] 43 | HRESULT GetProperty(ref PROPERTYKEY key, [In, Out] PROPVARIANT ppropvar); 44 | 45 | [PreserveSig] 46 | HRESULT GetCLSID(ref PROPERTYKEY key, out Guid pclsid); 47 | 48 | [PreserveSig] 49 | HRESULT GetFileTime(ref PROPERTYKEY key, out long pft); 50 | 51 | [PreserveSig] 52 | HRESULT GetInt32(ref PROPERTYKEY key, out int pi); 53 | 54 | [PreserveSig] 55 | HRESULT GetString(ref PROPERTYKEY key, out IntPtr ppsz); 56 | 57 | [PreserveSig] 58 | HRESULT GetUInt32(ref PROPERTYKEY key, out uint pui); 59 | 60 | [PreserveSig] 61 | HRESULT GetUInt64(ref PROPERTYKEY key, out ulong pull); 62 | 63 | [PreserveSig] 64 | HRESULT GetBool(ref PROPERTYKEY key, out bool pf); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/KNOWNFOLDERID.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | public static class KNOWNFOLDERID 6 | { 7 | public static readonly Guid FOLDERID_AccountPictures = new("008ca0b1-55b4-4c56-b8a8-4de4b299d3be"); 8 | public static readonly Guid FOLDERID_AddNewPrograms = new("de61d971-5ebc-4f02-a3a9-6c82895e5c04"); 9 | public static readonly Guid FOLDERID_AdminTools = new("724ef170-a42d-4fef-9f26-b60e846fba4f"); 10 | public static readonly Guid FOLDERID_AppDataDesktop = new("b2c5e279-7add-439f-b28c-c41fe1bbf672"); 11 | public static readonly Guid FOLDERID_AppDataDocuments = new("7be16610-1f7f-44ac-bff0-83e15f2ffca1"); 12 | public static readonly Guid FOLDERID_AppDataFavorites = new("7cfbefbc-de1f-45aa-b843-a542ac536cc9"); 13 | public static readonly Guid FOLDERID_AppDataProgramData = new("559d40a3-a036-40fa-af61-84cb430a4d34"); 14 | public static readonly Guid FOLDERID_ApplicationShortcuts = new("a3918781-e5f2-4890-b3d9-a7e54332328c"); 15 | public static readonly Guid FOLDERID_AppsFolder = new("1e87508d-89c2-42f0-8a7e-645a0f50ca58"); 16 | public static readonly Guid FOLDERID_AppUpdates = new("a305ce99-f527-492b-8b1a-7e76fa98d6e4"); 17 | public static readonly Guid FOLDERID_CameraRoll = new("ab5fb87b-7ce2-4f83-915d-550846c9537b"); 18 | public static readonly Guid FOLDERID_CDBurning = new("9e52ab10-f80d-49df-acb8-4330f5687855"); 19 | public static readonly Guid FOLDERID_ChangeRemovePrograms = new("df7266ac-9274-4867-8d55-3bd661de872d"); 20 | public static readonly Guid FOLDERID_CommonAdminTools = new("d0384e7d-bac3-4797-8f14-cba229b392b5"); 21 | public static readonly Guid FOLDERID_CommonOEMLinks = new("c1bae2d0-10df-4334-bedd-7aa20b227a9d"); 22 | public static readonly Guid FOLDERID_CommonPrograms = new("0139d44e-6afe-49f2-8690-3dafcae6ffb8"); 23 | public static readonly Guid FOLDERID_CommonStartMenu = new("a4115719-d62e-491d-aa7c-e74b8be3b067"); 24 | public static readonly Guid FOLDERID_CommonStartup = new("82a5ea35-d9cd-47c5-9629-e15d2f714e6e"); 25 | public static readonly Guid FOLDERID_CommonTemplates = new("b94237e7-57ac-4347-9151-b08c6c32d1f7"); 26 | public static readonly Guid FOLDERID_ComputerFolder = new("0ac0837c-bbf8-452a-850d-79d08e667ca7"); 27 | public static readonly Guid FOLDERID_ConflictFolder = new("4bfefb45-347d-4006-a5be-ac0cb0567192"); 28 | public static readonly Guid FOLDERID_ConnectionsFolder = new("6f0cd92b-2e97-45d1-88ff-b0d186b8dedd"); 29 | public static readonly Guid FOLDERID_Contacts = new("56784854-c6cb-462b-8169-88e350acb882"); 30 | public static readonly Guid FOLDERID_ControlPanelFolder = new("82a74aeb-aeb4-465c-a014-d097ee346d63"); 31 | public static readonly Guid FOLDERID_Cookies = new("2b0f765d-c0e9-4171-908e-08a611b84ff6"); 32 | public static readonly Guid FOLDERID_Desktop = new("b4bfcc3a-db2c-424c-b029-7fe99a87c641"); 33 | public static readonly Guid FOLDERID_Device = new("1c2ac1dc-4358-4b6c-9733-af21156576f0"); 34 | public static readonly Guid FOLDERID_DeviceMetadataStore = new("5ce4a5e9-e4eb-479d-b89f-130c02886155"); 35 | public static readonly Guid FOLDERID_Documents = new("fdd39ad0-238f-46af-adb4-6c85480369c7"); 36 | public static readonly Guid FOLDERID_DocumentsLibrary = new("7b0db17d-9cd2-4a93-9733-46cc89022e7c"); 37 | public static readonly Guid FOLDERID_Downloads = new("374de290-123f-4565-9164-39c4925e467b"); 38 | public static readonly Guid FOLDERID_Favorites = new("1777f761-68ad-4d8a-87bd-30b759fa33dd"); 39 | public static readonly Guid FOLDERID_Fonts = new("fd228cb7-ae11-4ae3-864c-16f3910ab8fe"); 40 | public static readonly Guid FOLDERID_Games = new("cac52c1a-b53d-4edc-92d7-6b2e8ac19434"); 41 | public static readonly Guid FOLDERID_GameTasks = new("054fae61-4dd8-4787-80b6-090220c4b700"); 42 | public static readonly Guid FOLDERID_History = new("d9dc8a3b-b784-432e-a781-5a1130a75963"); 43 | public static readonly Guid FOLDERID_HomeGroup = new("52528a6b-b9e3-4add-b60d-588c2dba842d"); 44 | public static readonly Guid FOLDERID_HomeGroupCurrentUser = new("9b74b6a3-0dfd-4f11-9e78-5f7800f2e772"); 45 | public static readonly Guid FOLDERID_ImplicitAppShortcuts = new("bcb5256f-79f6-4cee-b725-dc34e402fd46"); 46 | public static readonly Guid FOLDERID_InternetCache = new("352481e8-33be-4251-ba85-6007caedcf9d"); 47 | public static readonly Guid FOLDERID_InternetFolder = new("4d9f7874-4e0c-4904-967b-40b0d20c3e4b"); 48 | public static readonly Guid FOLDERID_Libraries = new("1b3ea5dc-b587-4786-b4ef-bd1dc332aeae"); 49 | public static readonly Guid FOLDERID_Links = new("bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968"); 50 | public static readonly Guid FOLDERID_LocalAppData = new("f1b32785-6fba-4fcf-9d55-7b8e7f157091"); 51 | public static readonly Guid FOLDERID_LocalAppDataLow = new("a520a1a4-1780-4ff6-bd18-167343c5af16"); 52 | public static readonly Guid FOLDERID_LocalizedResourcesDir = new("2a00375e-224c-49de-b8d1-440df7ef3ddc"); 53 | public static readonly Guid FOLDERID_Music = new("4bd8d571-6d19-48d3-be97-422220080e43"); 54 | public static readonly Guid FOLDERID_MusicLibrary = new("2112ab0a-c86a-4ffe-a368-0de96e47012e"); 55 | public static readonly Guid FOLDERID_NetHood = new("c5abbf53-e17f-4121-8900-86626fc2c973"); 56 | public static readonly Guid FOLDERID_NetworkFolder = new("d20beec4-5ca8-4905-ae3b-bf251ea09b53"); 57 | public static readonly Guid FOLDERID_Objects3D = new("31c0dd25-9439-4f12-bf41-7ff4eda38722"); 58 | public static readonly Guid FOLDERID_OneDrive = new("a52bba46-e9e1-435f-b3d9-28daa648c0f6"); 59 | public static readonly Guid FOLDERID_OriginalImages = new("2c36c0aa-5812-4b87-bfd0-4cd0dfb19b39"); 60 | public static readonly Guid FOLDERID_PhotoAlbums = new("69d2cf90-fc33-4fb7-9a0c-ebb0f0fcb43c"); 61 | public static readonly Guid FOLDERID_Pictures = new("33e28130-4e1e-4676-835a-98395c3bc3bb"); 62 | public static readonly Guid FOLDERID_PicturesLibrary = new("a990ae9f-a03b-4e80-94bc-9912d7504104"); 63 | public static readonly Guid FOLDERID_Playlists = new("de92c1c7-837f-4f69-a3bb-86e631204a23"); 64 | public static readonly Guid FOLDERID_PrintersFolder = new("76fc4e2d-d6ad-4519-a663-37bd56068185"); 65 | public static readonly Guid FOLDERID_PrintHood = new("9274bd8d-cfd1-41c3-b35e-b13f55a758f4"); 66 | public static readonly Guid FOLDERID_Profile = new("5e6c858f-0e22-4760-9afe-ea3317b67173"); 67 | public static readonly Guid FOLDERID_ProgramData = new("62ab5d82-fdc1-4dc3-a9dd-070d1d495d97"); 68 | public static readonly Guid FOLDERID_ProgramFiles = new("905e63b6-c1bf-494e-b29c-65b732d3d21a"); 69 | public static readonly Guid FOLDERID_ProgramFilesCommon = new("f7f1ed05-9f6d-47a2-aaae-29d317c6f066"); 70 | public static readonly Guid FOLDERID_ProgramFilesCommonX64 = new("6365d5a7-0f0d-45e5-87f6-0da56b6a4f7d"); 71 | public static readonly Guid FOLDERID_ProgramFilesCommonX86 = new("de974d24-d9c6-4d3e-bf91-f4455120b917"); 72 | public static readonly Guid FOLDERID_ProgramFilesX64 = new("6d809377-6af0-444b-8957-a3773f02200e"); 73 | public static readonly Guid FOLDERID_ProgramFilesX86 = new("7c5a40ef-a0fb-4bfc-874a-c0f2e0b9fa8e"); 74 | public static readonly Guid FOLDERID_Programs = new("a77f5d77-2e2b-44c3-a6a2-aba601054a51"); 75 | public static readonly Guid FOLDERID_Public = new("dfdf76a2-c82a-4d63-906a-5644ac457385"); 76 | public static readonly Guid FOLDERID_PublicDesktop = new("c4aa340d-f20f-4863-afef-f87ef2e6ba25"); 77 | public static readonly Guid FOLDERID_PublicDocuments = new("ed4824af-dce4-45a8-81e2-fc7965083634"); 78 | public static readonly Guid FOLDERID_PublicDownloads = new("3d644c9b-1fb8-4f30-9b45-f670235f79c0"); 79 | public static readonly Guid FOLDERID_PublicGameTasks = new("debf2536-e1a8-4c59-b6a2-414586476aea"); 80 | public static readonly Guid FOLDERID_PublicLibraries = new("48daf80b-e6cf-4f4e-b800-0e69d84ee384"); 81 | public static readonly Guid FOLDERID_PublicMusic = new("3214fab5-9757-4298-bb61-92a9deaa44ff"); 82 | public static readonly Guid FOLDERID_PublicPictures = new("b6ebfb86-6907-413c-9af7-4fc2abf07cc5"); 83 | public static readonly Guid FOLDERID_PublicUserTiles = new("0482af6c-08f1-4c34-8c90-e17ec98b1e17"); 84 | public static readonly Guid FOLDERID_PublicVideos = new("2400183a-6185-49fb-a2d8-4a392a602ba3"); 85 | public static readonly Guid FOLDERID_QuickLaunch = new("52a4f021-7b75-48a9-9f6b-4b87a210bc8f"); 86 | public static readonly Guid FOLDERID_Recent = new("ae50c081-ebd2-438a-8655-8a092e34987a"); 87 | public static readonly Guid FOLDERID_RecordedTVLibrary = new("1a6fdba2-f42d-4358-a798-b74d745926c5"); 88 | public static readonly Guid FOLDERID_RecycleBinFolder = new("b7534046-3ecb-4c18-be4e-64cd4cb7d6ac"); 89 | public static readonly Guid FOLDERID_ResourceDir = new("8ad10c31-2adb-4296-a8f7-e4701232c972"); 90 | public static readonly Guid FOLDERID_Ringtones = new("c870044b-f49e-4126-a9c3-b52a1ff411e8"); 91 | public static readonly Guid FOLDERID_RoamedTileImages = new("aaa8d5a5-f1d6-4259-baa8-78e7ef60835e"); 92 | public static readonly Guid FOLDERID_RoamingAppData = new("3eb685db-65f9-4cf6-a03a-e3ef65729f3d"); 93 | public static readonly Guid FOLDERID_RoamingTiles = new("00bcfc5a-ed94-4e48-96a1-3f6217f21990"); 94 | public static readonly Guid FOLDERID_SampleMusic = new("b250c668-f57d-4ee1-a63c-290ee7d1aa1f"); 95 | public static readonly Guid FOLDERID_SamplePictures = new("c4900540-2379-4c75-844b-64e6faf8716b"); 96 | public static readonly Guid FOLDERID_SamplePlaylists = new("15ca69b3-30ee-49c1-ace1-6b5ec372afb5"); 97 | public static readonly Guid FOLDERID_SampleVideos = new("859ead94-2e85-48ad-a71a-0969cb56a6cd"); 98 | public static readonly Guid FOLDERID_SavedGames = new("4c5c32ff-bb9d-43b0-b5b4-2d72e54eaaa4"); 99 | public static readonly Guid FOLDERID_SavedPictures = new("3b193882-d3ad-4eab-965a-69829d1fb59f"); 100 | public static readonly Guid FOLDERID_SavedPicturesLibrary = new("e25b5812-be88-4bd9-94b0-29233477b6c3"); 101 | public static readonly Guid FOLDERID_SavedSearches = new("7d1d3a04-debb-4115-95cf-2f29da2920da"); 102 | public static readonly Guid FOLDERID_Screenshots = new("b7bede81-df94-4682-a7d8-57a52620b86f"); 103 | public static readonly Guid FOLDERID_SEARCH_CSC = new("ee32e446-31ca-4aba-814f-a5ebd2fd6d5e"); 104 | public static readonly Guid FOLDERID_SEARCH_MAPI = new("98ec0e18-2098-4d44-8644-66979315a281"); 105 | public static readonly Guid FOLDERID_SearchHistory = new("0d4c3db6-03a3-462f-a0e6-08924c41b5d4"); 106 | public static readonly Guid FOLDERID_SearchHome = new("190337d1-b8ca-4121-a639-6d472d16972a"); 107 | public static readonly Guid FOLDERID_SearchTemplates = new("7e636bfe-dfa9-4d5e-b456-d7b39851d8a9"); 108 | public static readonly Guid FOLDERID_SendTo = new("8983036c-27c0-404b-8f08-102d10dcfd74"); 109 | public static readonly Guid FOLDERID_SidebarDefaultParts = new("7b396e54-9ec5-4300-be0a-2482ebae1a26"); 110 | public static readonly Guid FOLDERID_SidebarParts = new("a75d362e-50fc-4fb7-ac2c-a8beaa314493"); 111 | public static readonly Guid FOLDERID_SkyDrive = new("a52bba46-e9e1-435f-b3d9-28daa648c0f6"); 112 | public static readonly Guid FOLDERID_SkyDriveCameraRoll = new("767e6811-49cb-4273-87c2-20f355e1085b"); 113 | public static readonly Guid FOLDERID_SkyDriveDocuments = new("24d89e24-2f19-4534-9dde-6a6671fbb8fe"); 114 | public static readonly Guid FOLDERID_SkyDrivePictures = new("339719b5-8c47-4894-94c2-d8f77add44a6"); 115 | public static readonly Guid FOLDERID_StartMenu = new("625b53c3-ab48-4ec1-ba1f-a1ef4146fc19"); 116 | public static readonly Guid FOLDERID_Startup = new("b97d20bb-f46a-4c97-ba10-5e3608430854"); 117 | public static readonly Guid FOLDERID_SyncManagerFolder = new("43668bf8-c14e-49b2-97c9-747784d784b7"); 118 | public static readonly Guid FOLDERID_SyncResultsFolder = new("289a9a43-be44-4057-a41b-587a76d7e7f9"); 119 | public static readonly Guid FOLDERID_SyncSetupFolder = new("0f214138-b1d3-4a90-bba9-27cbc0c5389a"); 120 | public static readonly Guid FOLDERID_System = new("1ac14e77-02e7-4e5d-b744-2eb1ae5198b7"); 121 | public static readonly Guid FOLDERID_SystemX86 = new("d65231b0-b2f1-4857-a4ce-a8e7c6ea7d27"); 122 | public static readonly Guid FOLDERID_Templates = new("a63293e8-664e-48db-a079-df759e0509f7"); 123 | public static readonly Guid FOLDERID_UserPinned = new("9e3995ab-1f9c-4f13-b827-48b24b6c7174"); 124 | public static readonly Guid FOLDERID_UserProfiles = new("0762d272-c50a-4bb0-a382-697dcd729b80"); 125 | public static readonly Guid FOLDERID_UserProgramFiles = new("5cd7aee2-2219-4a67-b85d-6c9ce15660cb"); 126 | public static readonly Guid FOLDERID_UserProgramFilesCommon = new("bcbd3057-ca5c-4622-b42d-bc56db0ae516"); 127 | public static readonly Guid FOLDERID_UsersFiles = new("f3ce0f7c-4901-4acc-8648-d5d44b04ef8f"); 128 | public static readonly Guid FOLDERID_UsersLibraries = new("a302545d-deff-464b-abe8-61c8648d939b"); 129 | public static readonly Guid FOLDERID_Videos = new("18989b1d-99b5-455b-841c-ab7c74e4ddfc"); 130 | public static readonly Guid FOLDERID_VideosLibrary = new("491e922f-5643-4af4-a7eb-4e7a138d8174"); 131 | public static readonly Guid FOLDERID_Windows = new("f38bf404-1d43-42f2-9305-67de0b28fc23"); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/KNOWN_FOLDER_FLAG.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | [Flags] 6 | public enum KNOWN_FOLDER_FLAG : uint 7 | { 8 | KF_FLAG_DEFAULT = 0x00000000, 9 | KF_FLAG_FORCE_APP_DATA_REDIRECTION = 0x00080000, 10 | KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000, 11 | KF_FLAG_FORCE_PACKAGE_REDIRECTION = 0x00020000, 12 | KF_FLAG_NO_PACKAGE_REDIRECTION = 0x00010000, 13 | KF_FLAG_FORCE_APPCONTAINER_REDIRECTION = 0x00020000, 14 | KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000, 15 | KF_FLAG_CREATE = 0x00008000, 16 | KF_FLAG_DONT_VERIFY = 0x00004000, 17 | KF_FLAG_DONT_UNEXPAND = 0x00002000, 18 | KF_FLAG_NO_ALIAS = 0x00001000, 19 | KF_FLAG_INIT = 0x00000800, 20 | KF_FLAG_DEFAULT_PATH = 0x00000400, 21 | KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200, 22 | KF_FLAG_SIMPLE_IDLIST = 0x00000100, 23 | KF_FLAG_ALIAS_ONLY = 0x80000000, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/Native.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.InteropServices.ComTypes; 4 | 5 | namespace JumpListExplorer.Interop 6 | { 7 | internal static class Native 8 | { 9 | public static Guid IID_IUnknown = new Guid("00000000-0000-0000-c000-000000000046"); 10 | 11 | [DllImport("shell32")] 12 | public static extern HRESULT SHGetImageList(SHIL iImageList, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IImageList ppv); 13 | 14 | [DllImport("shell32")] 15 | public static extern int SHMapPIDLToSystemImageListIndex(IntPtr pshf, IntPtr pidl, out int piIndexSel); 16 | 17 | [DllImport("shell32")] 18 | public static extern HRESULT SHGetKnownFolderItem(Guid rfid, KNOWN_FOLDER_FLAG flags, IntPtr hToken, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv); 19 | 20 | [DllImport("shell32")] 21 | public static extern HRESULT SHCreateItemFromParsingName([MarshalAs(UnmanagedType.LPWStr)] string pszPath, IBindCtx? pbc, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IShellItem ppv); 22 | 23 | [DllImport("user32")] 24 | public static extern bool DestroyIcon(IntPtr handle); 25 | 26 | [DllImport("ole32")] 27 | private static extern HRESULT CreateBindCtx(int reserved, out IBindCtx ppbc); 28 | 29 | [DllImport("propsys")] 30 | public extern static HRESULT PSCreateMemoryPropertyStore([MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IPropertyStore store); 31 | 32 | public static IBindCtx CreateBindCtx() 33 | { 34 | CreateBindCtx(0, out var ctx).ThrowOnError(); 35 | return ctx; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/PROPERTYKEY.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [StructLayout(LayoutKind.Sequential)] 7 | public struct PROPERTYKEY 8 | { 9 | public static readonly PROPERTYKEY Null = new(Guid.Empty, 0); 10 | public static readonly Guid PSGUID_FOLDER_COLUMNID = new("9e5e05ac-1936-4a75-94f7-4704b8b01923"); 11 | public const int PID_FIRST_USABLE = 2; 12 | public const int FirstUsableId = PID_FIRST_USABLE; 13 | 14 | public PROPERTYKEY(Guid formatId, int id) 15 | { 16 | FormatId = formatId; 17 | Id = id; 18 | } 19 | 20 | public Guid FormatId { get; } 21 | public int Id { get; } 22 | public readonly bool IsNull => FormatId == Guid.Empty && Id == 0; 23 | 24 | public override readonly string ToString() => FormatId.ToString("B") + " " + Id; 25 | 26 | public static class System 27 | { 28 | public static PROPERTYKEY ItemType => new(new Guid("28636aa6-953d-11d2-b5d6-00c04fd918d0"), 11); 29 | public static PROPERTYKEY ItemTypeText => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 4); 30 | public static PROPERTYKEY Size => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 12); 31 | public static PROPERTYKEY FileAttributes => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 13); 32 | public static PROPERTYKEY DateModified => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 14); 33 | public static PROPERTYKEY DateCreated => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 15); 34 | public static PROPERTYKEY DateAccessed => new(new Guid("b725f130-47ef-101a-a5f1-02608c9eebac"), 16); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/PROPVARIANT.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace JumpListExplorer.Interop 8 | { 9 | [StructLayout(LayoutKind.Explicit)] 10 | public sealed class PROPVARIANT : IDisposable 11 | { 12 | #pragma warning disable IDE0044 // Add readonly modifier 13 | [FieldOffset(0)] 14 | private VARTYPE _vt; 15 | 16 | [FieldOffset(8)] 17 | private IntPtr _ptr; 18 | 19 | [FieldOffset(8)] 20 | private int _int32; 21 | 22 | [FieldOffset(8)] 23 | private uint _uint32; 24 | 25 | [FieldOffset(8)] 26 | private byte _byte; 27 | 28 | [FieldOffset(8)] 29 | private sbyte _sbyte; 30 | 31 | [FieldOffset(8)] 32 | private short _int16; 33 | 34 | [FieldOffset(8)] 35 | private ushort _uint16; 36 | 37 | [FieldOffset(8)] 38 | private long _int64; 39 | 40 | [FieldOffset(8)] 41 | private ulong _uint64; 42 | 43 | [FieldOffset(8)] 44 | private double _double; 45 | 46 | [FieldOffset(8)] 47 | private float _single; 48 | 49 | [FieldOffset(8)] 50 | private short _boolean; 51 | 52 | [FieldOffset(8)] 53 | private System.Runtime.InteropServices.ComTypes.FILETIME _filetime; 54 | 55 | [FieldOffset(8)] 56 | private PROPARRAY _ca; 57 | 58 | [FieldOffset(0)] 59 | private decimal _decimal; 60 | #pragma warning restore IDE0044 // Add readonly modifier 61 | 62 | [StructLayout(LayoutKind.Sequential)] 63 | private struct PROPARRAY 64 | { 65 | public int cElems; 66 | public IntPtr pElems; 67 | } 68 | 69 | public PROPVARIANT() 70 | { 71 | // it's a VT_EMPTY 72 | } 73 | 74 | private void ConstructBlob(byte[] bytes) 75 | { 76 | _ca.cElems = bytes.Length; 77 | _ca.pElems = Marshal.AllocCoTaskMem(bytes.Length); 78 | Marshal.Copy(bytes, 0, _ca.pElems, bytes.Length); 79 | _vt = VARTYPE.VT_BLOB; 80 | } 81 | 82 | private void ConstructArray(Array array, VARTYPE? type = null) 83 | { 84 | // special case for bools which are shorts... 85 | if (array is bool[] bools) 86 | { 87 | var shorts = new short[bools.Length]; 88 | for (var i = 0; i < bools.Length; i++) 89 | { 90 | shorts[i] = bools[i] ? (short)-1 : (short)0; 91 | } 92 | ConstructVector(shorts, typeof(short), VARTYPE.VT_BOOL); 93 | return; 94 | } 95 | 96 | var elementType = array.GetType().GetElementType()!; 97 | if (type == VARTYPE.VT_BLOB) 98 | { 99 | if (array is not byte[] bytes) 100 | throw new ArgumentException("Property type " + type + " is only supported for arrays of bytes.", nameof(type)); 101 | 102 | ConstructBlob(bytes); 103 | return; 104 | } 105 | 106 | ConstructVector(array, elementType, FromType(elementType, type)); 107 | } 108 | 109 | private void ConstructVector(Array array, Type type, VARTYPE vt) 110 | { 111 | _vt = vt | VARTYPE.VT_VECTOR; 112 | if (array.Length > 0) 113 | { 114 | int size; 115 | if (type == typeof(string)) 116 | { 117 | size = IntPtr.Size; 118 | } 119 | else 120 | { 121 | size = Marshal.SizeOf(type); 122 | } 123 | 124 | size *= array.Length; 125 | var ptr = Marshal.AllocCoTaskMem(size); 126 | _ca.cElems = array.Length; 127 | _ca.pElems = ptr; 128 | 129 | if (type == typeof(string)) 130 | { 131 | for (var i = 0; i < array.Length; i++) 132 | { 133 | var str = MarshalString((string?)array.GetValue(i), vt); 134 | Marshal.WriteIntPtr(ptr, IntPtr.Size * i, str); 135 | } 136 | } 137 | else 138 | { 139 | CopyMemory(ptr, Marshal.UnsafeAddrOfPinnedArrayElement(array, 0), (IntPtr)size); 140 | } 141 | } 142 | } 143 | 144 | private static void Using(object resource, Action action) 145 | { 146 | try 147 | { 148 | action(); 149 | } 150 | finally 151 | { 152 | (resource as IDisposable)?.Dispose(); 153 | } 154 | } 155 | 156 | private static int GetCount(IEnumerable enumerable) 157 | { 158 | if (enumerable is ICollection col) 159 | return col.Count; 160 | 161 | var count = 0; 162 | var e = enumerable.GetEnumerator(); 163 | Using(e, () => 164 | { 165 | while (e.MoveNext()) 166 | { 167 | count++; 168 | } 169 | }); 170 | return count; 171 | } 172 | 173 | private static Type? GetElementType(Type collectionType) 174 | { 175 | foreach (var iface in collectionType.GetInterfaces()) 176 | { 177 | if (!iface.IsGenericType) 178 | continue; 179 | 180 | if (iface.GetGenericTypeDefinition() == typeof(IEnumerable<>)) 181 | return iface.GetGenericArguments()[0]; 182 | 183 | if (iface.GetGenericTypeDefinition() == typeof(ICollection<>)) 184 | return iface.GetGenericArguments()[0]; 185 | 186 | if (iface.GetGenericTypeDefinition() == typeof(IList<>)) 187 | return iface.GetGenericArguments()[0]; 188 | } 189 | return null; 190 | } 191 | 192 | private static Type? GetElementType(IEnumerable enumerable) 193 | { 194 | var elementType = GetElementType(enumerable.GetType()); 195 | if (elementType != null) 196 | return elementType; 197 | 198 | foreach (var obj in enumerable) 199 | { 200 | return obj.GetType(); 201 | } 202 | return null; 203 | } 204 | 205 | private void ConstructEnumerable(IEnumerable enumerable, VARTYPE? type = null) 206 | { 207 | var elementType = GetElementType(enumerable); 208 | if (elementType == null) 209 | throw new ArgumentException("Enumerable type '" + enumerable.GetType().FullName + "' is not supported.", nameof(enumerable)); 210 | 211 | var count = GetCount(enumerable); 212 | var array = Array.CreateInstance(elementType, count); 213 | var i = 0; 214 | foreach (var obj in enumerable) 215 | { 216 | array.SetValue(obj, i++); 217 | } 218 | ConstructArray(array, type); 219 | } 220 | 221 | private static Type FromType(VARTYPE type) 222 | { 223 | switch (type) 224 | { 225 | case VARTYPE.VT_I1: 226 | return typeof(sbyte); 227 | 228 | case VARTYPE.VT_UI1: 229 | return typeof(byte); 230 | 231 | case VARTYPE.VT_I2: 232 | return typeof(short); 233 | 234 | case VARTYPE.VT_UI2: 235 | return typeof(ushort); 236 | 237 | case VARTYPE.VT_UI4: 238 | case VARTYPE.VT_UINT: 239 | return typeof(uint); 240 | 241 | case VARTYPE.VT_I8: 242 | return typeof(long); 243 | 244 | case VARTYPE.VT_UI8: 245 | return typeof(ulong); 246 | 247 | case VARTYPE.VT_R4: 248 | return typeof(float); 249 | 250 | case VARTYPE.VT_R8: 251 | return typeof(double); 252 | 253 | case VARTYPE.VT_BOOL: 254 | return typeof(bool); 255 | 256 | case VARTYPE.VT_I4: 257 | case VARTYPE.VT_INT: 258 | case VARTYPE.VT_ERROR: 259 | return typeof(int); 260 | 261 | case VARTYPE.VT_DATE: 262 | return typeof(DateTime); 263 | 264 | case VARTYPE.VT_FILETIME: 265 | return typeof(System.Runtime.InteropServices.ComTypes.FILETIME); 266 | 267 | case VARTYPE.VT_BLOB: 268 | return typeof(byte[]); 269 | 270 | case VARTYPE.VT_CLSID: 271 | return typeof(Guid); 272 | 273 | case VARTYPE.VT_BSTR: 274 | case VARTYPE.VT_LPSTR: 275 | case VARTYPE.VT_LPWSTR: 276 | return typeof(string); 277 | 278 | case VARTYPE.VT_UNKNOWN: 279 | case VARTYPE.VT_DISPATCH: 280 | return typeof(object); 281 | 282 | case VARTYPE.VT_CY: 283 | case VARTYPE.VT_DECIMAL: 284 | return typeof(decimal); 285 | 286 | default: 287 | throw new ArgumentException("Property type " + type + " is not supported.", nameof(type)); 288 | } 289 | } 290 | 291 | private static VARTYPE FromType(Type type, VARTYPE? vt) 292 | { 293 | if (type == null) 294 | return VARTYPE.VT_NULL; 295 | 296 | var tc = Type.GetTypeCode(type); 297 | switch (tc) 298 | { 299 | case TypeCode.Boolean: 300 | return VARTYPE.VT_BOOL; 301 | 302 | case TypeCode.Byte: 303 | return VARTYPE.VT_UI1; 304 | 305 | case TypeCode.Char: 306 | return VARTYPE.VT_LPWSTR; 307 | 308 | case TypeCode.DateTime: 309 | return VARTYPE.VT_FILETIME; 310 | 311 | case TypeCode.DBNull: 312 | return VARTYPE.VT_NULL; 313 | 314 | case TypeCode.Decimal: 315 | return VARTYPE.VT_DECIMAL; 316 | 317 | case TypeCode.Double: 318 | return VARTYPE.VT_R8; 319 | 320 | case TypeCode.Empty: 321 | return VARTYPE.VT_EMPTY; 322 | 323 | case TypeCode.Int16: 324 | return VARTYPE.VT_I2; 325 | 326 | case TypeCode.Int32: 327 | return VARTYPE.VT_I4; 328 | 329 | case TypeCode.Int64: 330 | return VARTYPE.VT_I8; 331 | 332 | case TypeCode.SByte: 333 | return VARTYPE.VT_I1; 334 | 335 | case TypeCode.Single: 336 | return VARTYPE.VT_R4; 337 | 338 | case TypeCode.String: 339 | if (!vt.HasValue) 340 | return VARTYPE.VT_LPWSTR; 341 | 342 | if (vt != VARTYPE.VT_LPSTR && vt != VARTYPE.VT_BSTR && vt != VARTYPE.VT_LPWSTR) 343 | throw new ArgumentException("Property type " + vt + " is not supported for string.", nameof(type)); 344 | 345 | return vt.Value; 346 | 347 | case TypeCode.UInt16: 348 | return VARTYPE.VT_UI2; 349 | 350 | case TypeCode.UInt32: 351 | return VARTYPE.VT_UI4; 352 | 353 | case TypeCode.UInt64: 354 | return VARTYPE.VT_UI8; 355 | 356 | // case TypeCode.Object: 357 | default: 358 | if (type == typeof(Guid)) 359 | return VARTYPE.VT_CLSID; 360 | 361 | if (type == typeof(System.Runtime.InteropServices.ComTypes.FILETIME)) 362 | return VARTYPE.VT_FILETIME; 363 | 364 | if (type == typeof(byte)) 365 | { 366 | if (!vt.HasValue) 367 | return VARTYPE.VT_UI1 | VARTYPE.VT_VECTOR; 368 | 369 | if (vt != VARTYPE.VT_BLOB && vt != (VARTYPE.VT_UI1 | VARTYPE.VT_VECTOR)) 370 | throw new ArgumentException("Property type " + vt + " is not supported for array of bytes.", nameof(type)); 371 | 372 | return vt.Value; 373 | } 374 | 375 | throw new ArgumentException("Value of type '" + type.FullName + "' is not supported.", nameof(type)); 376 | } 377 | } 378 | 379 | public PROPVARIANT(object? value, VARTYPE? type = null) 380 | { 381 | if (value is PROPVARIANT pv) 382 | { 383 | value = pv.Value; 384 | } 385 | 386 | if (value == null) 387 | { 388 | _vt = VARTYPE.VT_NULL; 389 | return; 390 | } 391 | 392 | if (Marshal.IsComObject(value)) 393 | { 394 | _ptr = Marshal.GetIUnknownForObject(value); 395 | _vt = VARTYPE.VT_UNKNOWN; 396 | return; 397 | } 398 | 399 | if (value is char[] chars) 400 | { 401 | value = new string(chars); 402 | } 403 | 404 | if (value is char[][] charray) 405 | { 406 | var strings = new string[charray.GetLength(0)]; 407 | for (var i = 0; i < charray.Length; i++) 408 | { 409 | strings[i] = new string(charray[i]); 410 | } 411 | value = strings; 412 | } 413 | 414 | if (value is Array array) 415 | { 416 | ConstructArray(array, type); 417 | return; 418 | } 419 | 420 | if (value is not string && value is IEnumerable enumerable) 421 | { 422 | ConstructEnumerable(enumerable, type); 423 | return; 424 | } 425 | 426 | var tc = Type.GetTypeCode(value.GetType()); 427 | switch (tc) 428 | { 429 | case TypeCode.Boolean: 430 | _boolean = (bool)value ? (short)-1 : (short)0; 431 | break; 432 | 433 | case TypeCode.Byte: 434 | _byte = (byte)value; 435 | break; 436 | 437 | case TypeCode.Char: 438 | chars = new[] { (char)value }; 439 | _ptr = MarshalString(new string(chars), FromType(typeof(string), type)); 440 | break; 441 | 442 | case TypeCode.DateTime: 443 | var ft = ToPositiveFileTime((DateTime)value); 444 | if (ft == 0) 445 | break; // stay empty 446 | 447 | InitPropVariantFromFileTime(ref ft, this); 448 | break; 449 | 450 | case TypeCode.Empty: 451 | case TypeCode.DBNull: 452 | break; 453 | 454 | case TypeCode.Decimal: 455 | _decimal = (decimal)value; 456 | break; 457 | 458 | case TypeCode.Double: 459 | _double = (double)value; 460 | break; 461 | 462 | case TypeCode.Int16: 463 | _int16 = (short)value; 464 | break; 465 | 466 | case TypeCode.Int32: 467 | _int32 = (int)value; 468 | break; 469 | 470 | case TypeCode.Int64: 471 | _int64 = (long)value; 472 | break; 473 | 474 | case TypeCode.SByte: 475 | _sbyte = (sbyte)value; 476 | break; 477 | 478 | case TypeCode.Single: 479 | _single = (float)value; 480 | break; 481 | 482 | case TypeCode.String: 483 | _ptr = MarshalString((string)value, FromType(typeof(string), type)); 484 | break; 485 | 486 | case TypeCode.UInt16: 487 | _uint16 = (ushort)value; 488 | break; 489 | 490 | case TypeCode.UInt32: 491 | _uint32 = (uint)value; 492 | break; 493 | 494 | case TypeCode.UInt64: 495 | _uint64 = (ulong)value; 496 | break; 497 | 498 | //case TypeCode.Object: 499 | default: 500 | if (value is Guid guid) 501 | { 502 | _ptr = Marshal.AllocCoTaskMem(16); 503 | Marshal.Copy(guid.ToByteArray(), 0, _ptr, 16); 504 | break; 505 | } 506 | 507 | if (value is System.Runtime.InteropServices.ComTypes.FILETIME filetime) 508 | { 509 | _filetime = filetime; 510 | break; 511 | } 512 | throw new ArgumentException("Value of type '" + value.GetType().FullName + "' is not supported.", nameof(value)); 513 | } 514 | 515 | _vt = FromType(value.GetType(), type); 516 | } 517 | 518 | public VARTYPE VarType { get => _vt; set => _vt = value; } 519 | public object? Value 520 | { 521 | get 522 | { 523 | switch (_vt) 524 | { 525 | case VARTYPE.VT_EMPTY: 526 | case VARTYPE.VT_NULL: // DbNull 527 | return null; 528 | 529 | case VARTYPE.VT_I1: 530 | return _sbyte; 531 | 532 | case VARTYPE.VT_UI1: 533 | return _byte; 534 | 535 | case VARTYPE.VT_I2: 536 | return _int16; 537 | 538 | case VARTYPE.VT_UI2: 539 | return _uint16; 540 | 541 | case VARTYPE.VT_I4: 542 | case VARTYPE.VT_INT: 543 | return _int32; 544 | 545 | case VARTYPE.VT_UI4: 546 | case VARTYPE.VT_UINT: 547 | return _uint32; 548 | 549 | case VARTYPE.VT_I8: 550 | return _int64; 551 | 552 | case VARTYPE.VT_UI8: 553 | return _uint64; 554 | 555 | case VARTYPE.VT_R4: 556 | return _single; 557 | 558 | case VARTYPE.VT_R8: 559 | return _double; 560 | 561 | case VARTYPE.VT_BOOL: 562 | return _int32 != 0; 563 | 564 | case VARTYPE.VT_ERROR: 565 | return _int64; 566 | 567 | case VARTYPE.VT_CY: 568 | return _decimal; 569 | 570 | case VARTYPE.VT_DATE: 571 | return DateTime.FromOADate(_double); 572 | 573 | case VARTYPE.VT_FILETIME: 574 | return DateTime.FromFileTime(_int64); 575 | 576 | case VARTYPE.VT_BSTR: 577 | return Marshal.PtrToStringBSTR(_ptr); 578 | 579 | case VARTYPE.VT_BLOB: 580 | var blob = new byte[_ca.cElems]; 581 | Marshal.Copy(_ca.pElems, blob, 0, _int32); 582 | return blob; 583 | 584 | case VARTYPE.VT_CLSID: 585 | var guid = new byte[16]; 586 | Marshal.Copy(_ptr, guid, 0, guid.Length); 587 | return new Guid(guid); 588 | 589 | case VARTYPE.VT_LPSTR: 590 | return Marshal.PtrToStringAnsi(_ptr); 591 | 592 | case VARTYPE.VT_LPWSTR: 593 | return Marshal.PtrToStringUni(_ptr); 594 | 595 | case VARTYPE.VT_UNKNOWN: 596 | case VARTYPE.VT_DISPATCH: 597 | return Marshal.GetObjectForIUnknown(_ptr); 598 | 599 | case VARTYPE.VT_DECIMAL: 600 | return _decimal; 601 | 602 | default: 603 | if ((_vt & VARTYPE.VT_VECTOR) == VARTYPE.VT_VECTOR) 604 | { 605 | var et = _vt & ~VARTYPE.VT_VECTOR; 606 | if (TryGetVectorValue(et, out var vector)) 607 | return vector; 608 | } 609 | throw new NotSupportedException("Value of property type " + _vt + " is not supported."); 610 | } 611 | } 612 | } 613 | 614 | ~PROPVARIANT() => Dispose(); 615 | public void Dispose() 616 | { 617 | _ = PropVariantClear(this); 618 | GC.SuppressFinalize(this); 619 | } 620 | 621 | private static IntPtr MarshalString(string? str, VARTYPE vt) 622 | { 623 | switch (vt) 624 | { 625 | case VARTYPE.VT_LPWSTR: 626 | return Marshal.StringToCoTaskMemUni(str); 627 | 628 | case VARTYPE.VT_BSTR: 629 | return Marshal.StringToBSTR(str); 630 | 631 | case VARTYPE.VT_LPSTR: 632 | return Marshal.StringToCoTaskMemAnsi(str); 633 | 634 | default: 635 | throw new NotSupportedException("A string can only be of property type VT_LPWSTR, VT_LPSTR or VT_BSTR."); 636 | } 637 | } 638 | 639 | private static long ToPositiveFileTime(DateTime dt) 640 | { 641 | var ft = dt.ToUniversalTime().ToFileTimeUtc(); 642 | return ft < 0 ? 0 : ft; 643 | } 644 | 645 | private bool TryGetVectorValue(VARTYPE vt, out object? value) 646 | { 647 | value = null; 648 | var ret = false; 649 | int size; 650 | switch (vt) 651 | { 652 | case VARTYPE.VT_LPSTR: 653 | case VARTYPE.VT_LPWSTR: 654 | var strings = new string?[_ca.cElems]; 655 | for (var i = 0; i < strings.Length; i++) 656 | { 657 | var str = Marshal.ReadIntPtr(_ca.pElems, IntPtr.Size * i); 658 | strings[i] = vt == VARTYPE.VT_LPSTR ? Marshal.PtrToStringAnsi(str) : Marshal.PtrToStringUni(str); 659 | } 660 | value = strings; 661 | ret = true; 662 | break; 663 | 664 | case VARTYPE.VT_BOOL: 665 | var shorts = new short[_ca.cElems]; 666 | size = _ca.cElems * Marshal.SizeOf(typeof(short)); 667 | CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(shorts, 0), _ca.pElems, (IntPtr)size); 668 | var bools = new bool[shorts.Length]; 669 | for (var i = 0; i < shorts.Length; i++) 670 | { 671 | bools[i] = shorts[i] != 0; 672 | } 673 | value = bools; 674 | ret = true; 675 | break; 676 | 677 | case VARTYPE.VT_I1: 678 | case VARTYPE.VT_UI1: 679 | case VARTYPE.VT_I2: 680 | case VARTYPE.VT_UI2: 681 | case VARTYPE.VT_I4: 682 | case VARTYPE.VT_INT: 683 | case VARTYPE.VT_UI4: 684 | case VARTYPE.VT_UINT: 685 | case VARTYPE.VT_I8: 686 | case VARTYPE.VT_UI8: 687 | case VARTYPE.VT_R4: 688 | case VARTYPE.VT_R8: 689 | case VARTYPE.VT_ERROR: 690 | case VARTYPE.VT_CY: 691 | case VARTYPE.VT_DATE: 692 | case VARTYPE.VT_FILETIME: 693 | case VARTYPE.VT_CLSID: 694 | case VARTYPE.VT_UNKNOWN: 695 | case VARTYPE.VT_DISPATCH: 696 | var et = FromType(vt); 697 | var values = Array.CreateInstance(et, _ca.cElems); 698 | size = _ca.cElems * Marshal.SizeOf(et); 699 | CopyMemory(Marshal.UnsafeAddrOfPinnedArrayElement(values, 0), _ca.pElems, (IntPtr)size); 700 | value = values; 701 | ret = true; 702 | break; 703 | } 704 | return ret; 705 | } 706 | 707 | public IntPtr Serialize(out int size) 708 | { 709 | StgSerializePropVariant(this, out var ptr, out size).ThrowOnError(); 710 | return ptr; 711 | } 712 | 713 | public byte[] Serialize() 714 | { 715 | StgSerializePropVariant(this, out var ptr, out var size).ThrowOnError(); 716 | var bytes = new byte[size]; 717 | Marshal.Copy(ptr, bytes, 0, bytes.Length); 718 | Marshal.FreeCoTaskMem(ptr); 719 | return bytes; 720 | } 721 | 722 | public static PROPVARIANT? Deserialize(byte[] bytes) => Deserialize(bytes, true); 723 | public static PROPVARIANT? Deserialize(byte[] bytes, bool throwOnError) 724 | { 725 | if (bytes == null) 726 | throw new ArgumentNullException(nameof(bytes)); 727 | 728 | var pv = new PROPVARIANT(); 729 | var hr = StgDeserializePropVariant(bytes, bytes.Length, pv); 730 | if (hr.IsError) 731 | { 732 | pv.Dispose(); 733 | hr.ThrowOnError(throwOnError); 734 | return null; 735 | } 736 | 737 | return pv; 738 | } 739 | 740 | public static PROPVARIANT? Deserialize(IntPtr ptr, int size) => Deserialize(ptr, size, true); 741 | public static PROPVARIANT? Deserialize(IntPtr ptr, int size, bool throwOnError) 742 | { 743 | if (ptr == IntPtr.Zero) 744 | throw new ArgumentNullException(nameof(ptr)); 745 | 746 | var pv = new PROPVARIANT(); 747 | var hr = StgDeserializePropVariant(ptr, size, pv); 748 | if (hr.IsError) 749 | { 750 | pv.Dispose(); 751 | hr.ThrowOnError(throwOnError); 752 | return null; 753 | } 754 | 755 | return pv; 756 | } 757 | 758 | public override string ToString() 759 | { 760 | var value = Value; 761 | if (value == null) 762 | return ""; 763 | 764 | if (value is string svalue) 765 | return "[" + VarType + "] `" + svalue + "`"; 766 | 767 | if (value is not byte[] && value is IEnumerable enumerable) 768 | return "[" + VarType + "] " + string.Join(", ", enumerable.OfType()); 769 | 770 | if (value is byte[] bytes) 771 | return "[" + VarType + "] bytes[" + bytes.Length + "]"; 772 | 773 | return "[" + VarType + "] " + value; 774 | } 775 | 776 | [DllImport("propsys", ExactSpelling = true)] 777 | private extern static HRESULT StgDeserializePropVariant(IntPtr ppProp, int cbMax, [Out] PROPVARIANT ppropvar); 778 | 779 | [DllImport("propsys", ExactSpelling = true)] 780 | private extern static HRESULT StgDeserializePropVariant([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] ppProp, int cbMax, [Out] PROPVARIANT ppropvar); 781 | 782 | [DllImport("propsys", ExactSpelling = true)] 783 | private extern static HRESULT StgSerializePropVariant(PROPVARIANT ppropvar, out IntPtr ppProp, out int pcb); 784 | 785 | [DllImport("ole32", ExactSpelling = true)] 786 | private extern static HRESULT PropVariantClear([In, Out] PROPVARIANT pvar); 787 | 788 | [DllImport("propsys", ExactSpelling = true)] 789 | private static extern HRESULT InitPropVariantFromFileTime(ref long pftIn, [Out] PROPVARIANT ppropvar); 790 | 791 | [DllImport("kernel32", ExactSpelling = true, EntryPoint = "RtlMoveMemory")] 792 | internal static extern void CopyMemory(IntPtr destination, IntPtr source, IntPtr length); 793 | } 794 | } 795 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/SFGAO.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | [Flags] 6 | public enum SFGAO : uint 7 | { 8 | SFGAO_NONE = 0, 9 | SFGAO_CANCOPY = DROPEFFECT.DROPEFFECT_COPY, 10 | SFGAO_CANMOVE = DROPEFFECT.DROPEFFECT_MOVE, 11 | SFGAO_CANLINK = DROPEFFECT.DROPEFFECT_LINK, 12 | SFGAO_STORAGE = 0x00000008, 13 | SFGAO_CANRENAME = 0x00000010, 14 | SFGAO_CANDELETE = 0x00000020, 15 | SFGAO_HASPROPSHEET = 0x00000040, 16 | SFGAO_DROPTARGET = 0x00000100, 17 | SFGAO_PLACEHOLDER = 0x00000800, 18 | SFGAO_SYSTEM = 0x00001000, 19 | SFGAO_ENCRYPTED = 0x00002000, 20 | SFGAO_ISSLOW = 0x00004000, 21 | SFGAO_GHOSTED = 0x00008000, 22 | SFGAO_LINK = 0x00010000, 23 | SFGAO_SHARE = 0x00020000, 24 | SFGAO_READONLY = 0x00040000, 25 | SFGAO_HIDDEN = 0x00080000, 26 | SFGAO_FILESYSANCESTOR = 0x10000000, 27 | SFGAO_FOLDER = 0x20000000, 28 | SFGAO_FILESYSTEM = 0x40000000, 29 | SFGAO_HASSUBFOLDER = 0x80000000, 30 | SFGAO_VALIDATE = 0x01000000, 31 | SFGAO_REMOVABLE = 0x02000000, 32 | SFGAO_COMPRESSED = 0x04000000, 33 | SFGAO_BROWSABLE = 0x08000000, 34 | SFGAO_NONENUMERATED = 0x00100000, 35 | SFGAO_NEWCONTENT = 0x00200000, 36 | SFGAO_STREAM = 0x00400000, 37 | SFGAO_STORAGEANCESTOR = 0x00800000, 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/SHCONTF.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | [Flags] 6 | public enum SHCONTF : uint 7 | { 8 | SHCONTF_CHECKING_FOR_CHILDREN = 0x10, 9 | SHCONTF_FOLDERS = 0x20, 10 | SHCONTF_NONFOLDERS = 0x40, 11 | SHCONTF_INCLUDEHIDDEN = 0x80, 12 | SHCONTF_INIT_ON_FIRST_NEXT = 0x100, 13 | SHCONTF_NETPRINTERSRCH = 0x200, 14 | SHCONTF_SHAREABLE = 0x400, 15 | SHCONTF_STORAGE = 0x800, 16 | SHCONTF_NAVIGATION_ENUM = 0x1000, 17 | SHCONTF_FASTITEMS = 0x2000, 18 | SHCONTF_FLATLIST = 0x4000, 19 | SHCONTF_ENABLE_ASYNC = 0x8000, 20 | SHCONTF_INCLUDESUPERHIDDEN = 0x10000, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/SHIL.cs: -------------------------------------------------------------------------------- 1 | namespace JumpListExplorer.Interop 2 | { 3 | public enum SHIL 4 | { 5 | SHIL_LARGE = 0, 6 | SHIL_SMALL = 1, 7 | SHIL_EXTRALARGE = 2, 8 | SHIL_SYSSMALL = 3, 9 | SHIL_JUMBO = 4, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/SICHINTF.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | [Flags] 6 | public enum SICHINTF : uint 7 | { 8 | SICHINT_DISPLAY = 0, 9 | SICHINT_ALLFIELDS = 0x80000000, 10 | SICHINT_CANONICAL = 0x10000000, 11 | SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/SIGDN.cs: -------------------------------------------------------------------------------- 1 | namespace JumpListExplorer.Interop 2 | { 3 | public enum SIGDN : uint 4 | { 5 | SIGDN_NORMALDISPLAY = 0, 6 | SIGDN_PARENTRELATIVEPARSING = 0x80018001, 7 | SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000, 8 | SIGDN_PARENTRELATIVEEDITING = 0x80031001, 9 | SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000, 10 | SIGDN_FILESYSPATH = 0x80058000, 11 | SIGDN_URL = 0x80068000, 12 | SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001, 13 | SIGDN_PARENTRELATIVE = 0x80080001, 14 | SIGDN_PARENTRELATIVEFORUI = 0x80094001, 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/VARTYPE.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace JumpListExplorer.Interop 4 | { 5 | // stupid .NET's VarEnum does not define Flags and does not derive from ushort ... 6 | [Flags] 7 | public enum VARTYPE : ushort 8 | { 9 | VT_EMPTY = 0, 10 | VT_NULL = 1, 11 | VT_I2 = 2, 12 | VT_I4 = 3, 13 | VT_R4 = 4, 14 | VT_R8 = 5, 15 | VT_CY = 6, 16 | VT_DATE = 7, 17 | VT_BSTR = 8, 18 | VT_DISPATCH = 9, 19 | VT_ERROR = 10, 20 | VT_BOOL = 11, 21 | VT_VARIANT = 12, 22 | VT_UNKNOWN = 13, 23 | VT_DECIMAL = 14, 24 | VT_I1 = 16, 25 | VT_UI1 = 17, 26 | VT_UI2 = 18, 27 | VT_UI4 = 19, 28 | VT_I8 = 20, 29 | VT_UI8 = 21, 30 | VT_INT = 22, 31 | VT_UINT = 23, 32 | VT_VOID = 24, 33 | VT_HRESULT = 25, 34 | VT_PTR = 26, 35 | VT_SAFEARRAY = 27, 36 | VT_CARRAY = 28, 37 | VT_USERDEFINED = 29, 38 | VT_LPSTR = 30, 39 | VT_LPWSTR = 31, 40 | VT_RECORD = 36, 41 | VT_INT_PTR = 37, 42 | VT_UINT_PTR = 38, 43 | VT_FILETIME = 64, 44 | VT_BLOB = 65, 45 | VT_STREAM = 66, 46 | VT_STORAGE = 67, 47 | VT_STREAMED_OBJECT = 68, 48 | VT_STORED_OBJECT = 69, 49 | VT_BLOB_OBJECT = 70, 50 | VT_CF = 71, 51 | VT_CLSID = 72, 52 | VT_VERSIONED_STREAM = 73, 53 | VT_BSTR_BLOB = 0xfff, 54 | VT_VECTOR = 0x1000, 55 | VT_ARRAY = 0x2000, 56 | VT_BYREF = 0x4000, 57 | VT_RESERVED = 0x8000, 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /JumpListExplorer/Interop/WIN32_FIND_DATAW.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Runtime.InteropServices; 3 | 4 | namespace JumpListExplorer.Interop 5 | { 6 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 7 | public struct WIN32_FIND_DATAW 8 | { 9 | public FileAttributes fileAttributes; 10 | public uint ftCreationTimeLow; 11 | public uint ftCreationTimeHigh; 12 | public uint ftLastAccessTimeLow; 13 | public uint ftLastAccessTimeHigh; 14 | public uint ftLastWriteTimeLow; 15 | public uint ftLastWriteTimeHigh; 16 | public uint fileSizeHigh; 17 | public uint fileSizeLow; 18 | public uint dwReserved0; 19 | public uint dwReserved1; 20 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] 21 | public string cFileName; 22 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] 23 | public string cAlternateFileName; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JumpListExplorer/JumpListExplorer.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WinExe 5 | net6.0-windows 6 | enable 7 | true 8 | false 9 | JumpListExplorer.ico 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | True 19 | True 20 | Resources.resx 21 | 22 | 23 | 24 | 25 | 26 | ResXFileCodeGenerator 27 | Resources.Designer.cs 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /JumpListExplorer/JumpListExplorer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smourier/JumpListExplorer/e541d0040f091dcd4de86bc593f9752679faf1f9/JumpListExplorer/JumpListExplorer.ico -------------------------------------------------------------------------------- /JumpListExplorer/Main.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace JumpListExplorer 2 | { 3 | partial class Main 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | menuStripMain = new System.Windows.Forms.MenuStrip(); 33 | fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 34 | exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 36 | refreshToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 37 | helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 | aboutWindowsJumpListExplorerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 39 | listViewMain = new System.Windows.Forms.ListView(); 40 | columnHeaderAumid = new System.Windows.Forms.ColumnHeader(); 41 | columnHeaderDate = new System.Windows.Forms.ColumnHeader(); 42 | columnHeaderName = new System.Windows.Forms.ColumnHeader(); 43 | columnHeaderPath = new System.Windows.Forms.ColumnHeader(); 44 | contextMenuStripMain = new System.Windows.Forms.ContextMenuStrip(components); 45 | removeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 46 | toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); 47 | openLocationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 48 | runFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 49 | toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); 50 | removeAllDeletedFilesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 | imageListIcons = new System.Windows.Forms.ImageList(components); 52 | menuStripMain.SuspendLayout(); 53 | contextMenuStripMain.SuspendLayout(); 54 | SuspendLayout(); 55 | // 56 | // menuStripMain 57 | // 58 | menuStripMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { fileToolStripMenuItem, viewToolStripMenuItem, helpToolStripMenuItem }); 59 | menuStripMain.Location = new System.Drawing.Point(0, 0); 60 | menuStripMain.Name = "menuStripMain"; 61 | menuStripMain.Size = new System.Drawing.Size(1226, 24); 62 | menuStripMain.TabIndex = 0; 63 | menuStripMain.Text = "Main Menu"; 64 | // 65 | // fileToolStripMenuItem 66 | // 67 | fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { exitToolStripMenuItem }); 68 | fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 69 | fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); 70 | fileToolStripMenuItem.Text = "&File"; 71 | // 72 | // exitToolStripMenuItem 73 | // 74 | exitToolStripMenuItem.Name = "exitToolStripMenuItem"; 75 | exitToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F4; 76 | exitToolStripMenuItem.Size = new System.Drawing.Size(139, 22); 77 | exitToolStripMenuItem.Text = "E&xit"; 78 | exitToolStripMenuItem.Click += ExitToolStripMenuItem_Click; 79 | // 80 | // viewToolStripMenuItem 81 | // 82 | viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { refreshToolStripMenuItem }); 83 | viewToolStripMenuItem.Name = "viewToolStripMenuItem"; 84 | viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); 85 | viewToolStripMenuItem.Text = "&View"; 86 | // 87 | // refreshToolStripMenuItem 88 | // 89 | refreshToolStripMenuItem.Name = "refreshToolStripMenuItem"; 90 | refreshToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F5; 91 | refreshToolStripMenuItem.Size = new System.Drawing.Size(132, 22); 92 | refreshToolStripMenuItem.Text = "&Refresh"; 93 | refreshToolStripMenuItem.Click += RefreshToolStripMenuItem_Click; 94 | // 95 | // helpToolStripMenuItem 96 | // 97 | helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { aboutWindowsJumpListExplorerToolStripMenuItem }); 98 | helpToolStripMenuItem.Name = "helpToolStripMenuItem"; 99 | helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); 100 | helpToolStripMenuItem.Text = "&Help"; 101 | // 102 | // aboutWindowsJumpListExplorerToolStripMenuItem 103 | // 104 | aboutWindowsJumpListExplorerToolStripMenuItem.Name = "aboutWindowsJumpListExplorerToolStripMenuItem"; 105 | aboutWindowsJumpListExplorerToolStripMenuItem.Size = new System.Drawing.Size(258, 22); 106 | aboutWindowsJumpListExplorerToolStripMenuItem.Text = "&About Windows Jump List Explorer"; 107 | aboutWindowsJumpListExplorerToolStripMenuItem.Click += AboutWindowsJumpListExplorerToolStripMenuItem_Click; 108 | // 109 | // listViewMain 110 | // 111 | listViewMain.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { columnHeaderAumid, columnHeaderDate, columnHeaderName, columnHeaderPath }); 112 | listViewMain.ContextMenuStrip = contextMenuStripMain; 113 | listViewMain.Dock = System.Windows.Forms.DockStyle.Fill; 114 | listViewMain.FullRowSelect = true; 115 | listViewMain.Location = new System.Drawing.Point(0, 24); 116 | listViewMain.Name = "listViewMain"; 117 | listViewMain.Size = new System.Drawing.Size(1226, 594); 118 | listViewMain.SmallImageList = imageListIcons; 119 | listViewMain.TabIndex = 1; 120 | listViewMain.UseCompatibleStateImageBehavior = false; 121 | listViewMain.View = System.Windows.Forms.View.Details; 122 | listViewMain.DoubleClick += ListViewMain_DoubleClick; 123 | // 124 | // columnHeaderAumid 125 | // 126 | columnHeaderAumid.Text = "Application User Model ID"; 127 | columnHeaderAumid.Width = 200; 128 | // 129 | // columnHeaderDate 130 | // 131 | columnHeaderDate.Text = "Last Accessed Date"; 132 | columnHeaderDate.Width = 140; 133 | // 134 | // columnHeaderName 135 | // 136 | columnHeaderName.Text = "Name"; 137 | columnHeaderName.Width = 150; 138 | // 139 | // columnHeaderPath 140 | // 141 | columnHeaderPath.Text = "Path"; 142 | columnHeaderPath.Width = 300; 143 | // 144 | // contextMenuStripMain 145 | // 146 | contextMenuStripMain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { removeToolStripMenuItem, toolStripSeparator1, openLocationToolStripMenuItem, runFileToolStripMenuItem, toolStripSeparator2, removeAllDeletedFilesToolStripMenuItem }); 147 | contextMenuStripMain.Name = "contextMenuStripMain"; 148 | contextMenuStripMain.Size = new System.Drawing.Size(269, 104); 149 | contextMenuStripMain.Opening += ContextMenuStripMain_Opening; 150 | // 151 | // removeToolStripMenuItem 152 | // 153 | removeToolStripMenuItem.Name = "removeToolStripMenuItem"; 154 | removeToolStripMenuItem.Size = new System.Drawing.Size(268, 22); 155 | removeToolStripMenuItem.Text = "Remove"; 156 | removeToolStripMenuItem.Click += RemoveToolStripMenuItem_Click; 157 | // 158 | // toolStripSeparator1 159 | // 160 | toolStripSeparator1.Name = "toolStripSeparator1"; 161 | toolStripSeparator1.Size = new System.Drawing.Size(265, 6); 162 | // 163 | // openLocationToolStripMenuItem 164 | // 165 | openLocationToolStripMenuItem.Name = "openLocationToolStripMenuItem"; 166 | openLocationToolStripMenuItem.Size = new System.Drawing.Size(268, 22); 167 | openLocationToolStripMenuItem.Text = "Open location"; 168 | openLocationToolStripMenuItem.Click += OpenLocationToolStripMenuItem_Click; 169 | // 170 | // runFileToolStripMenuItem 171 | // 172 | runFileToolStripMenuItem.Name = "runFileToolStripMenuItem"; 173 | runFileToolStripMenuItem.Size = new System.Drawing.Size(268, 22); 174 | runFileToolStripMenuItem.Text = "Run file"; 175 | runFileToolStripMenuItem.Click += RunFileToolStripMenuItem_Click; 176 | // 177 | // toolStripSeparator2 178 | // 179 | toolStripSeparator2.Name = "toolStripSeparator2"; 180 | toolStripSeparator2.Size = new System.Drawing.Size(265, 6); 181 | // 182 | // removeAllDeletedFilesToolStripMenuItem 183 | // 184 | removeAllDeletedFilesToolStripMenuItem.Name = "removeAllDeletedFilesToolStripMenuItem"; 185 | removeAllDeletedFilesToolStripMenuItem.Size = new System.Drawing.Size(268, 22); 186 | removeAllDeletedFilesToolStripMenuItem.Text = "Remove shortcuts for all deleted files"; 187 | removeAllDeletedFilesToolStripMenuItem.Click += RemoveAllDeletedFilesToolStripMenuItem_Click; 188 | // 189 | // imageListIcons 190 | // 191 | imageListIcons.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; 192 | imageListIcons.ImageSize = new System.Drawing.Size(16, 16); 193 | imageListIcons.TransparentColor = System.Drawing.Color.Transparent; 194 | // 195 | // Main 196 | // 197 | AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); 198 | AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 199 | ClientSize = new System.Drawing.Size(1226, 618); 200 | Controls.Add(listViewMain); 201 | Controls.Add(menuStripMain); 202 | MainMenuStrip = menuStripMain; 203 | Name = "Main"; 204 | StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 205 | Text = "Windows Jump List Explorer"; 206 | menuStripMain.ResumeLayout(false); 207 | menuStripMain.PerformLayout(); 208 | contextMenuStripMain.ResumeLayout(false); 209 | ResumeLayout(false); 210 | PerformLayout(); 211 | } 212 | 213 | #endregion 214 | 215 | private System.Windows.Forms.MenuStrip menuStripMain; 216 | private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; 217 | private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; 218 | private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem; 219 | private System.Windows.Forms.ToolStripMenuItem refreshToolStripMenuItem; 220 | private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; 221 | private System.Windows.Forms.ToolStripMenuItem aboutWindowsJumpListExplorerToolStripMenuItem; 222 | private System.Windows.Forms.ListView listViewMain; 223 | private System.Windows.Forms.ColumnHeader columnHeaderAumid; 224 | private System.Windows.Forms.ColumnHeader columnHeaderPath; 225 | private System.Windows.Forms.ImageList imageListIcons; 226 | private System.Windows.Forms.ContextMenuStrip contextMenuStripMain; 227 | private System.Windows.Forms.ToolStripMenuItem removeToolStripMenuItem; 228 | private System.Windows.Forms.ColumnHeader columnHeaderDate; 229 | private System.Windows.Forms.ToolStripMenuItem openLocationToolStripMenuItem; 230 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; 231 | private System.Windows.Forms.ToolStripMenuItem runFileToolStripMenuItem; 232 | private System.Windows.Forms.ToolStripMenuItem removeAllDeletedFilesToolStripMenuItem; 233 | private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; 234 | private System.Windows.Forms.ColumnHeader columnHeaderName; 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /JumpListExplorer/Main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Reflection; 7 | using System.Windows.Forms; 8 | using JumpListExplorer.Shell; 9 | using JumpListExplorer.Utilities; 10 | 11 | namespace JumpListExplorer 12 | { 13 | public partial class Main : Form 14 | { 15 | public Main() 16 | { 17 | InitializeComponent(); 18 | Icon = Resources.JumpListExplorerIcon; 19 | listViewMain.ListViewItemSorter = new ColumnSorter { SortColumn = columnHeaderDate.Index, Order = SortOrder.Descending }; 20 | LoadApplicationUserModelIDs(); 21 | listViewMain.Sort(); 22 | listViewMain.ColumnClick += (s, e) => { ((ColumnSorter)listViewMain.ListViewItemSorter).HandleClick(listViewMain, e.Column); }; 23 | } 24 | 25 | private void LoadApplicationUserModelIDs() 26 | { 27 | listViewMain.Items.Clear(); 28 | foreach (var aumid in AutomaticDestinationList.EnumerateAppUserModelIDs().OrderBy(i => i)) 29 | { 30 | foreach (var item in AutomaticDestinationList.GetItems(aumid).OrderBy(i => i.SIGDN_DESKTOPABSOLUTEPARSING)) 31 | { 32 | var imageIndex = -1; 33 | try 34 | { 35 | var path = item.SIGDN_FILESYSPATH; 36 | if (!string.IsNullOrWhiteSpace(path)) 37 | { 38 | var extension = Path.GetExtension(path).ToLowerInvariant(); 39 | if (!string.IsNullOrEmpty(extension)) 40 | { 41 | imageIndex = imageListIcons.Images.IndexOfKey(extension); 42 | if (imageIndex < 0) 43 | { 44 | var icon = item.GetIconFromImageList(Interop.SHIL.SHIL_SYSSMALL); 45 | if (icon != null) 46 | { 47 | imageIndex = imageListIcons.Images.Count; 48 | imageListIcons.Images.Add(extension, icon); 49 | } 50 | } 51 | } 52 | } 53 | } 54 | catch 55 | { 56 | // continue 57 | } 58 | 59 | ListViewItem lvi; 60 | if (imageIndex >= 0) 61 | { 62 | lvi = listViewMain.Items.Add(aumid, imageIndex); 63 | } 64 | else 65 | { 66 | lvi = listViewMain.Items.Add(aumid); 67 | } 68 | 69 | lvi.Tag = new Model(aumid, item); 70 | lvi.SubItems.Add(item.DateAccessed?.ToString("yyyy/MM/dd HH:mm:ss")); 71 | lvi.SubItems.Add(item.SIGDN_NORMALDISPLAY); 72 | lvi.SubItems.Add(item.SIGDN_DESKTOPABSOLUTEPARSING); 73 | } 74 | } 75 | 76 | listViewMain.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); 77 | columnHeaderName.Width = 120; 78 | Text = $"{WinformsUtilities.ApplicationName} - {listViewMain.Items.Count} items"; 79 | } 80 | 81 | private void RemoveAllDeleted() 82 | { 83 | foreach (var aumid in AutomaticDestinationList.EnumerateAppUserModelIDs().OrderBy(i => i)) 84 | { 85 | var list = new List(); 86 | foreach (var item in AutomaticDestinationList.GetItems(aumid).OrderBy(i => i.SIGDN_DESKTOPABSOLUTEPARSING)) 87 | { 88 | var path = item.SIGDN_FILESYSPATH; 89 | if (path != null && !Directory.Exists(item.SIGDN_FILESYSPATH) && !File.Exists(item.SIGDN_FILESYSPATH)) 90 | { 91 | list.Add(item); 92 | } 93 | } 94 | 95 | AutomaticDestinationList.RemoveItems(aumid, list); 96 | } 97 | 98 | LoadApplicationUserModelIDs(); 99 | } 100 | 101 | private List GetSelection() 102 | { 103 | var list = new List(); 104 | foreach (var lvi in listViewMain.SelectedItems.OfType()) 105 | { 106 | if (lvi.Tag is Model model) 107 | { 108 | list.Add(model); 109 | } 110 | } 111 | return list; 112 | } 113 | 114 | private string? GetParentPath() 115 | { 116 | var list = GetSelection(); 117 | if (list.Count == 1 && list[0].Item.Parent?.SIGDN_FILESYSPATH != null) 118 | return list[0].Item.Parent?.SIGDN_FILESYSPATH; 119 | 120 | return null; 121 | } 122 | 123 | private string? GetPath() 124 | { 125 | var list = GetSelection(); 126 | if (list.Count == 1 && list[0].Item.SIGDN_FILESYSPATH != null) 127 | return list[0].Item.SIGDN_FILESYSPATH; 128 | 129 | return null; 130 | } 131 | 132 | private void ExitToolStripMenuItem_Click(object sender, EventArgs e) => Close(); 133 | private void AboutWindowsJumpListExplorerToolStripMenuItem_Click(object sender, EventArgs e) => this.ShowMessage(Assembly.GetEntryAssembly()!.GetCustomAttribute()!.Title + " - " + (IntPtr.Size == 4 ? "32" : "64") + "-bit" + Environment.NewLine + "Copyright (C) 2022-" + DateTime.Now.Year + " Simon Mourier. All rights reserved."); 134 | private void RefreshToolStripMenuItem_Click(object sender, EventArgs e) => LoadApplicationUserModelIDs(); 135 | private void OpenLocationToolStripMenuItem_Click(object sender, EventArgs e) => WindowsUtilities.OpenExplorer(GetParentPath()); 136 | private void ListViewMain_DoubleClick(object sender, EventArgs e) => WindowsUtilities.OpenFile(GetPath()); 137 | private void RunFileToolStripMenuItem_Click(object sender, EventArgs e) => WindowsUtilities.OpenFile(GetPath()); 138 | private void RemoveAllDeletedFilesToolStripMenuItem_Click(object sender, EventArgs e) => RemoveAllDeleted(); 139 | private void RemoveToolStripMenuItem_Click(object sender, EventArgs e) 140 | { 141 | var list = GetSelection(); 142 | if (list.Count == 0) 143 | return; 144 | 145 | if (list.Count == 1) 146 | { 147 | if (this.ShowConfirm($"Are you sure you want to delete the shortcut to {list[0].Item.SIGDN_DESKTOPABSOLUTEPARSING}?") != DialogResult.Yes) 148 | return; 149 | } 150 | else 151 | { 152 | if (this.ShowConfirm($"Are you sure you want to delete {list.Count} shortcuts?") != DialogResult.Yes) 153 | return; 154 | } 155 | 156 | var count = 0; 157 | foreach (var group in list.GroupBy(i => i.AppUserModelID)) 158 | { 159 | count += AutomaticDestinationList.RemoveItems(group.Key, group.Select(g => g.Item)); 160 | } 161 | this.ShowMessage($"{count} shortcut(s) were deleted."); 162 | 163 | if (count > 0) 164 | { 165 | LoadApplicationUserModelIDs(); 166 | } 167 | } 168 | 169 | private void ContextMenuStripMain_Opening(object sender, System.ComponentModel.CancelEventArgs e) 170 | { 171 | runFileToolStripMenuItem.Text = "Run File"; 172 | runFileToolStripMenuItem.Enabled = false; 173 | openLocationToolStripMenuItem.Text = "Open Location"; 174 | openLocationToolStripMenuItem.Enabled = false; 175 | 176 | var selection = GetSelection(); 177 | if (selection.Count > 1) 178 | { 179 | removeToolStripMenuItem.Text = $"Remove {selection.Count} shortcuts"; 180 | } 181 | else 182 | { 183 | var path = GetPath(); 184 | if (path != null) 185 | { 186 | runFileToolStripMenuItem.Text = $"Run '{path}'"; 187 | runFileToolStripMenuItem.Enabled = true; 188 | removeToolStripMenuItem.Text = $"Remove '{path}' shortcut"; 189 | } 190 | } 191 | 192 | var parentPath = GetParentPath(); 193 | if (parentPath != null) 194 | { 195 | openLocationToolStripMenuItem.Text = $"Open '{parentPath}'"; 196 | openLocationToolStripMenuItem.Enabled = true; 197 | } 198 | } 199 | 200 | private sealed class Model 201 | { 202 | public Model(string aumid, Item item) 203 | { 204 | AppUserModelID = aumid; 205 | Item = item; 206 | } 207 | 208 | public string AppUserModelID { get; } 209 | public Item Item { get; } 210 | } 211 | 212 | private sealed class ColumnSorter : IComparer 213 | { 214 | private static readonly CaseInsensitiveComparer _comparer = new(); 215 | 216 | public int SortColumn { get; set; } 217 | public SortOrder Order { get; set; } 218 | 219 | public int Compare(object? x, object? y) 220 | { 221 | var listviewX = (ListViewItem)x!; 222 | var listviewY = (ListViewItem)y!; 223 | 224 | if (SortColumn >= listviewX.SubItems.Count) 225 | return -1; 226 | 227 | if (SortColumn >= listviewY.SubItems.Count) 228 | return 1; 229 | 230 | var compareResult = _comparer.Compare(listviewX.SubItems[SortColumn].Text, listviewY.SubItems[SortColumn].Text); 231 | if (Order == SortOrder.Ascending) 232 | return compareResult; 233 | 234 | if (Order == SortOrder.Descending) 235 | return -compareResult; 236 | 237 | return 0; 238 | } 239 | 240 | public void HandleClick(ListView listView, int column) 241 | { 242 | if (column == SortColumn) 243 | { 244 | if (Order == SortOrder.Ascending) 245 | { 246 | Order = SortOrder.Descending; 247 | } 248 | else 249 | { 250 | Order = SortOrder.Ascending; 251 | } 252 | } 253 | else 254 | { 255 | SortColumn = column; 256 | Order = SortOrder.Ascending; 257 | } 258 | listView.Sort(); 259 | } 260 | } 261 | } 262 | } 263 | -------------------------------------------------------------------------------- /JumpListExplorer/Main.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 17, 17 122 | 123 | 124 | 286, 17 125 | 126 | 127 | 153, 17 128 | 129 | -------------------------------------------------------------------------------- /JumpListExplorer/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace JumpListExplorer 5 | { 6 | internal static class Program 7 | { 8 | [STAThread] 9 | static void Main() 10 | { 11 | ApplicationConfiguration.Initialize(); 12 | Application.Run(new Main()); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /JumpListExplorer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using System.Runtime.Versioning; 4 | 5 | [assembly: AssemblyCopyright("Copyright (C) 2022-2025 Simon Mourier. All rights reserved.")] 6 | [assembly: AssemblyTitle("Windows Jump List Explorer")] 7 | #if DEBUG 8 | [assembly: AssemblyConfiguration("DEBUG")] 9 | #else 10 | [assembly: AssemblyConfiguration("RELEASE")] 11 | #endif 12 | [assembly: AssemblyDescription("Windows Jump List Explorer")] 13 | [assembly: AssemblyCompany("Simon Mourier")] 14 | [assembly: AssemblyProduct("Windows Jump List Explorer")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | [assembly: ComVisible(false)] 18 | [assembly: Guid("c9ce0ba6-4c4e-4d31-b1c2-e002a78f83fc")] 19 | [assembly: SupportedOSPlatform("windows")] -------------------------------------------------------------------------------- /JumpListExplorer/Properties/AssemblyVersionInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyVersion("1.2.0.1")] 4 | [assembly: AssemblyFileVersion("1.2.0.1")] 5 | [assembly: AssemblyInformationalVersion("1.2.0.1")] 6 | -------------------------------------------------------------------------------- /JumpListExplorer/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace JumpListExplorer { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JumpListExplorer.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Windows Jump List Explorer. 65 | /// 66 | internal static string AppName { 67 | get { 68 | return ResourceManager.GetString("AppName", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Confirmation. 74 | /// 75 | internal static string Confirmation { 76 | get { 77 | return ResourceManager.GetString("Confirmation", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Error. 83 | /// 84 | internal static string Error { 85 | get { 86 | return ResourceManager.GetString("Error", resourceCulture); 87 | } 88 | } 89 | 90 | /// 91 | /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). 92 | /// 93 | internal static System.Drawing.Icon JumpListExplorerIcon { 94 | get { 95 | object obj = ResourceManager.GetObject("JumpListExplorerIcon", resourceCulture); 96 | return ((System.Drawing.Icon)(obj)); 97 | } 98 | } 99 | 100 | /// 101 | /// Looks up a localized string similar to Warning. 102 | /// 103 | internal static string Warning { 104 | get { 105 | return ResourceManager.GetString("Warning", resourceCulture); 106 | } 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /JumpListExplorer/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Confirmation 122 | 123 | 124 | Error 125 | 126 | 127 | Warning 128 | 129 | 130 | Windows Jump List Explorer 131 | 132 | 133 | 134 | JumpListExplorer.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | -------------------------------------------------------------------------------- /JumpListExplorer/Shell/AutomaticDestinationList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using JumpListExplorer.Interop; 7 | using Microsoft.Win32; 8 | 9 | namespace JumpListExplorer.Shell 10 | { 11 | public static class AutomaticDestinationList 12 | { 13 | public static IEnumerable GetItems(string aumid) 14 | { 15 | ArgumentNullException.ThrowIfNull(aumid); 16 | 17 | var list = (IAutomaticDestinationList)new CLSID_AutomaticDestinationList(); 18 | var hr = list.Initialize(aumid, null, null); 19 | if (hr.IsError) 20 | yield break; 21 | 22 | hr = list.GetList(DESTLISTTYPE.RECENT, int.MaxValue, GETDESTLISTFLAGS.NONE, typeof(IObjectCollection).GUID, out var coll); 23 | if (hr.IsError || coll == null) 24 | yield break; 25 | 26 | coll.GetCount(out var count); 27 | for (var i = 0; i < count; i++) 28 | { 29 | hr = coll.GetAt(i, Native.IID_IUnknown, out var obj); 30 | if (hr.IsError) 31 | continue; 32 | 33 | if (obj is IShellItem item) 34 | yield return new Item(item); 35 | } 36 | } 37 | 38 | public static int RemoveItems(string aumid, IEnumerable items) 39 | { 40 | ArgumentNullException.ThrowIfNull(aumid); 41 | ArgumentNullException.ThrowIfNull(items); 42 | 43 | if (!items.Any()) 44 | return 0; 45 | 46 | var list = (IAutomaticDestinationList)new CLSID_AutomaticDestinationList(); 47 | var hr = list.Initialize(aumid, null, null); 48 | if (hr.IsError) 49 | return 0; 50 | hr = list.GetList(DESTLISTTYPE.RECENT, int.MaxValue, GETDESTLISTFLAGS.NONE, typeof(IObjectCollection).GUID, out _); 51 | if (hr.IsError) 52 | return 0; 53 | 54 | var count = 0; 55 | foreach (var item in items) 56 | { 57 | hr = list.RemoveDestination(item.NativeObject); 58 | if (hr.IsSuccess) 59 | { 60 | count++; 61 | } 62 | } 63 | return count; 64 | } 65 | 66 | public static IEnumerable EnumerateAppUserModelIDs() 67 | { 68 | var list = EnumerateAppUserModelIDsFromClassesRoot().ToHashSet(); 69 | foreach (var id in EnumerateAppUserModelIDsFromJumpListData()) 70 | { 71 | list.Add(id); 72 | } 73 | return list; 74 | } 75 | 76 | private static IEnumerable EnumerateAppUserModelIDsFromJumpListData() 77 | { 78 | using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Search\JumplistData", false); 79 | if (key == null) 80 | yield break; 81 | 82 | foreach (var name in key.GetValueNames()) 83 | { 84 | yield return name; 85 | } 86 | } 87 | 88 | private static IEnumerable EnumerateAppUserModelIDsFromClassesRoot() 89 | { 90 | using var key = Registry.ClassesRoot; 91 | if (key == null) 92 | yield break; 93 | 94 | foreach (var name in key.GetSubKeyNames()) 95 | { 96 | using var app = key.OpenSubKey(Path.Combine(name, "Application"), false); 97 | if (app != null) 98 | { 99 | if (app.GetValue("AppUserModelID") is string aumid) 100 | yield return aumid; 101 | } 102 | } 103 | } 104 | 105 | [ComImport, Guid("f0ae1542-f497-484b-a175-a20db09144ba")] 106 | private class CLSID_AutomaticDestinationList { } 107 | 108 | private enum DESTLISTTYPE 109 | { 110 | PINNED = 0, 111 | RECENT = 1, 112 | FREQUENT = 2 113 | } 114 | 115 | [Flags] 116 | private enum GETDESTLISTFLAGS 117 | { 118 | NONE = 0x0, 119 | EXCLUDE_UNNAMED_DESTINATIONS = 0x1, 120 | } 121 | 122 | [ComImport, Guid("e9c5ef8d-fd41-4f72-ba87-eb03bad5817c"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 123 | private interface IAutomaticDestinationList 124 | { 125 | [PreserveSig] 126 | HRESULT Initialize([MarshalAs(UnmanagedType.LPWStr)] string appid, [MarshalAs(UnmanagedType.LPWStr)] string? b, [MarshalAs(UnmanagedType.LPWStr)] string? c); 127 | 128 | [PreserveSig] 129 | HRESULT HasList(out bool has); 130 | 131 | [PreserveSig] 132 | HRESULT GetList(DESTLISTTYPE type, int count, GETDESTLISTFLAGS flags, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IObjectCollection obj); 133 | 134 | [PreserveSig] 135 | HRESULT AddUsagePoint([MarshalAs(UnmanagedType.IUnknown)] object obj); 136 | 137 | [PreserveSig] 138 | HRESULT PinItem([MarshalAs(UnmanagedType.IUnknown)] object obj, bool pinned); 139 | 140 | [PreserveSig] 141 | HRESULT IsPinned([MarshalAs(UnmanagedType.IUnknown)] object obj, out bool pinned); 142 | 143 | [PreserveSig] 144 | HRESULT RemoveDestination([MarshalAs(UnmanagedType.IUnknown)] object obj); 145 | 146 | [PreserveSig] 147 | HRESULT SetUsageData([MarshalAs(UnmanagedType.IUnknown)] object obj, ref float fl, ref long fileTime); 148 | 149 | [PreserveSig] 150 | HRESULT GetUsageData([MarshalAs(UnmanagedType.IUnknown)] object obj, ref float fl, ref long fileTime); 151 | 152 | [PreserveSig] 153 | HRESULT ResolveDestination(IntPtr hwnd, int i, [MarshalAs(UnmanagedType.IUnknown)] object shellItem, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object obj); 154 | 155 | [PreserveSig] 156 | HRESULT ClearList(int i); 157 | } 158 | 159 | [ComImport, Guid("92ca9dcd-5622-4bba-a805-5e9f541bd8c9"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 160 | private interface IObjectArray 161 | { 162 | [PreserveSig] 163 | HRESULT GetCount(out int count); 164 | 165 | [PreserveSig] 166 | HRESULT GetAt(int index, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object obj); 167 | } 168 | 169 | [ComImport, Guid("5632b1a4-e38a-400a-928a-d4cd63230295"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] 170 | private interface IObjectCollection : IObjectArray 171 | { 172 | // IObjectArray 173 | [PreserveSig] 174 | new HRESULT GetCount(out int count); 175 | 176 | [PreserveSig] 177 | new HRESULT GetAt(int index, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object obj); 178 | 179 | // IObjectCollection 180 | [PreserveSig] 181 | HRESULT AddObject([MarshalAs(UnmanagedType.IUnknown)] object punk); 182 | 183 | [PreserveSig] 184 | HRESULT AddFromArray(IObjectArray source); 185 | 186 | [PreserveSig] 187 | HRESULT RemoveObjectAt(int index); 188 | 189 | [PreserveSig] 190 | HRESULT Clear(); 191 | } 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /JumpListExplorer/Shell/Folder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Runtime.InteropServices.ComTypes; 4 | using JumpListExplorer.Interop; 5 | using JumpListExplorer.Utilities; 6 | 7 | namespace JumpListExplorer.Shell 8 | { 9 | public class Folder : Item 10 | { 11 | private static readonly Lazy _desktop = new(() => GetKnownFolder(KNOWNFOLDERID.FOLDERID_Desktop)!); 12 | public static Folder Desktop => _desktop.Value; 13 | public static Guid ShellFSFolder { get; } = new("f3364ba0-65b9-11ce-a9ba-00aa004ae837"); 14 | 15 | public Folder(object? shellItem) 16 | : base(shellItem) 17 | { 18 | } 19 | 20 | public Guid ClassId 21 | { 22 | get 23 | { 24 | _shellItem.BindToHandler(null, BHID.BHID_SFObject, typeof(IPersist).GUID, out var obj); 25 | var clsid = Guid.Empty; 26 | if (obj is IPersist persist) 27 | { 28 | persist.GetClassID(out clsid); 29 | } 30 | return clsid; 31 | } 32 | } 33 | 34 | public IEnumerable Children => EnumerateChildren(); 35 | public IEnumerable EnumerateChildren(SHCONTF? flags = null) 36 | { 37 | //+ see https://devblogs.microsoft.com/oldnewthing/20150126-00/?p=44833 38 | IBindCtx? context = null; 39 | if (flags.HasValue) 40 | { 41 | context = Native.CreateBindCtx(); 42 | const string STR_ENUM_ITEMS_FLAGS = "SHCONTF"; 43 | context.AddToBindCtx(STR_ENUM_ITEMS_FLAGS, flags.Value); 44 | } 45 | 46 | _shellItem.BindToHandler(context, BHID.BHID_EnumItems, typeof(IEnumShellItems).GUID, out var obj); 47 | if (obj == null) 48 | yield break; 49 | 50 | var enumItems = (IEnumShellItems)obj; 51 | do 52 | { 53 | IShellItem item; 54 | try 55 | { 56 | var hr = enumItems.Next(1, out item, out _); 57 | if (hr != 0) 58 | break; 59 | } 60 | catch 61 | { 62 | continue; 63 | } 64 | 65 | var child = ToItem(item); 66 | if (child != null) 67 | yield return child; 68 | } 69 | while (true); 70 | } 71 | 72 | public static Folder? GetKnownFolder(Guid id, KNOWN_FOLDER_FLAG flags = 0, IntPtr? token = null, bool throwOnError = false) 73 | { 74 | Native.SHGetKnownFolderItem(id, flags, token ?? IntPtr.Zero, typeof(IShellItem).GUID, out var obj).ThrowOnError(throwOnError); 75 | return ToItem(obj as IShellItem) as Folder; 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /JumpListExplorer/Shell/Item.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using JumpListExplorer.Interop; 5 | using JumpListExplorer.Utilities; 6 | 7 | namespace JumpListExplorer.Shell 8 | { 9 | public class Item 10 | { 11 | internal readonly IShellItem _shellItem; 12 | internal readonly IShellItem2 _shellItem2; 13 | 14 | public Item(object? shellItem) 15 | { 16 | var item = shellItem as IShellItem; 17 | ArgumentNullException.ThrowIfNull(item, nameof(shellItem)); 18 | _shellItem = item; 19 | _shellItem2 = (IShellItem2)shellItem!; 20 | _properties = new(() => GetProperties(GETPROPERTYSTOREFLAGS.GPS_DEFAULT)); 21 | } 22 | 23 | public object NativeObject => _shellItem; 24 | public string SIGDN_DESKTOPABSOLUTEEDITING { get { _shellItem.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEEDITING, out var name); return name; } } 25 | public string SIGDN_DESKTOPABSOLUTEPARSING { get { _shellItem.GetDisplayName(SIGDN.SIGDN_DESKTOPABSOLUTEPARSING, out var name); return name; } } 26 | public string SIGDN_FILESYSPATH { get { _shellItem.GetDisplayName(SIGDN.SIGDN_FILESYSPATH, out var name); return name; } } 27 | public string SIGDN_NORMALDISPLAY { get { _shellItem.GetDisplayName(SIGDN.SIGDN_NORMALDISPLAY, out var name); return name; } } 28 | public string SIGDN_PARENTRELATIVE { get { _shellItem.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVE, out var name); return name; } } 29 | public string SIGDN_PARENTRELATIVEEDITING { get { _shellItem.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVEEDITING, out var name); return name; } } 30 | public string SIGDN_PARENTRELATIVEFORADDRESSBAR { get { _shellItem.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVEFORADDRESSBAR, out var name); return name; } } 31 | public string SIGDN_PARENTRELATIVEFORUI { get { _shellItem.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVEFORUI, out var name); return name; } } 32 | public string SIGDN_PARENTRELATIVEPARSING { get { _shellItem.GetDisplayName(SIGDN.SIGDN_PARENTRELATIVEPARSING, out var name); return name; } } 33 | public string SIGDN_URL { get { _shellItem.GetDisplayName(SIGDN.SIGDN_URL, out var name); return name; } } 34 | public SFGAO Attributes { get { _shellItem.GetAttributes((SFGAO)0x7FFFFFFF, out var flags); return flags; } } 35 | public bool IsFolder => Attributes.HasFlag(SFGAO.SFGAO_FOLDER); 36 | public bool IsHidden => Attributes.HasFlag(SFGAO.SFGAO_HIDDEN); 37 | public bool IsReadOnly => Attributes.HasFlag(SFGAO.SFGAO_READONLY); 38 | public Folder? Parent { get { _shellItem.GetParent(out var item); return item == null ? null : new Folder(item); } } 39 | public long? Size => GetProperty(PROPERTYKEY.System.Size); 40 | public DateTime? DateModified => GetProperty(PROPERTYKEY.System.DateModified); 41 | public DateTime? DateAccessed => GetProperty(PROPERTYKEY.System.DateAccessed); 42 | public DateTime? DateCreated => GetProperty(PROPERTYKEY.System.DateCreated); 43 | public string? ItemType => GetProperty(PROPERTYKEY.System.ItemType); 44 | public string? ItemTypeText => GetProperty(PROPERTYKEY.System.ItemTypeText); 45 | 46 | private readonly Lazy> _properties; 47 | public IReadOnlyDictionary Properties => _properties.Value; 48 | 49 | public object? GetProperty(PROPERTYKEY pk, bool throwOnError = false) 50 | { 51 | using var pv = new PROPVARIANT(); 52 | _shellItem2.GetProperty(pk, pv).ThrowOnError(throwOnError); 53 | return pv.Value; 54 | } 55 | 56 | public T? GetProperty(PROPERTYKEY pk, T? defaultValue = default) 57 | { 58 | using var pv = new PROPVARIANT(); 59 | var hr = _shellItem2.GetProperty(pk, pv); 60 | if (hr.IsError) 61 | return defaultValue; 62 | 63 | var value = pv.Value; 64 | if (value is T t) 65 | return t; 66 | 67 | return Conversions.ChangeType(value, defaultValue); 68 | } 69 | 70 | public IReadOnlyDictionary GetProperties(GETPROPERTYSTOREFLAGS flags = GETPROPERTYSTOREFLAGS.GPS_DEFAULT) 71 | { 72 | var dic = new Dictionary(); 73 | _shellItem2.GetPropertyStore(flags, typeof(IPropertyStore).GUID, out var obj); 74 | if (obj is IPropertyStore store) 75 | { 76 | store.GetCount(out var count); 77 | for (var i = 0; i < count; i++) 78 | { 79 | if (store.GetAt(i, out var pk).IsSuccess) 80 | { 81 | using var pv = new PROPVARIANT(); 82 | store.GetValue(ref pk, pv); 83 | dic[pk] = pv.Value; 84 | } 85 | } 86 | } 87 | return dic; 88 | } 89 | 90 | public override string ToString() => SIGDN_NORMALDISPLAY; 91 | 92 | public IntPtr GetIconHandleFromImageList(SHIL shil) => IconUtilities.GetIconHandleFromImageList(_shellItem, shil); 93 | public Icon? GetIconFromImageList(SHIL shil) 94 | { 95 | var handle = GetIconHandleFromImageList(shil); 96 | if (handle == IntPtr.Zero) 97 | return null; 98 | 99 | using var icon = Icon.FromHandle(handle); 100 | var clone = (Icon)icon.Clone(); 101 | Native.DestroyIcon(handle); 102 | return clone; 103 | } 104 | 105 | internal static Item? ToItem(IShellItem? shellItem) 106 | { 107 | if (shellItem == null) 108 | return null; 109 | 110 | shellItem.GetAttributes(SFGAO.SFGAO_FOLDER, out var flags); 111 | if (flags.HasFlag(SFGAO.SFGAO_FOLDER)) 112 | return new Folder(shellItem); 113 | 114 | return new Item(shellItem); 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/AssemblyUtilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Runtime.InteropServices; 5 | 6 | namespace JumpListExplorer.Utilities 7 | { 8 | public static class AssemblyUtilities 9 | { 10 | public static string? GetCompany() => GetCompany(null); 11 | public static string? GetCompany(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Company; 12 | 13 | public static string? GetDescription() => GetDescription(null); 14 | public static string? GetDescription(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Description; 15 | 16 | public static string? GetProduct() => GetProduct(null); 17 | public static string? GetProduct(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Product; 18 | 19 | public static string? GetConfiguration() => GetConfiguration(null); 20 | public static string? GetConfiguration(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Configuration; 21 | 22 | public static string? GetTitle() => GetTitle(null); 23 | public static string? GetTitle(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Title; 24 | 25 | public static string? GetInformationalVersion() => GetInformationalVersion(null); 26 | public static string? GetInformationalVersion(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.InformationalVersion; 27 | 28 | public static string? GetFileVersion() => GetFileVersion(null); 29 | public static string? GetFileVersion(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Version; 30 | 31 | public static string? GetCopyright() => GetCopyright(null); 32 | public static string? GetCopyright(this Assembly? assembly) => (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttribute()?.Copyright; 33 | 34 | public static Guid? GetGuid() => GetGuid(null); // note we use executing assembly here 35 | public static Guid? GetGuid(this Assembly? assembly) 36 | { 37 | var sguid = (assembly ?? Assembly.GetExecutingAssembly())?.GetCustomAttribute()?.Value; 38 | if (sguid == null || !Guid.TryParse(sguid, out var guid)) 39 | return null; 40 | 41 | return guid; 42 | } 43 | 44 | public static string? GetMetatadaAttribute(string key) => GetMetatadaAttribute(null, key); 45 | public static string? GetMetatadaAttribute(this Assembly? assembly, string key) 46 | { 47 | ArgumentNullException.ThrowIfNull(key); 48 | return (assembly ?? Assembly.GetEntryAssembly())?.GetCustomAttributes()?.FirstOrDefault(a => a.Key.EqualsIgnoreCase(key))?.Value; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/Conversions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Runtime.CompilerServices; 4 | 5 | namespace JumpListExplorer.Utilities 6 | { 7 | public static class Conversions 8 | { 9 | public static bool EqualsIgnoreCase(this string? thisString, string? text, bool trim = true) 10 | { 11 | if (trim) 12 | { 13 | thisString = thisString.Nullify(); 14 | text = text.Nullify(); 15 | } 16 | 17 | if (thisString == null) 18 | return text == null; 19 | 20 | if (text == null) 21 | return false; 22 | 23 | if (thisString.Length != text.Length) 24 | return false; 25 | 26 | return string.Compare(thisString, text, StringComparison.OrdinalIgnoreCase) == 0; 27 | } 28 | 29 | public static string? Nullify(this string? text) 30 | { 31 | if (text == null) 32 | return null; 33 | 34 | if (string.IsNullOrWhiteSpace(text)) 35 | return null; 36 | 37 | var t = text.Trim(); 38 | return t.Length == 0 ? null : t; 39 | } 40 | 41 | public static object? ChangeType(object? input, Type conversionType, object? defaultValue = null, IFormatProvider? provider = null) 42 | { 43 | if (!TryChangeType(input, conversionType, provider, out object? value)) 44 | return defaultValue; 45 | 46 | return value; 47 | } 48 | 49 | public static T? ChangeType(object? input, T? defaultValue = default, IFormatProvider? provider = null) 50 | { 51 | if (!TryChangeType(input, provider, out T? value)) 52 | return defaultValue; 53 | 54 | return value; 55 | } 56 | 57 | public static bool TryChangeType(object? input, out T? value) => TryChangeType(input, null, out value); 58 | public static bool TryChangeType(object? input, IFormatProvider? provider, out T? value) 59 | { 60 | if (!TryChangeType(input, typeof(T), provider, out object? tvalue)) 61 | { 62 | value = default; 63 | return false; 64 | } 65 | 66 | value = (T?)tvalue; 67 | return true; 68 | } 69 | 70 | public static bool TryChangeType(object? input, Type conversionType, out object? value) => TryChangeType(input, conversionType, null, out value); 71 | public static bool TryChangeType(object? input, Type conversionType, IFormatProvider? provider, out object? value) 72 | { 73 | ArgumentNullException.ThrowIfNull(conversionType); 74 | if (conversionType == typeof(object)) 75 | { 76 | value = input; 77 | return true; 78 | } 79 | 80 | value = conversionType.IsValueType ? RuntimeHelpers.GetUninitializedObject(conversionType) : null; 81 | if (input == null) 82 | return !conversionType.IsValueType; 83 | 84 | var inputType = input.GetType(); 85 | if (conversionType.IsAssignableFrom(inputType)) 86 | { 87 | value = input; 88 | return true; 89 | } 90 | 91 | if (conversionType.IsEnum) 92 | return TryParseEnum(conversionType, input, out value); 93 | 94 | if (conversionType == typeof(Guid)) 95 | { 96 | var svalue = string.Format(provider, "{0}", input).Nullify(); 97 | if (svalue != null && Guid.TryParse(svalue, out Guid guid)) 98 | { 99 | value = guid; 100 | return true; 101 | } 102 | return false; 103 | } 104 | 105 | if (conversionType == typeof(Type)) 106 | { 107 | var typeName = string.Format(provider, "{0}", input).Nullify(); 108 | if (typeName == null) 109 | return false; 110 | 111 | var type = Type.GetType(typeName, false); 112 | if (type == null) 113 | return false; 114 | 115 | value = type; 116 | return true; 117 | } 118 | 119 | if (conversionType == typeof(IntPtr)) 120 | { 121 | if (IntPtr.Size == 8) 122 | { 123 | if (TryChangeType(input, provider, out long l)) 124 | { 125 | value = new IntPtr(l); 126 | return true; 127 | } 128 | } 129 | else if (TryChangeType(input, provider, out int i2)) 130 | { 131 | value = new IntPtr(i2); 132 | return true; 133 | } 134 | return false; 135 | } 136 | 137 | if (conversionType == typeof(int)) 138 | { 139 | if (inputType == typeof(uint)) 140 | { 141 | value = unchecked((int)(uint)input); 142 | return true; 143 | } 144 | 145 | if (inputType == typeof(ulong)) 146 | { 147 | value = unchecked((int)(ulong)input); 148 | return true; 149 | } 150 | 151 | if (inputType == typeof(ushort)) 152 | { 153 | value = unchecked((int)(ushort)input); 154 | return true; 155 | } 156 | 157 | if (inputType == typeof(byte)) 158 | { 159 | value = unchecked((int)(byte)input); 160 | return true; 161 | } 162 | 163 | if (input is string s) 164 | { 165 | if (int.TryParse(s, NumberStyles.Any, provider, out var si)) 166 | { 167 | value = si; 168 | return true; 169 | } 170 | return false; 171 | } 172 | } 173 | 174 | if (conversionType == typeof(long)) 175 | { 176 | if (inputType == typeof(uint)) 177 | { 178 | value = unchecked((long)(uint)input); 179 | return true; 180 | } 181 | 182 | if (inputType == typeof(ulong)) 183 | { 184 | value = unchecked((long)(ulong)input); 185 | return true; 186 | } 187 | 188 | if (inputType == typeof(ushort)) 189 | { 190 | value = unchecked((long)(ushort)input); 191 | return true; 192 | } 193 | 194 | if (inputType == typeof(byte)) 195 | { 196 | value = unchecked((long)(byte)input); 197 | return true; 198 | } 199 | 200 | if (input is string s) 201 | { 202 | if (long.TryParse(s, NumberStyles.Any, provider, out var sl)) 203 | { 204 | value = sl; 205 | return true; 206 | } 207 | return false; 208 | } 209 | } 210 | 211 | if (conversionType == typeof(short)) 212 | { 213 | if (inputType == typeof(uint)) 214 | { 215 | value = unchecked((short)(uint)input); 216 | return true; 217 | } 218 | 219 | if (inputType == typeof(ulong)) 220 | { 221 | value = unchecked((short)(ulong)input); 222 | return true; 223 | } 224 | 225 | if (inputType == typeof(ushort)) 226 | { 227 | value = unchecked((short)(ushort)input); 228 | return true; 229 | } 230 | 231 | if (inputType == typeof(byte)) 232 | { 233 | value = unchecked((short)(byte)input); 234 | return true; 235 | } 236 | 237 | if (input is string s) 238 | { 239 | if (short.TryParse(s, NumberStyles.Any, provider, out var ss)) 240 | { 241 | value = ss; 242 | return true; 243 | } 244 | return false; 245 | } 246 | } 247 | 248 | if (conversionType == typeof(sbyte)) 249 | { 250 | if (inputType == typeof(uint)) 251 | { 252 | value = unchecked((sbyte)(uint)input); 253 | return true; 254 | } 255 | 256 | if (inputType == typeof(ulong)) 257 | { 258 | value = unchecked((sbyte)(ulong)input); 259 | return true; 260 | } 261 | 262 | if (inputType == typeof(ushort)) 263 | { 264 | value = unchecked((sbyte)(ushort)input); 265 | return true; 266 | } 267 | 268 | if (inputType == typeof(byte)) 269 | { 270 | value = unchecked((sbyte)(byte)input); 271 | return true; 272 | } 273 | 274 | if (input is string s) 275 | { 276 | if (sbyte.TryParse(s, NumberStyles.Any, provider, out var sb)) 277 | { 278 | value = sb; 279 | return true; 280 | } 281 | return false; 282 | } 283 | } 284 | 285 | if (conversionType == typeof(uint)) 286 | { 287 | if (inputType == typeof(int)) 288 | { 289 | value = unchecked((uint)(int)input); 290 | return true; 291 | } 292 | 293 | if (inputType == typeof(long)) 294 | { 295 | value = unchecked((uint)(long)input); 296 | return true; 297 | } 298 | 299 | if (inputType == typeof(short)) 300 | { 301 | value = unchecked((uint)(short)input); 302 | return true; 303 | } 304 | 305 | if (inputType == typeof(sbyte)) 306 | { 307 | value = unchecked((uint)(sbyte)input); 308 | return true; 309 | } 310 | 311 | if (input is string s) 312 | { 313 | if (uint.TryParse(s, NumberStyles.Any, provider, out var ui)) 314 | { 315 | value = ui; 316 | return true; 317 | } 318 | return false; 319 | } 320 | } 321 | 322 | if (conversionType == typeof(ulong)) 323 | { 324 | if (inputType == typeof(int)) 325 | { 326 | value = unchecked((ulong)(int)input); 327 | return true; 328 | } 329 | 330 | if (inputType == typeof(long)) 331 | { 332 | value = unchecked((ulong)(long)input); 333 | return true; 334 | } 335 | 336 | if (inputType == typeof(short)) 337 | { 338 | value = unchecked((ulong)(short)input); 339 | return true; 340 | } 341 | 342 | if (inputType == typeof(sbyte)) 343 | { 344 | value = unchecked((ulong)(sbyte)input); 345 | return true; 346 | } 347 | 348 | if (input is string s) 349 | { 350 | if (ulong.TryParse(s, NumberStyles.Any, provider, out var ul)) 351 | { 352 | value = ul; 353 | return true; 354 | } 355 | return false; 356 | } 357 | } 358 | 359 | if (conversionType == typeof(ushort)) 360 | { 361 | if (inputType == typeof(int)) 362 | { 363 | value = unchecked((ushort)(int)input); 364 | return true; 365 | } 366 | 367 | if (inputType == typeof(long)) 368 | { 369 | value = unchecked((ushort)(long)input); 370 | return true; 371 | } 372 | 373 | if (inputType == typeof(short)) 374 | { 375 | value = unchecked((ushort)(short)input); 376 | return true; 377 | } 378 | 379 | if (inputType == typeof(sbyte)) 380 | { 381 | value = unchecked((ushort)(sbyte)input); 382 | return true; 383 | } 384 | 385 | if (input is string s) 386 | { 387 | if (ushort.TryParse(s, NumberStyles.Any, provider, out var us)) 388 | { 389 | value = us; 390 | return true; 391 | } 392 | return false; 393 | } 394 | } 395 | 396 | if (conversionType == typeof(byte)) 397 | { 398 | if (inputType == typeof(int)) 399 | { 400 | value = unchecked((byte)(int)input); 401 | return true; 402 | } 403 | 404 | if (inputType == typeof(long)) 405 | { 406 | value = unchecked((byte)(long)input); 407 | return true; 408 | } 409 | 410 | if (inputType == typeof(short)) 411 | { 412 | value = unchecked((byte)(short)input); 413 | return true; 414 | } 415 | 416 | if (inputType == typeof(sbyte)) 417 | { 418 | value = unchecked((byte)(sbyte)input); 419 | return true; 420 | } 421 | 422 | if (input is string s) 423 | { 424 | if (byte.TryParse(s, NumberStyles.Any, provider, out var b)) 425 | { 426 | value = b; 427 | return true; 428 | } 429 | return false; 430 | } 431 | } 432 | 433 | if (conversionType == typeof(float)) 434 | { 435 | if (input is string s) 436 | { 437 | if (float.TryParse(s, NumberStyles.Any, provider, out var fl)) 438 | { 439 | value = fl; 440 | return true; 441 | } 442 | return false; 443 | } 444 | } 445 | 446 | if (conversionType == typeof(double)) 447 | { 448 | if (input is string s) 449 | { 450 | if (double.TryParse(s, NumberStyles.Any, provider, out var dbl3)) 451 | { 452 | value = dbl3; 453 | return true; 454 | } 455 | return false; 456 | } 457 | } 458 | 459 | if (conversionType == typeof(decimal)) 460 | { 461 | if (input is string s) 462 | { 463 | if (decimal.TryParse(s, NumberStyles.Any, provider, out var dec)) 464 | { 465 | value = dec; 466 | return true; 467 | } 468 | return false; 469 | } 470 | } 471 | 472 | if (conversionType == typeof(DateTime) && input is double dbl) 473 | { 474 | try 475 | { 476 | value = DateTime.FromOADate(dbl); 477 | return true; 478 | } 479 | catch 480 | { 481 | value = DateTime.MinValue; 482 | return false; 483 | } 484 | } 485 | 486 | if (conversionType == typeof(DateTimeOffset) && input is double dbl2) 487 | { 488 | try 489 | { 490 | value = new DateTimeOffset(DateTime.FromOADate(dbl2)); 491 | return true; 492 | } 493 | catch 494 | { 495 | value = DateTimeOffset.MinValue; 496 | return false; 497 | } 498 | } 499 | 500 | if (conversionType == typeof(bool) && TryChangeType(input, out var i)) 501 | { 502 | value = i != 0; 503 | return true; 504 | } 505 | 506 | var nullable = conversionType.IsGenericType && conversionType.GetGenericTypeDefinition() == typeof(Nullable<>); 507 | if (nullable) 508 | { 509 | if (string.Empty.Equals(input)) 510 | { 511 | value = null; 512 | return true; 513 | } 514 | 515 | var type = conversionType.GetGenericArguments()[0]; 516 | if (TryChangeType(input, type, provider, out var vtValue)) 517 | { 518 | var nullableType = typeof(Nullable<>).MakeGenericType(type); 519 | value = Activator.CreateInstance(nullableType, vtValue); 520 | return true; 521 | } 522 | 523 | value = null; 524 | return false; 525 | } 526 | 527 | if (input is IConvertible convertible) 528 | { 529 | try 530 | { 531 | value = convertible.ToType(conversionType, provider); 532 | return true; 533 | } 534 | catch 535 | { 536 | // do nothing 537 | return false; 538 | } 539 | } 540 | 541 | return false; 542 | } 543 | 544 | public static ulong EnumToUInt64(object value) 545 | { 546 | ArgumentNullException.ThrowIfNull(value); 547 | var typeCode = Convert.GetTypeCode(value); 548 | switch (typeCode) 549 | { 550 | case TypeCode.SByte: 551 | case TypeCode.Int16: 552 | case TypeCode.Int32: 553 | case TypeCode.Int64: 554 | return (ulong)Convert.ToInt64(value, CultureInfo.InvariantCulture); 555 | 556 | case TypeCode.Byte: 557 | case TypeCode.UInt16: 558 | case TypeCode.UInt32: 559 | case TypeCode.UInt64: 560 | return Convert.ToUInt64(value, CultureInfo.InvariantCulture); 561 | 562 | case TypeCode.String: 563 | default: 564 | return ChangeType(value, 0, CultureInfo.InvariantCulture); 565 | } 566 | } 567 | 568 | public static bool IsFlagsEnum(Type enumType) 569 | { 570 | ArgumentNullException.ThrowIfNull(enumType); 571 | if (!enumType.IsEnum) 572 | throw new ArgumentException(null, nameof(enumType)); 573 | 574 | return enumType.IsDefined(typeof(FlagsAttribute), true); 575 | } 576 | 577 | public static int GetEnumMaxPower(Type enumType) 578 | { 579 | ArgumentNullException.ThrowIfNull(enumType); 580 | if (!enumType.IsEnum) 581 | throw new ArgumentException(null, nameof(enumType)); 582 | 583 | var type = Enum.GetUnderlyingType(enumType); 584 | return GetEnumUnderlyingTypeMaxPower(type); 585 | } 586 | 587 | public static int GetEnumUnderlyingTypeMaxPower(Type underlyingType) 588 | { 589 | ArgumentNullException.ThrowIfNull(underlyingType); 590 | if (underlyingType == typeof(long) || 591 | underlyingType == typeof(ulong)) 592 | return 64; 593 | 594 | if (underlyingType == typeof(int) || 595 | underlyingType == typeof(uint)) 596 | return 32; 597 | 598 | if (underlyingType == typeof(short) || 599 | underlyingType == typeof(ushort)) 600 | return 16; 601 | 602 | if (underlyingType == typeof(byte) || 603 | underlyingType == typeof(sbyte)) 604 | return 8; 605 | 606 | throw new ArgumentException(null, nameof(underlyingType)); 607 | } 608 | 609 | public static object EnumToObject(Type enumType, object value) 610 | { 611 | ArgumentNullException.ThrowIfNull(enumType); 612 | ArgumentNullException.ThrowIfNull(value); 613 | if (!enumType.IsEnum) 614 | throw new ArgumentException(null, nameof(enumType)); 615 | 616 | var underlyingType = Enum.GetUnderlyingType(enumType); 617 | if (underlyingType == typeof(long)) 618 | return Enum.ToObject(enumType, ChangeType(value)); 619 | 620 | if (underlyingType == typeof(ulong)) 621 | return Enum.ToObject(enumType, ChangeType(value)); 622 | 623 | if (underlyingType == typeof(int)) 624 | return Enum.ToObject(enumType, ChangeType(value)); 625 | 626 | if (underlyingType == typeof(uint)) 627 | return Enum.ToObject(enumType, ChangeType(value)); 628 | 629 | if (underlyingType == typeof(short)) 630 | return Enum.ToObject(enumType, ChangeType(value)); 631 | 632 | if (underlyingType == typeof(ushort)) 633 | return Enum.ToObject(enumType, ChangeType(value)); 634 | 635 | if (underlyingType == typeof(byte)) 636 | return Enum.ToObject(enumType, ChangeType(value)); 637 | 638 | if (underlyingType == typeof(sbyte)) 639 | return Enum.ToObject(enumType, ChangeType(value)); 640 | 641 | throw new ArgumentException(null, nameof(enumType)); 642 | } 643 | 644 | private static readonly char[] _enumSeparators = new char[] { ',', ';', '+', '|', ' ' }; 645 | 646 | public static object ToEnum(string text, Type enumType) { TryParseEnum(enumType, text, out object value); return value; } 647 | public static bool TryParseEnum(Type type, object input, out object value) 648 | { 649 | ArgumentNullException.ThrowIfNull(type); 650 | if (!type.IsEnum) 651 | throw new ArgumentException(null, nameof(type)); 652 | 653 | if (input == null) 654 | { 655 | value = RuntimeHelpers.GetUninitializedObject(type); 656 | return false; 657 | } 658 | 659 | var stringInput = string.Format(CultureInfo.InvariantCulture, "{0}", input); 660 | stringInput = stringInput.Nullify(); 661 | if (stringInput == null) 662 | { 663 | value = RuntimeHelpers.GetUninitializedObject(type); 664 | return false; 665 | } 666 | 667 | if (stringInput.StartsWith("0x", StringComparison.OrdinalIgnoreCase) && ulong.TryParse(stringInput.AsSpan(2), NumberStyles.HexNumber, null, out var ulx)) 668 | { 669 | value = ToEnum(ulx.ToString(CultureInfo.InvariantCulture), type); 670 | return true; 671 | } 672 | 673 | var names = Enum.GetNames(type); 674 | if (names.Length == 0) 675 | { 676 | value = RuntimeHelpers.GetUninitializedObject(type); 677 | return false; 678 | } 679 | 680 | var values = Enum.GetValues(type); 681 | // some enums like System.CodeDom.MemberAttributes *are* flags but are not declared with Flags... 682 | if (!type.IsDefined(typeof(FlagsAttribute), true) && stringInput.IndexOfAny(_enumSeparators) < 0) 683 | return StringToEnum(type, names, values, stringInput, out value); 684 | 685 | // multi value enum 686 | var tokens = stringInput.Split(_enumSeparators, StringSplitOptions.RemoveEmptyEntries); 687 | if (tokens.Length == 0) 688 | { 689 | value = RuntimeHelpers.GetUninitializedObject(type); 690 | return false; 691 | } 692 | 693 | ulong ul = 0; 694 | foreach (var tok in tokens) 695 | { 696 | var token = tok.Nullify(); // NOTE: we don't consider empty tokens as errors 697 | if (token == null) 698 | continue; 699 | 700 | if (!StringToEnum(type, names, values, token, out object tokenValue)) 701 | { 702 | value = RuntimeHelpers.GetUninitializedObject(type); 703 | return false; 704 | } 705 | 706 | ulong tokenUl; 707 | switch (Convert.GetTypeCode(tokenValue)) 708 | { 709 | case TypeCode.Int16: 710 | case TypeCode.Int32: 711 | case TypeCode.Int64: 712 | case TypeCode.SByte: 713 | tokenUl = (ulong)Convert.ToInt64(tokenValue, CultureInfo.InvariantCulture); 714 | break; 715 | 716 | default: 717 | tokenUl = Convert.ToUInt64(tokenValue, CultureInfo.InvariantCulture); 718 | break; 719 | } 720 | 721 | ul |= tokenUl; 722 | } 723 | value = Enum.ToObject(type, ul); 724 | return true; 725 | } 726 | 727 | private static bool StringToEnum(Type type, string[] names, Array values, string input, out object value) 728 | { 729 | for (var i = 0; i < names.Length; i++) 730 | { 731 | if (names[i].EqualsIgnoreCase(input)) 732 | { 733 | value = values.GetValue(i)!; 734 | return true; 735 | } 736 | } 737 | 738 | for (var i = 0; i < values.GetLength(0); i++) 739 | { 740 | var valuei = values.GetValue(i)!; 741 | if (input.Length > 0 && input[0] == '-') 742 | { 743 | var ul = (long)EnumToUInt64(valuei); 744 | if (ul.ToString().EqualsIgnoreCase(input)) 745 | { 746 | value = valuei; 747 | return true; 748 | } 749 | } 750 | else 751 | { 752 | var ul = EnumToUInt64(valuei); 753 | if (ul.ToString().EqualsIgnoreCase(input)) 754 | { 755 | value = valuei; 756 | return true; 757 | } 758 | } 759 | } 760 | 761 | if (char.IsDigit(input[0]) || input[0] == '-' || input[0] == '+') 762 | { 763 | var obj = EnumToObject(type, input); 764 | if (obj == null) 765 | { 766 | value = RuntimeHelpers.GetUninitializedObject(type); 767 | return false; 768 | } 769 | value = obj; 770 | return true; 771 | } 772 | 773 | value = RuntimeHelpers.GetUninitializedObject(type); 774 | return false; 775 | } 776 | } 777 | } 778 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices.ComTypes; 3 | using JumpListExplorer.Interop; 4 | 5 | namespace JumpListExplorer.Utilities 6 | { 7 | internal static class Extensions 8 | { 9 | public static HRESULT AddToBindCtx(this IBindCtx bindContext, string name, object value, bool throwOnError = true) 10 | { 11 | ArgumentNullException.ThrowIfNull(bindContext); 12 | ArgumentNullException.ThrowIfNull(name); 13 | var hr = bindContext.EnsureBindCtxPropertyBag(out var ps, throwOnError); 14 | if (hr != 0) 15 | return hr; 16 | 17 | if (ps is not IPropertyBag bag) 18 | return HRESULTS.E_FAIL; 19 | 20 | var variant = value; 21 | return bag.Write(name, ref variant).ThrowOnError(throwOnError); 22 | } 23 | 24 | public static HRESULT EnsureBindCtxPropertyBag(this IBindCtx bindContext, out object? store, bool throwOnError = true) 25 | { 26 | ArgumentNullException.ThrowIfNull(bindContext); 27 | 28 | store = null; 29 | const string STR_PROPERTYBAG_PARAM = "SHBindCtxPropertyBag"; 30 | object? unk = null; 31 | try 32 | { 33 | bindContext.GetObjectParam(STR_PROPERTYBAG_PARAM, out unk); 34 | } 35 | catch 36 | { 37 | // continue 38 | } 39 | 40 | if (unk == null) 41 | { 42 | var hr = Native.PSCreateMemoryPropertyStore(typeof(IPropertyStore).GUID, out var ps).ThrowOnError(throwOnError); 43 | if (hr != 0) 44 | return hr; 45 | 46 | store = ps; 47 | if (throwOnError) 48 | { 49 | bindContext.RegisterObjectParam(STR_PROPERTYBAG_PARAM, store); 50 | } 51 | else 52 | { 53 | try 54 | { 55 | bindContext.RegisterObjectParam(STR_PROPERTYBAG_PARAM, store); 56 | } 57 | catch 58 | { 59 | return HRESULTS.E_FAIL; 60 | } 61 | } 62 | } 63 | return HRESULTS.S_OK; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/IconUtilities.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Drawing; 3 | using System.IO; 4 | using System.Runtime.InteropServices; 5 | using System.Runtime.InteropServices.ComTypes; 6 | using JumpListExplorer.Interop; 7 | 8 | namespace JumpListExplorer.Utilities 9 | { 10 | public sealed class IconUtilities 11 | { 12 | public static Icon? GetIconFromImageList(string path, SHIL shil) 13 | { 14 | var handle = GetIconHandleFromImageList(path, shil); 15 | if (handle == IntPtr.Zero) 16 | return null; 17 | 18 | using var icon = Icon.FromHandle(handle); 19 | var clone = (Icon)icon.Clone(); 20 | Native.DestroyIcon(handle); 21 | return clone; 22 | } 23 | 24 | // note: you must call DestroyIcon on the returned icon handle once you have finished to use it 25 | public static IntPtr GetIconHandleFromImageList(string path, SHIL shil) 26 | { 27 | ArgumentNullException.ThrowIfNull(path); 28 | var ctx = CreateBindCtx(path); 29 | _ = Native.SHCreateItemFromParsingName(path, ctx, typeof(IShellItem).GUID, out var obj); 30 | if (obj == null) 31 | return IntPtr.Zero; 32 | 33 | return GetIconHandleFromImageList(obj, shil); 34 | } 35 | 36 | // create an IBindCtx for an item that doesn't exist 37 | private static IBindCtx CreateBindCtx(string name) 38 | { 39 | var data = new WIN32_FIND_DATAW 40 | { 41 | cFileName = Path.GetFileName(name), 42 | }; 43 | 44 | var bindData = new FileSystemBindData2(); 45 | bindData.SetFindData(ref data); 46 | var ctx = Native.CreateBindCtx(); 47 | 48 | const string STR_FILE_SYS_BIND_DATA = "File System Bind Data"; 49 | try 50 | { 51 | ctx.RegisterObjectParam(STR_FILE_SYS_BIND_DATA, bindData); 52 | } 53 | catch 54 | { 55 | // do nothing 56 | } 57 | 58 | var opts = new BIND_OPTS 59 | { 60 | cbStruct = Marshal.SizeOf(), 61 | grfMode = STGM_CREATE 62 | }; 63 | ctx.SetBindOptions(ref opts); 64 | try 65 | { 66 | ctx.SetBindOptions(ref opts); 67 | } 68 | catch 69 | { 70 | // continue 71 | } 72 | 73 | return ctx; 74 | } 75 | 76 | internal static IntPtr GetIconHandleFromImageList(IShellItem item, SHIL shil) 77 | { 78 | if (item is not IParentAndItem pai) 79 | return IntPtr.Zero; 80 | 81 | if (pai.GetParentAndItem(IntPtr.Zero, out var psf, out var child) < 0) 82 | return IntPtr.Zero; 83 | 84 | var index = Native.SHMapPIDLToSystemImageListIndex(psf, child, out _); 85 | Marshal.FreeCoTaskMem(child); 86 | 87 | var list = GetImageList(shil); 88 | if (list == null) 89 | return IntPtr.Zero; 90 | 91 | list.GetIcon(index, 0, out var hicon); 92 | return hicon; 93 | } 94 | 95 | private static IImageList GetImageList(SHIL shil) { _ = Native.SHGetImageList(shil, typeof(IImageList).GUID, out var ilist); return ilist; } 96 | 97 | private const int STGM_CREATE = 0x00001000; 98 | 99 | private sealed class FileSystemBindData2 : IFileSystemBindData2 100 | { 101 | private Guid _clsid; 102 | private long _fileId; 103 | private WIN32_FIND_DATAW _data; 104 | 105 | public void SetFindData(ref WIN32_FIND_DATAW data) { _data = data; } 106 | public void GetFindData(out WIN32_FIND_DATAW data) { data = _data; } 107 | public void SetFileID(long fileID) { _fileId = fileID; } 108 | public void GetFileID(out long fileId) { fileId = _fileId; } 109 | public void SetJunctionCLSID(Guid clsid) { _clsid = clsid; } 110 | public void GetJunctionCLSID(out Guid clsid) { clsid = _clsid; } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/WindowsUtilities.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.IO; 3 | 4 | namespace JumpListExplorer.Utilities 5 | { 6 | public static class WindowsUtilities 7 | { 8 | public static void OpenFile(string? fileName) 9 | { 10 | if (fileName == null) 11 | return; 12 | 13 | var psi = new ProcessStartInfo 14 | { 15 | FileName = fileName, 16 | UseShellExecute = true 17 | }; 18 | Process.Start(psi); 19 | } 20 | 21 | public static void OpenExplorer(string? directoryPath) 22 | { 23 | if (directoryPath == null) 24 | return; 25 | 26 | if (!Directory.Exists(directoryPath)) 27 | return; 28 | 29 | // see http://support.microsoft.com/kb/152457/en-us 30 | Process.Start("explorer.exe", "/e,/root,/select," + directoryPath); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /JumpListExplorer/Utilities/WinformsUtilities.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Windows.Forms; 3 | 4 | namespace JumpListExplorer.Utilities 5 | { 6 | public static class WinformsUtilities 7 | { 8 | public static string ApplicationName => Resources.AppName; 9 | public static string? ApplicationVersion => AssemblyUtilities.GetFileVersion(Assembly.GetExecutingAssembly()); 10 | public static string ApplicationTitle => ApplicationName + " V" + ApplicationVersion; 11 | 12 | public static void ShowMessage(this IWin32Window owner, string text) => MessageBox.Show(owner, text, ApplicationTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); 13 | public static DialogResult ShowConfirm(this IWin32Window owner, string text) => MessageBox.Show(owner, text, ApplicationTitle + " - " + Resources.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2); 14 | public static DialogResult ShowQuestion(this IWin32Window owner, string text) => MessageBox.Show(owner, text, ApplicationTitle + " - " + Resources.Confirmation, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); 15 | public static void ShowError(this IWin32Window owner, string text) => MessageBox.Show(owner, text, ApplicationTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); 16 | public static void ShowWarning(this IWin32Window owner, string text) => MessageBox.Show(owner, text, ApplicationTitle + " - " + Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023-2025 Simon Mourier 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JumpListExplorer 2 | A tool to view and remove Windows Jump Lists: 3 | 4 | ![image](https://github.com/smourier/JumpListExplorer/assets/5328574/25fd742b-f159-411d-8f4e-24f867b45996) 5 | 6 | PS: you can sort by application, date, name, or path. 7 | --------------------------------------------------------------------------------