Skip to content

Commit 35ff61d

Browse files
author
Vasiliy
committed
Fixed some issues
1. OutOfMemory exception 2. Wrong icon 3. Registry integration
1 parent 8acdc55 commit 35ff61d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

build/v2.zip

-12.1 MB
Binary file not shown.

src/Console.v2/Console.v2.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<AssemblyName>FileLockedBy2</AssemblyName>
77
<RootNamespace>FileLockedBy</RootNamespace>
8-
<ApplicationIcon>unlock-128.ico</ApplicationIcon>
8+
<ApplicationIcon>unlock-64.ico</ApplicationIcon>
99
</PropertyGroup>
1010

1111
<ItemGroup>

src/Console.v2/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ static void Main(string[] args)
6464
int handleCount = information.Count;
6565
var process = Process.GetProcessById(info.Process.dwProcessId);
6666
var infoEnumerator = ProcessHelper.GetCurrentProcessOpenFilesEnumerator(info.Process.dwProcessId, sptr, handleCount);
67-
while (infoEnumerator.MoveNext())
67+
bool skip = false;
68+
while (infoEnumerator.MoveNext() && !skip)
6869
{
6970
FileHandleInfo current = infoEnumerator.Current;
7071
if (string.Compare(path, current.FileSystemInfo.FullName, StringComparison.OrdinalIgnoreCase) != 0) continue;
7172
Console.WriteLine($"Found! {process.ProcessName} -> {process.MainModule.FileName}");
7273
found = true;
74+
skip = true;
7375
var result = ProcessHelper.CloseHandle(process, current, currentProcess);
7476
Console.WriteLine(result == 0 ? "Success." : $"Error: {Enum.GetName(typeof(Error), result)}");
7577
}

src/Console.v2/Registry/ExplorerIntegration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ public static void RegisterMenuItem(string app, string path)
1313
throw new NotSupportedException("The platform is not supported.");
1414
}
1515

16-
RegistryKey shell = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Classes\\*\\shell", writable: true);
16+
RegistryKey classes = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\Classes", writable: true);
17+
RegistryKey asterisk = classes.OpenSubKey("*", writable: true) ?? classes.CreateSubKey("*");
18+
RegistryKey shell = asterisk.OpenSubKey("shell", writable: true) ?? asterisk.CreateSubKey("shell");
1719
RegistryKey unlock = shell.CreateSubKey(app, writable: true);
1820
unlock.SetValue("Icon", $"\"{path}\"");
1921
RegistryKey command = unlock.CreateSubKey("command");

0 commit comments

Comments
 (0)