mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-05-17 10:53:27 +12:00
[BUG] Lnk not not resolved if target contains a dot (.) (#247), version 1.1.0.4
This commit is contained in:
parent
83fa626b08
commit
bba1bedede
|
@ -257,13 +257,13 @@ namespace SystemTrayMenu.DataClasses
|
|||
private bool SetLnk(int level, ref bool isLnkDirectory, ref string resolvedLnkPath)
|
||||
{
|
||||
bool handled = false;
|
||||
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath);
|
||||
resolvedLnkPath = FileLnk.GetResolvedFileName(TargetFilePath, out bool isFolder);
|
||||
|
||||
if (string.IsNullOrEmpty(resolvedLnkPath))
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (string.IsNullOrEmpty(Path.GetExtension(resolvedLnkPath)))
|
||||
else if (isFolder)
|
||||
{
|
||||
icon = IconReader.GetFolderIconWithCache(TargetFilePathOrig, IconReader.FolderType.Open, true, true, level == 0, out bool loading);
|
||||
IconLoading = loading;
|
||||
|
|
|
@ -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.1.0.3")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.3")]
|
||||
[assembly: AssemblyVersion("1.1.0.4")]
|
||||
[assembly: AssemblyFileVersion("1.1.0.4")]
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace SystemTrayMenu.Utilities
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Threading;
|
||||
|
@ -12,19 +13,20 @@ namespace SystemTrayMenu.Utilities
|
|||
|
||||
internal class FileLnk
|
||||
{
|
||||
public static string GetResolvedFileName(string shortcutFilename)
|
||||
public static string GetResolvedFileName(string shortcutFilename, out bool isFolder)
|
||||
{
|
||||
bool isFolderByShell = false;
|
||||
string resolvedFilename = string.Empty;
|
||||
if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
|
||||
{
|
||||
resolvedFilename = GetShortcutFileNamePath(shortcutFilename);
|
||||
resolvedFilename = GetShortcutFileNamePath(shortcutFilename, out isFolderByShell);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread staThread = new(new ParameterizedThreadStart(StaThreadMethod));
|
||||
void StaThreadMethod(object obj)
|
||||
{
|
||||
resolvedFilename = GetShortcutFileNamePath(shortcutFilename);
|
||||
resolvedFilename = GetShortcutFileNamePath(shortcutFilename, out isFolderByShell);
|
||||
}
|
||||
|
||||
staThread.SetApartmentState(ApartmentState.STA);
|
||||
|
@ -32,6 +34,7 @@ namespace SystemTrayMenu.Utilities
|
|||
staThread.Join();
|
||||
}
|
||||
|
||||
isFolder = isFolderByShell;
|
||||
return resolvedFilename;
|
||||
}
|
||||
|
||||
|
@ -67,9 +70,10 @@ namespace SystemTrayMenu.Utilities
|
|||
return pingable;
|
||||
}
|
||||
|
||||
private static string GetShortcutFileNamePath(object shortcutFilename)
|
||||
private static string GetShortcutFileNamePath(object shortcutFilename, out bool isFolder)
|
||||
{
|
||||
string resolvedFilename = string.Empty;
|
||||
isFolder = false;
|
||||
string pathOnly = Path.GetDirectoryName((string)shortcutFilename);
|
||||
string filenameOnly = Path.GetFileName((string)shortcutFilename);
|
||||
|
||||
|
@ -81,6 +85,7 @@ namespace SystemTrayMenu.Utilities
|
|||
try
|
||||
{
|
||||
ShellLinkObject link = (ShellLinkObject)folderItem.GetLink;
|
||||
isFolder = link.Target.IsFolder;
|
||||
if (string.IsNullOrEmpty(link.Path))
|
||||
{
|
||||
// https://github.com/Hofknecht/SystemTrayMenu/issues/242
|
||||
|
|
Loading…
Reference in a new issue