Skip to content

Commit

Permalink
Fix compatibility with Windows 7
Browse files Browse the repository at this point in the history
Fix #11
  • Loading branch information
krlvm committed Sep 1, 2022
1 parent 8bab63e commit 67c9edd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions AccentColorizer/AccentColorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#include "SystemHelper.h"

const LPCWSTR szWindowClass = L"ACCENTCOLORIZER";
HANDLE hHandle;
HANDLE hMutex;

void ApplyAccentColorization() {
void ApplyAccentColorization()
{
if (!UpdateAccentColors())
{
// Accent Colors have not been changed.
Expand Down Expand Up @@ -49,8 +50,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
hHandle = CreateMutex(NULL, TRUE, szWindowClass);
if (!hHandle || ERROR_ALREADY_EXISTS == GetLastError())
hMutex = CreateMutex(NULL, TRUE, szWindowClass);
if (!hMutex || ERROR_ALREADY_EXISTS == GetLastError())
{
return 1;
}
Expand All @@ -61,6 +62,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
colorizeProgressBar = IsProgressBarColorizationEnabled();

ApplyAccentColorization();
if (winver < 8)
{
accent = NULL;
}

WNDCLASSEX wcex = {};
wcex.cbSize = sizeof(WNDCLASSEX);
Expand All @@ -87,8 +92,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
DispatchMessage(&msg);
}

ReleaseMutex(hHandle);
CloseHandle(hHandle);
ReleaseMutex(hMutex);
CloseHandle(hMutex);

return (int)msg.wParam;
}

0 comments on commit 67c9edd

Please sign in to comment.