Skip to content

Commit

Permalink
Use newly cocreatable ShellLink from updated CsWin32
Browse files Browse the repository at this point in the history
  - In CsWin32 0.1.635-beta, the ShellLink class became cocreatable, which allows me to restore my original method of creating a `ShellLink`. See microsoft/CsWin32#453.
  • Loading branch information
craigktreasure committed Mar 11, 2022
1 parent c42605d commit 3c13498
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/StartMenuCleaner/Utils/CsWin32ShortcutHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ public unsafe string ResolveTarget(string shortcutPath)
throw new NotSupportedException($"{nameof(ResolveTarget)} is only supported on Windows 5.1.2600+.");
}

// See the following issues for current status and new advice:
// https://github.com/microsoft/CsWin32/issues/453
// https://github.com/microsoft/CsWin32/discussions/323
IPersistFile shellLink = (IPersistFile)(Activator.CreateInstance(Type.GetTypeFromCLSID(typeof(ShellLink).GUID, throwOnError: true)!)
?? throw new InvalidOperationException("Failed to create an instance of ShellLink"));
IPersistFile shellLink = (IPersistFile)new ShellLink();

fixed (char* shortcutFilePathPcwstr = shortcutPath)
{
Expand Down

0 comments on commit 3c13498

Please sign in to comment.