Fixing string loader

This commit is contained in:
Clint Rutkas
2024-09-03 16:46:10 -07:00
parent 9963a0a8a5
commit 87d1762031
2 changed files with 4 additions and 4 deletions

View File

@@ -10,6 +10,6 @@ namespace AllApps.Programs;
internal sealed class Native
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1838:Avoid 'StringBuilder' parameters for P/Invokes", Justification = "<Pending>")]
public static extern int SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, int cchOutBuf, string ppvReserved);
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1838:Avoid 'StringBuilder' parameters for P/Invokes", Justification = "Part of API, can't remove")]
public static extern int SHLoadIndirectString(string pszSource, StringBuilder pszOutBuf, int cchOutBuf, IntPtr ppvReserved);
}

View File

@@ -168,13 +168,13 @@ public class UWPApplication : IProgram
var outBuffer = new StringBuilder(128);
var source = $"@{{{packageFullName}? {parsed}}}";
var hResult = Native.SHLoadIndirectString(source, outBuffer, outBuffer.Capacity, null);
var hResult = Native.SHLoadIndirectString(source, outBuffer, outBuffer.Capacity, IntPtr.Zero);
if (hResult != 0)
{
if (!string.IsNullOrEmpty(parsedFallback))
{
var sourceFallback = $"@{{{packageFullName}? {parsedFallback}}}";
hResult = Native.SHLoadIndirectString(sourceFallback, outBuffer, outBuffer.Capacity, null);
hResult = Native.SHLoadIndirectString(sourceFallback, outBuffer, outBuffer.Capacity, IntPtr.Zero);
if (hResult == 0) // HRESULT.S_OK
{
var loaded = outBuffer.ToString();