mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add consistent error handling for GetArguments
This commit is contained in:
parent
0153f71083
commit
02a45661c4
1 changed files with 13 additions and 5 deletions
|
|
@ -35,10 +35,18 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
|
||||
var data = new WIN32_FIND_DATAW();
|
||||
var target = string.Empty;
|
||||
fixed (char* bufferPtr = buffer)
|
||||
try
|
||||
{
|
||||
((IShellLinkW)link).GetPath((PWSTR)bufferPtr, MAX_PATH, &data, (uint)SLGP_FLAGS.SLGP_SHORTPATH);
|
||||
target = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(bufferPtr).ToString();
|
||||
fixed (char* bufferPtr = buffer)
|
||||
{
|
||||
((IShellLinkW)link).GetPath((PWSTR)bufferPtr, MAX_PATH, &data, (uint)SLGP_FLAGS.SLGP_SHORTPATH);
|
||||
target = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(bufferPtr).ToString();
|
||||
}
|
||||
}
|
||||
catch (COMException e)
|
||||
{
|
||||
ProgramLogger.LogException($"|IShellLinkW|retrieveTargetPath|{path}" +
|
||||
"|Error occurred while getting program arguments", e);
|
||||
}
|
||||
|
||||
// To set the app description
|
||||
|
|
@ -66,11 +74,11 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
arguments = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(bufferPtr).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// To release unmanaged memory
|
||||
Marshal.ReleaseComObject(link);
|
||||
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue