const LPSYSTEMTIME start,
const LPSYSTEMTIME end)
{
- bool isValid = false;
- if (start->wHour == end->wHour) {
- if (start->wMinute == end->wMinute) {
- if (start->wSecond < end->wSecond) {
- isValid = true;
- }
- } else if (start->wMinute < end->wMinute) {
- isValid = true;
- }
- } else if (start->wHour < end->wHour) {
- isValid = true;
+ bool isValid = true;
+ if (start->wHour == end->wHour &&
+ start->wMinute == end->wMinute &&
+ start->wSecond == end->wSecond) {
+ isValid = false;
}
return isValid;
}
nullptr,
PROGRAM_NAME,
_T("Invalid time range"),
- _T("Quiet hours must end before they start.\n")
- _T("Please correct your input.\n"),
+ _T("Can't start and stop at the same time.\n")
+ _T("Please correct your time range.\n"),
TDCBF_OK_BUTTON,
TD_WARNING_ICON,
nullptr);
return false;
}
- ResetQuietHours();
-
hTrayIcon_ = LoadIcon(hglobInstance, MAKEINTRESOURCE(IDI_TRAY));
if (hTrayIcon_ == NULL) {
PrintWindowsError(_T("LoadIcon"));
return false;
}
trayIcon_.Init(hWnd_, 0, hTrayIcon_, _T("WinMute"), true);
+
+ ResetQuietHours();
+
return true;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
+static __int64 ConvertSystemTimeTo100NS(const LPSYSTEMTIME sysTime)
+{
+ FILETIME ft;
+ SystemTimeToFileTime(sysTime, &ft);
+ ULARGE_INTEGER ulInt;
+ ulInt.HighPart = ft.dwHighDateTime;
+ ulInt.LowPart = ft.dwLowDateTime;
+ return static_cast<__int64>(ulInt.QuadPart);
+}
+
static bool QuietHoursShouldAlreadyHaveStarted(
const LPSYSTEMTIME now,
const LPSYSTEMTIME qhStart,
const LPSYSTEMTIME qhEnd)
{
- FILETIME ftNow;
- FILETIME ftStart;
- FILETIME ftEnd;
- ULARGE_INTEGER ulNow;
- ULARGE_INTEGER ulStart;
- ULARGE_INTEGER ulEnd;
-
- SystemTimeToFileTime(now, &ftNow);
- SystemTimeToFileTime(qhStart, &ftStart);
- SystemTimeToFileTime(qhEnd, &ftEnd);
-
- ulNow.LowPart = ftNow.dwLowDateTime;
- ulNow.HighPart = ftNow.dwHighDateTime;
- ulStart.LowPart = ftStart.dwLowDateTime;
- ulStart.HighPart = ftStart.dwHighDateTime;
- ulEnd.LowPart = ftEnd.dwLowDateTime;
- ulEnd.HighPart = ftEnd.dwHighDateTime;
-
- if (ulEnd.QuadPart - ulNow.QuadPart > 0 &&
- ulStart.QuadPart - ulNow.QuadPart < 0) {
+ __int64 iStart = ConvertSystemTimeTo100NS(qhStart);
+ __int64 iEnd = ConvertSystemTimeTo100NS(qhEnd);
+ __int64 iNow = ConvertSystemTimeTo100NS(now);
+
+ if (iEnd < iStart) {
+ // Add one day
+ iEnd += 864000000000ll;
+ }
+
+ if (iEnd - iNow > 0 && iStart - iNow < 0) {
return true;
}
*/
static int GetDiffMillseconds(const LPSYSTEMTIME t1, const LPSYSTEMTIME t2)
{
- FILETIME ftT1;
- FILETIME ftT2;
- ULARGE_INTEGER ulT1;
- ULARGE_INTEGER ulT2;
- __int64 res;
- SystemTimeToFileTime(t1, &ftT1);
- ulT1.LowPart = ftT1.dwLowDateTime;
- ulT1.HighPart = ftT1.dwHighDateTime;
- SystemTimeToFileTime(t2, &ftT2);
- ulT2.LowPart = ftT2.dwLowDateTime;
- ulT2.HighPart = ftT2.dwHighDateTime;
-
- res = ulT1.QuadPart - ulT2.QuadPart;
+ __int64 it1 = ConvertSystemTimeTo100NS(t1);
+ __int64 it2 = ConvertSystemTimeTo100NS(t2);
+
+ __int64 res = it1 - it2;
res /= (1000000000 / 100); // To seconds
if (res < 0) { // Add 24 Hours for Wrap Around
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "lx-systems"
- VALUE "FileDescription", "Automatic volume muting."
+ VALUE "FileDescription", "WinMute"
VALUE "FileVersion", "1.6.0.0"
VALUE "InternalName", "WinMute"
VALUE "LegalCopyright", "Copyright (c) 2020, Alexander Steinhöfer"
BLOCK "040704b0"
BEGIN
VALUE "CompanyName", "lx-systems"
- VALUE "FileDescription", "Automatisches Stummschalten des PCs."
+ VALUE "FileDescription", "WinMute"
VALUE "FileVersion", "1.6.0.0"
VALUE "InternalName", "WinMute"
VALUE "LegalCopyright", "Copyright (c) 2020, Alexander Steinhöfer"