Skip to content

Commit

Permalink
Merge pull request #27 from zadjii-msft/dev/crutkas/uiCleanupPart3
Browse files Browse the repository at this point in the history
Fixing string loader
  • Loading branch information
crutkas authored Sep 3, 2024
2 parents 9963a0a + 87d1762 commit 5a93de4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ internal string ResourceFromPri(string packageFullName, string resourceReference
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();
Expand Down

0 comments on commit 5a93de4

Please sign in to comment.