Skip to content

Commit

Permalink
[CDPX] Fix build: move dll imports to NativeMethods (#12544)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe committed Jul 28, 2021
1 parent 0463633 commit 5a97db8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;

namespace Microsoft.PowerToys.Settings.UI.Helpers
Expand All @@ -20,6 +21,12 @@ public static class NativeMethods

[DllImport("user32.dll")]
public static extern bool AllowSetForegroundWindow(int dwProcessId);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr LoadLibrary(string dllToLoad);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern bool FreeLibrary(IntPtr hModule);
#pragma warning restore CA1401 // P/Invokes should not be visible
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,15 @@ public bool IsBackEnabled
set { Set(ref isBackEnabled, value); }
}

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibrary(string dllToLoad);

[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
private static extern bool FreeLibrary(IntPtr hModule);

public bool IsVideoConferenceBuild
{
get
{
var mfHandle = LoadLibrary("mf.dll");
var mfHandle = NativeMethods.LoadLibrary("mf.dll");
bool mfAvailable = mfHandle != null;
if (mfAvailable)
{
FreeLibrary(mfHandle);
NativeMethods.FreeLibrary(mfHandle);
}

return this != null && File.Exists("modules/VideoConference/VideoConferenceModule.dll") && mfAvailable;
Expand Down

0 comments on commit 5a97db8

Please sign in to comment.