Fix crash

This commit is contained in:
Stefan Markovic 2024-02-22 14:00:28 +01:00
parent a3be4cb6d6
commit 48811ecb4d
2 changed files with 29 additions and 30 deletions

View File

@ -95,9 +95,12 @@ namespace FileLocksmith::Interop
} }
static array<System::String ^>^ ReadPathsFromPipe(System::String^ pipeName) static array<System::String ^>^ ReadPathsFromPipe(System::String^ pipeName)
{
HANDLE hStdin = INVALID_HANDLE_VALUE;
if (!pipeName->Empty)
{ {
std::wstring pipe = from_system_string(pipeName); std::wstring pipe = from_system_string(pipeName);
HANDLE hStdin;
if (pipe.size() > 0) if (pipe.size() > 0)
{ {
@ -129,6 +132,7 @@ namespace FileLocksmith::Interop
} }
} }
} }
}
else else
{ {
hStdin = GetStdHandle(STD_INPUT_HANDLE); hStdin = GetStdHandle(STD_INPUT_HANDLE);

View File

@ -82,11 +82,6 @@ namespace PowerToys.FileLocksmithUI.ViewModels
var args = Environment.GetCommandLineArgs(); var args = Environment.GetCommandLineArgs();
var pipeName = args.Where(s => s.Contains("\\\\.\\pipe\\")).FirstOrDefault(); var pipeName = args.Where(s => s.Contains("\\\\.\\pipe\\")).FirstOrDefault();
foreach (var s in args)
{
MessageBox.Show(s);
}
paths = NativeMethods.ReadPathsFromPipe(pipeName); paths = NativeMethods.ReadPathsFromPipe(pipeName);
Logger.LogInfo($"Starting FileLocksmith with {paths.Length} files selected."); Logger.LogInfo($"Starting FileLocksmith with {paths.Length} files selected.");
LoadProcessesCommand = new AsyncRelayCommand(LoadProcessesAsync); LoadProcessesCommand = new AsyncRelayCommand(LoadProcessesAsync);