Add timestamp to warning prompt title
This commit is contained in:
parent
967aa86b33
commit
eb4b3fae4c
3 changed files with 18 additions and 8 deletions
|
@ -127,19 +127,28 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
LockWorkStation();
|
LockWorkStation();
|
||||||
}
|
}
|
||||||
|
|
||||||
time.wMinute += 10;
|
SYSTEMTIME timeFuture = time;
|
||||||
GetLogonHoursIndices(&time, &time_zone, &lIndexSA, &lIndexBit);
|
timeFuture.wMinute += 10;
|
||||||
|
GetLogonHoursIndices(&timeFuture, &time_zone, &lIndexSA, &lIndexBit);
|
||||||
if (FAILED(SafeArrayGetElement(V_ARRAY(&varLogonHours), &lIndexSA, &bData))) {
|
if (FAILED(SafeArrayGetElement(V_ARRAY(&varLogonHours), &lIndexSA, &bData))) {
|
||||||
uiResult = 8; // Logon hour index not found
|
uiResult = 8; // Logon hour index not found
|
||||||
goto _cleanup5;
|
goto _cleanup5;
|
||||||
}
|
}
|
||||||
if (uiResult == 0 && !(bData & (1 << lIndexBit))) {
|
if (uiResult == 0 && !(bData & (1 << lIndexBit))) {
|
||||||
// Within logon hours now, but out of logon hours in 10 min.
|
// Within logon hours now, but out of logon hours in up to 10 minutes.
|
||||||
HINSTANCE hShell32Res = LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
HINSTANCE hShell32Res = LoadLibraryEx(_T("shell32.dll"), NULL, LOAD_LIBRARY_AS_IMAGE_RESOURCE);
|
||||||
LPTSTR lpTitle, lpMsgFmt, lpMsg;
|
LPTSTR lpTitleFmt;
|
||||||
LoadString(hInstance, IDS_WARNING_TITLE, (LPTSTR)&lpTitle, 0);
|
LoadString(hInstance, IDS_WARNING_TITLE_FMT, (LPTSTR)&lpTitleFmt, 0);
|
||||||
|
TCHAR szDate[0x100];
|
||||||
|
GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &time, NULL, szDate, _countof(szDate));
|
||||||
|
szDate[_countof(szDate) - 1] = 0;
|
||||||
|
TCHAR szTime[0x100];
|
||||||
|
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time, NULL, szTime, _countof(szTime));
|
||||||
|
szTime[_countof(szTime) - 1] = 0;
|
||||||
|
LPTSTR lpTitle = FormatMsg(lpTitleFmt, szDate, szTime);
|
||||||
|
LPTSTR lpMsgFmt;
|
||||||
LoadString(hInstance, IDS_WARNING_MSG_FMT, (LPTSTR)&lpMsgFmt, 0);
|
LoadString(hInstance, IDS_WARNING_MSG_FMT, (LPTSTR)&lpMsgFmt, 0);
|
||||||
lpMsg = FormatMsg(lpMsgFmt, 70 - time.wMinute);
|
LPTSTR lpMsg = FormatMsg(lpMsgFmt, 60 - time.wMinute);
|
||||||
MSGBOXPARAMS params = {
|
MSGBOXPARAMS params = {
|
||||||
sizeof(MSGBOXPARAMS), // cbSize
|
sizeof(MSGBOXPARAMS), // cbSize
|
||||||
NULL, // hwndOwner
|
NULL, // hwndOwner
|
||||||
|
@ -151,6 +160,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine
|
||||||
};
|
};
|
||||||
MessageBoxIndirect(¶ms);
|
MessageBoxIndirect(¶ms);
|
||||||
LocalFree(lpMsg);
|
LocalFree(lpMsg);
|
||||||
|
LocalFree(lpTitle);
|
||||||
FreeLibrary(hShell32Res);
|
FreeLibrary(hShell32Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
#ifndef __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||||
#define __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
#define __LOCK_IF_OUT_OF_LOGON_HOURS_H__
|
||||||
|
|
||||||
#define IDS_WARNING_TITLE 0
|
#define IDS_WARNING_TITLE_FMT 0
|
||||||
#define IDS_WARNING_MSG_FMT 1
|
#define IDS_WARNING_MSG_FMT 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue