Skip to content

Commit d025379

Browse files
committed
- Use Handle2 to get locking information
- Reduce amount of 3rd party dependencies - Simplify the code
1 parent 6018097 commit d025379

67 files changed

Lines changed: 938 additions & 1095 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ charset = utf-8
88
indent_style = space
99
indent_size = 4
1010

11-
[*.{xml,wxs}]
11+
[*.{xml,wxs, csproj, wixproj, config, sln, svg, manifest, json}]
1212
indent_size = 2

.github/workflows/build.ps1

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ Function CheckReturnCodeOfPreviousCommand($msg) {
1717
Function GetVersion() {
1818
$gitCommand = Get-Command -Name git
1919

20-
$nearestTag = & $gitCommand describe --exact-match --tags HEAD
20+
$tag = & $gitCommand describe --exact-match --tags HEAD
2121
if(-Not $?) {
2222
Info "The commit is not tagged. Use 'v0.0-dev' as a version instead"
23-
$nearestTag = "v0.0-dev"
23+
$tag = "v0.0-dev"
2424
}
2525

2626
$commitHash = & $gitCommand rev-parse --short HEAD
2727
CheckReturnCodeOfPreviousCommand "Failed to get git commit hash"
2828

29-
return "$($nearestTag.Substring(1))-$commitHash"
29+
return "$($tag.Substring(1))-$commitHash"
3030
}
3131

3232
Function GetInstallerVersion($version) {
@@ -86,15 +86,3 @@ CheckReturnCodeOfPreviousCommand "build failed"
8686
RemoveFileIfExists "$publishDir/${projectName}.msi.zip"
8787
Info "Create zip archive from msi installer"
8888
Compress-Archive -Path "$publishDir/$projectName.msi" -DestinationPath "$publishDir/${projectName}.msi.zip"
89-
90-
# Skip running tests if the build script is run on Github Actions.
91-
# There are no processes which lock files on Github Actions executors. It makes a lot of test fail.
92-
if ($null -eq $env:GITHUB_ACTIONS) {
93-
& "$buildDir/nuget/nunit.consolerunner/*/tools/nunit3-console.exe" `
94-
"$publishDir/net461/Test.dll" `
95-
--stoponerror `
96-
--labels=Before `
97-
--noheader `
98-
--noresult
99-
CheckReturnCodeOfPreviousCommand "tests failed"
100-
}

.github/workflows/main.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
build:
55
runs-on: windows-latest
66
steps:
7-
- uses: actions/checkout@v2
7+
- uses: actions/checkout@v3
88
- run: .github/workflows/build.ps1
99
- uses: softprops/action-gh-release@v1
1010
if: startsWith(github.ref, 'refs/tags/')
@@ -13,7 +13,7 @@ jobs:
1313
with:
1414
draft: true
1515
files: Build/Release/*.msi.zip
16-
- uses: actions/upload-artifact@v2
16+
- uses: actions/upload-artifact@v3
1717
with:
1818
name: Build artifacts
1919
path: Build/Release/*.msi.zip

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
/Build
2-
.vs/
1+
/Build/
2+
/.vs/
3+
/.idea/
4+
launchSettings.json

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
# ShowWhatProcessLocksFile
2-
An utility to discover what processes lock a specific file or folder.<br>
2+
A utility to discover what processes lock a specific file or folder.
33

44
# Screenshots
55
## Context menu
6-
![Screenshot](doc/ContextMenu.png)
7-
## The application
8-
![Screenshot](doc/Screenshot.png)
6+
<img src="doc/ContextMenu.png" width="70%" height="70%"/>
7+
8+
## Application
9+
<img src="doc/Screenshot.png" width="70%" height="70%"/>
910

1011
# System requirements
11-
* .Net Framework 4.6.1 or higher (Windows 10 already has it)
12+
* Windows 10 or higher (it can also work on Windows 8 if you install [.Net Framework 4.6.2](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net462-web-installer))
1213
* The user should be allowed to run applications as an Administrator.
1314

1415
# How it works
15-
The application uses [Handle by Mark Russinovich](https://docs.microsoft.com/en-us/sysinternals/downloads/handle) to get information about locking processes. The output of `handle.exe` is parsed and displayed in the GUI.<br>
16+
The application uses [Handle2](https://github.com/PolarGoose/Handle2) to get information about locking processes.
1617

1718
# How to use
1819
* Download `ShowWhatProcessLocksFile.msi.zip` from the latest [release](https://github.com/PolarGoose/ShowWhatProcessLocksFile/releases).
19-
* Run the installer. The installer will install this programm to the `%AppData%\ShowWhatProcessLocksFile` folder and add a "Show what locks this file" Windows File Explorer context menu element.
20-
* Use "Show what locks this file" File Explorer's context menu to select a file or folder
21-
* To terminate selected processes, open a context menu by clicking mouse right button
20+
* Run the installer. The installer will install this programm to the `%AppData%\ShowWhatProcessLocksFile` folder and add a `Show what locks this file` Windows File Explorer context menu element.
21+
* Use `Show what locks this file` File Explorer's context menu to select a file or folder
22+
* To terminate a process, select it and open a context menu by clicking right mouse button
2223
* If you want to uninstall the program, use `Control Panel\Programs\Programs and Features`, uninstaller will remove an integration with the context menu and all files which were installed.
2324

2425
# How to build
25-
* Use `Visual Studio 2019` with [Wix Toolset Visual Studio 2019 Extension](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2019Extension) and [Wix Toolset](https://wixtoolset.org/releases/).
26-
* Run `.github\workflows\build.ps1` to build a release (`git.exe` should be in your PATH)
27-
28-
# References
29-
* This tool is inspired by [LockHunter](https://lockhunter.com/)
30-
* Article about API used by `Handle.exe` with code samples: [Examine Information on Windows NT System Level Primitives](https://www.codeguru.com/cpp/w-p/system/processesmodules/article.php/c2827/Examine-Information-on-Windows-NT-System-Level-Primitives.htm)
26+
* To work with the codebase, use `Visual Studio 2022` with a plugin [HeatWave for VS2022](https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17).
27+
* To build a release, run `.github\workflows\build.ps1` (`git.exe` should be in your PATH)

ShowWhatProcessLocksFile.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio Version 16
3-
VisualStudioVersion = 16.0.31129.286
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.4.33205.214
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShowWhatProcessLocksFile", "src\App\ShowWhatProcessLocksFile.csproj", "{952F82E5-8372-4435-8318-3ED0C114A57C}"
66
EndProject

doc/ContextMenu.png

65.4 KB
Loading

doc/Screenshot.png

116 KB
Loading

src/App/App.xaml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<Application x:Class="ShowWhatProcessLocksFile.App"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:controls="clr-namespace:ShowWhatProcessLocksFile.Gui.Controls"
54
StartupUri="Gui/MainWindow.xaml">
65
<Application.Resources>
7-
<Style x:Key="ButtonStyle" TargetType="ButtonBase">
8-
<Style.Setters>
9-
<Setter Property="Background" Value="White"/>
10-
</Style.Setters>
11-
</Style>
12-
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle}"/>
13-
<Style TargetType="ToggleButton" BasedOn="{StaticResource ButtonStyle}"/>
14-
<Style TargetType="controls:IconButton" BasedOn="{StaticResource ButtonStyle}"/>
6+
<ResourceDictionary>
7+
<ResourceDictionary.MergedDictionaries>
8+
<ResourceDictionary Source="/Gui/Icons.xaml" />
9+
</ResourceDictionary.MergedDictionaries>
10+
<Style x:Key="ButtonStyle" TargetType="ButtonBase">
11+
<Style.Setters>
12+
<Setter Property="Background" Value="White" />
13+
</Style.Setters>
14+
</Style>
15+
<Style TargetType="Button" BasedOn="{StaticResource ButtonStyle}" />
16+
<Style TargetType="ToggleButton" BasedOn="{StaticResource ButtonStyle}" />
17+
</ResourceDictionary>
1518
</Application.Resources>
1619
</Application>

src/App/App.xaml.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System.Windows;
22

3-
namespace ShowWhatProcessLocksFile
3+
namespace ShowWhatProcessLocksFile;
4+
5+
public partial class App : Application
46
{
5-
public partial class App : Application
6-
{
7-
}
87
}

0 commit comments

Comments
 (0)