mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-04-26 00:32:01 +12:00
[BUG] Fix NullReferenceException as GetShortcutFileNamePath (#463), version 1.3.2.0
This commit is contained in:
parent
1d4820c946
commit
a131b2a3dd
|
@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.3.1.9")]
|
||||
[assembly: AssemblyFileVersion("1.3.1.9")]
|
||||
[assembly: AssemblyVersion("1.3.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.2.0")]
|
||||
|
|
|
@ -240,7 +240,6 @@ Special thanks to our productive contibutors!
|
|||
|
||||
Thanks for ideas, reporting issues and contributing!
|
||||
|
||||
#462 [Mario Sedlmayr](https://github.com/verdammt89x),
|
||||
#123 [Mordecai00](https://github.com/Mordecai00),
|
||||
#125 [Holgermh](https://github.com/Holgermh),
|
||||
#135 #153 #154 #164 [jakkaas](https://github.com/jakkaas),
|
||||
|
@ -274,7 +273,7 @@ Thanks for ideas, reporting issues and contributing!
|
|||
#283 #284 #289 [RuSieg](https://github.com/RuSieg),
|
||||
#285 #286 [dao-net](https://github.com/dao-net),
|
||||
#288 William P.,
|
||||
#294 #295 #296 Stefan Mahrer,
|
||||
#294 #295 #296 Stefan M.,
|
||||
#225 #297 #299 #317 #321 #324 #330 #386 #390 #401 #402 #407 #409 #414 #416 #418 #428 #430 #443 [chip33](https://github.com/chip33),
|
||||
#298 [phanirithvij](https://github.com/phanirithvij),
|
||||
#306 [wini2](https://github.com/wini2),
|
||||
|
@ -289,7 +288,10 @@ Thanks for ideas, reporting issues and contributing!
|
|||
#446 [timinformatica](https://github.com/timinformatica),
|
||||
#450 [ppt-oldoerp](https://github.com/ppt-oldoerp),
|
||||
#453 [fubaWoW](https://github.com/fubaWoW),
|
||||
#454 [WouterVanGoey](https://github.com/WouterVanGoey)
|
||||
#454 [WouterVanGoey](https://github.com/WouterVanGoey),
|
||||
#462 [verdammt89x](https://github.com/verdammt89x),
|
||||
#463 Dirk S.
|
||||
|
||||
|
||||
Donations
|
||||
------------------
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace SystemTrayMenu.Helper
|
|||
aboutBox.AppMoreInfo += "(Version 3, 29 June 2007)" + Environment.NewLine;
|
||||
|
||||
aboutBox.AppMoreInfo += "Thanks for ideas, reporting issues and contributing!" + Environment.NewLine;
|
||||
aboutBox.AppMoreInfo += "#462 verdammt89x, #123 Mordecai00, #125 Holgermh, #135 #153 #154 #164 jakkaas, #145 Pascal Aloy, #153 #158 #160 blackcrack,";
|
||||
aboutBox.AppMoreInfo += "#123 Mordecai00, #125 Holgermh, #135 #153 #154 #164 jakkaas, #145 Pascal Aloy, #153 #158 #160 blackcrack,";
|
||||
aboutBox.AppMoreInfo += "#162 HansieNL, #163 igorruckert, #171 kehoen, #186 Dtrieb, #188 #189 #191 #195 iJahangard, #195 #197 #225 #238 the-phuctran, ";
|
||||
aboutBox.AppMoreInfo += "#205 kristofzerbe, #209 jonaskohl, #211 blacksparrow15, #220 #403 Yavuz E., #229 #230 #239 Peter O., #231 Ryonez, ";
|
||||
aboutBox.AppMoreInfo += "#235 #242 243 #247, #271 Tom, #237 Torsten S., #240 video Patrick, #244 Gunter D., #246 #329 MACE4GITHUB, #259 #310 vanjac, ";
|
||||
|
@ -93,6 +93,7 @@ namespace SystemTrayMenu.Helper
|
|||
aboutBox.AppMoreInfo += "#298 phanirithvij, #306 wini2, #370 dna5589, #372 not-nef, #376 Michelle H., ";
|
||||
aboutBox.AppMoreInfo += "#377 SoenkeHob, #380 #394 TransLucida, #384 #434 #435 boydfields, #386 visusys, #387 #411 #444 yrctw" + Environment.NewLine;
|
||||
aboutBox.AppMoreInfo += "#446 timinformatica, #450 ppt-oldoerp, #453 fubaWoW, #454 WouterVanGoey" + Environment.NewLine;
|
||||
aboutBox.AppMoreInfo += "#462 verdammt89x, #463 Dirk S." + Environment.NewLine;
|
||||
aboutBox.AppMoreInfo += @"
|
||||
Sponsors - Thank you!
|
||||
------------------
|
||||
|
|
|
@ -46,42 +46,51 @@ namespace SystemTrayMenu.Utilities
|
|||
{
|
||||
string resolvedFilename = string.Empty;
|
||||
isFolder = false;
|
||||
string pathOnly = Path.GetDirectoryName((string)shortcutFilename);
|
||||
string filenameOnly = Path.GetFileName((string)shortcutFilename);
|
||||
|
||||
Shell shell = new();
|
||||
Folder folder = shell.NameSpace(pathOnly);
|
||||
FolderItem folderItem = folder.ParseName(filenameOnly);
|
||||
if (folderItem != null)
|
||||
try
|
||||
{
|
||||
try
|
||||
string pathOnly = Path.GetDirectoryName((string)shortcutFilename);
|
||||
string filenameOnly = Path.GetFileName((string)shortcutFilename);
|
||||
|
||||
Shell shell = new();
|
||||
Folder folder = shell.NameSpace(pathOnly);
|
||||
if (folder == null)
|
||||
{
|
||||
ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
|
||||
isFolder = link.Target.IsFolder;
|
||||
if (string.IsNullOrEmpty(link.Path))
|
||||
Log.Info($"{nameof(GetShortcutFileNamePath)} folder == null for path:'{shortcutFilename}'");
|
||||
return resolvedFilename;
|
||||
}
|
||||
|
||||
FolderItem folderItem = folder.ParseName(filenameOnly);
|
||||
if (folderItem == null)
|
||||
{
|
||||
Log.Info($"{nameof(GetShortcutFileNamePath)} folderItem == null for path:'{shortcutFilename}'");
|
||||
return resolvedFilename;
|
||||
}
|
||||
|
||||
ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
|
||||
isFolder = link.Target.IsFolder;
|
||||
if (string.IsNullOrEmpty(link.Path))
|
||||
{
|
||||
// https://github.com/Hofknecht/SystemTrayMenu/issues/242
|
||||
// do not set CLSID key (GUID) shortcuts as resolvedFilename
|
||||
if (!link.Target.Path.Contains("::{"))
|
||||
{
|
||||
// https://github.com/Hofknecht/SystemTrayMenu/issues/242
|
||||
// do not set CLSID key (GUID) shortcuts as resolvedFilename
|
||||
if (!link.Target.Path.Contains("::{"))
|
||||
{
|
||||
resolvedFilename = link.Target.Path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
resolvedFilename = link.Path;
|
||||
resolvedFilename = link.Target.Path;
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
else
|
||||
{
|
||||
// https://stackoverflow.com/questions/2934420/why-do-i-get-e-accessdenied-when-reading-public-shortcuts-through-shell32
|
||||
// e.g. Administrative Tools\Component Services.lnk which can not be resolved, do not spam the logfile in this case
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warn($"shortcutFilename:'{shortcutFilename}'", ex);
|
||||
resolvedFilename = link.Path;
|
||||
}
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
// https://stackoverflow.com/questions/2934420/why-do-i-get-e-accessdenied-when-reading-public-shortcuts-through-shell32
|
||||
// e.g. Administrative Tools\Component Services.lnk which can not be resolved, do not spam the logfile in this case
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Warn($"shortcutFilename:'{shortcutFilename}'", ex);
|
||||
}
|
||||
|
||||
return resolvedFilename;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue