diff --git a/TwitchDownloaderWPF/Services/NativeFunctions.cs b/TwitchDownloaderWPF/Services/NativeFunctions.cs
index 332fe2a5..d4a4e08d 100644
--- a/TwitchDownloaderWPF/Services/NativeFunctions.cs
+++ b/TwitchDownloaderWPF/Services/NativeFunctions.cs
@@ -5,9 +5,9 @@
namespace TwitchDownloaderWPF.Services
{
[SupportedOSPlatform("windows")]
- public static class NativeFunctions
+ public static unsafe class NativeFunctions
{
[DllImport("dwmapi.dll", EntryPoint = "DwmSetWindowAttribute", PreserveSig = true)]
- public static extern int SetWindowAttribute(IntPtr handle, int attribute, [In] ref int attributeValue, int attributeSize);
+ public static extern int SetWindowAttribute(IntPtr handle, int attribute, void* attributeValue, uint attributeSize);
}
}
\ No newline at end of file
diff --git a/TwitchDownloaderWPF/Services/ThemeService.cs b/TwitchDownloaderWPF/Services/ThemeService.cs
index a8c80d86..37708653 100644
--- a/TwitchDownloaderWPF/Services/ThemeService.cs
+++ b/TwitchDownloaderWPF/Services/ThemeService.cs
@@ -103,7 +103,13 @@ public void SetTitleBarTheme(WindowCollection windows)
foreach (Window window in windows)
{
var windowHandle = new WindowInteropHelper(window).Handle;
- NativeFunctions.SetWindowAttribute(windowHandle, darkTitleBarAttribute, ref shouldUseDarkTitleBar, sizeof(int));
+ if (windowHandle == IntPtr.Zero)
+ continue;
+
+ unsafe
+ {
+ _ = NativeFunctions.SetWindowAttribute(windowHandle, darkTitleBarAttribute, &shouldUseDarkTitleBar, sizeof(int));
+ }
}
Window wnd = new()
diff --git a/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj b/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj
index c2f05537..00e51d42 100644
--- a/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj
+++ b/TwitchDownloaderWPF/TwitchDownloaderWPF.csproj
@@ -21,6 +21,7 @@
true
false
AnyCPU;x64
+ true