========================================================================== */
#pragma data_seg(".shared")
-static HHOOK hook_ = NULL;
-static HWND hNotifyWnd_ = NULL;
+static HHOOK hook_ = nullptr;
+static HWND hNotifyWnd_ = nullptr;
static UINT notifyWndMsgId_ = 0;
#pragma data_seg()
#pragma comment(linker, "/SECTION:.shared,RWS")
-static HINSTANCE hglobInstance_ = NULL;
+static HINSTANCE hglobInstance_ = nullptr;
/* =============================================================================
Hook Function
WINMUTEDLL_API int RegisterScreensaverHook(HWND hNotifyWnd, UINT notifyWndMsgId)
{
- if (hook_ != NULL) {
+ if (hook_ != nullptr) {
UnregisterScreensaverHook();
}
hNotifyWnd_ = hNotifyWnd;
reinterpret_cast<HOOKPROC>(MsgHookProc),
hglobInstance_,
0);
- return hook_ != NULL;
+ return hook_ != nullptr;
}
WINMUTEDLL_API void UnregisterScreensaverHook()
{
- if (hook_ != NULL) {
+ if (hook_ != nullptr) {
UnhookWindowsHookEx(hook_);
- hook_ = NULL;
- hNotifyWnd_ = NULL;
+ hook_ = nullptr;
+ hNotifyWnd_ = nullptr;
notifyWndMsgId_ = 0;
}
}
{
UNREFERENCED_PARAMETER(lpReserved);
- if ((reason == DLL_PROCESS_ATTACH) && (hglobInstance_ == NULL)) {
+ if ((reason == DLL_PROCESS_ATTACH) && (hglobInstance_ == nullptr)) {
hglobInstance_ = hInstance;
}
class WinAudio;
MMNotificationClient::MMNotificationClient(WinAudio* notifyParent) :
- ref_(1), pEnumerator_(NULL), notifyParent_(notifyParent)
+ ref_(1), pEnumerator_(nullptr), notifyParent_(notifyParent)
{
}
AddRef();
*ppvInterface = (IMMNotificationClient*)this;
} else {
- *ppvInterface = NULL;
+ *ppvInterface = nullptr;
return E_NOINTERFACE;
}
return S_OK;
{
hWnd_ = CreateWindowEx(WS_EX_TOOLWINDOW,
SCRSVER_NOTIFY_WND_CLASS,
- NULL,
+ nullptr,
WS_POPUP,
0, 0, 0, 0,
HWND_MESSAGE,
0,
hglobInstance,
this);
- if (hWnd_ == NULL) {
+ if (hWnd_ == nullptr) {
PrintWindowsError(_T("CreateWindow"));
return false;
}
GetProcAddress(hookDll_, "RegisterScreensaverHook"));
unregHook_ = reinterpret_cast<UnregisterHook>(
GetProcAddress(hookDll_, "UnregisterScreensaverHook"));
- if (regHook_ == NULL || unregHook_ == NULL) {
+ if (regHook_ == nullptr || unregHook_ == nullptr) {
Unload();
}
}
}
- return hookDll_ != NULL;
+ return hookDll_ != nullptr;
}
void ScreensaverNotifier::StartScreensaverPollTimer(bool start)
{
if (start) {
- if (SetTimer(hWnd_, SCRSV_TIMER_ID, 1000, NULL) == 0) {
+ if (SetTimer(hWnd_, SCRSV_TIMER_ID, 1000, nullptr) == 0) {
PrintWindowsError(_T("SetTimer"));
}
} else {
if (SystemParametersInfo(SPI_GETSCREENSAVERRUNNING,
0,
&isRunning,
- FALSE) == NULL) {
+ FALSE) == FALSE) {
PrintWindowsError(_T("SystemParametersInfo"));
return false;
}
DWORD regError = RegCreateKeyEx(HKEY_CURRENT_USER,
LX_SYSTEMS_SUBKEY,
0,
- NULL,
+ nullptr,
0,
KEY_READ | KEY_WRITE,
- NULL,
+ nullptr,
&hRegSettingsKey_,
- NULL);
+ nullptr);
if (regError != ERROR_SUCCESS) {
PrintWindowsError(_T("RegCreateKeyEx"), regError);
return false;
DWORD regError = RegQueryValueEx(hRegSettingsKey_,
keyStr,
0,
- NULL,
+ nullptr,
reinterpret_cast<LPBYTE>(&value),
&size);
if (regError == ERROR_FILE_NOT_FOUND) {
lpszFunction,
lastError,
reinterpret_cast<TCHAR*>(lpMsgBuf));
-
- MessageBox(nullptr, static_cast<LPCTSTR>(lpDisplayBuf), _T("Error"),
- MB_ICONERROR | MB_OK);
-
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ static_cast<LPCTSTR>(lpDisplayBuf),
+ nullptr,
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
LocalFree(lpDisplayBuf);
}
LocalFree(lpMsgBuf);
IMMDevice *defaultDevice = nullptr;
if(FAILED(deviceEnumerator_->GetDefaultAudioEndpoint(eRender, eConsole,
&defaultDevice))) {
- MessageBox(0, _T("Failed to get default audio endpoint device"),
- PROGRAM_NAME, MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to get default audio endpoint device"),
+ _T("WinMute is not able to recover from that condition.\n")
+ _T("Please try restarting the program"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
return false;
}
if (FAILED(defaultDevice->Activate(__uuidof(IAudioSessionManager2),
CLSCTX_INPROC_SERVER, nullptr,
reinterpret_cast<LPVOID*>(&sessionManager2)))) {
- MessageBox(0, _T("Failed to retrieve audio session manager."),
- PROGRAM_NAME, MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to retrieve audio session manager."),
+ _T("Please try restarting the program"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
SafeRelease(&defaultDevice);
return false;
}
if (FAILED(sessionManager2->GetAudioSessionControl(nullptr, 0,
&sessionControl_))) {
- MessageBox(0, _T("Failed to retrieve session control."), PROGRAM_NAME,
- MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to retrieve session control."),
+ _T("Please try restarting the program"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
SafeRelease(&sessionManager2);
return false;
}
if (FAILED(defaultDevice->Activate(__uuidof(IAudioEndpointVolume),
CLSCTX_INPROC_SERVER, nullptr,
reinterpret_cast<LPVOID*>(&endpointVolume_)))) {
- MessageBox(0, _T("Failed to activate default audio device."),
- PROGRAM_NAME, MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to activate default audio device."),
+ _T("Please try restarting the program"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
SafeRelease(&defaultDevice);
return false;
}
notifyParent_->ShouldReInit();
break;
case DisconnectReasonServerShutdown:
- MessageBox(0, _T("The audio service has been shut down. ")
- _T("WinMute is not able to recover from that condition.\n")
- _T("Please try restarting the program"), PROGRAM_NAME,
- MB_ICONWARNING | MB_OK);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("The audio service has been shut down. "),
+ _T("WinMute is not able to recover from that condition.\n")
+ _T("Please try restarting the program"),
+ TDCBF_OK_BUTTON,
+ TD_WARNING_ICON,
+ nullptr);
break;
case DisconnectReasonSessionLogoff:
break;
_In_ int)
{
HANDLE hMutex = CreateMutex(nullptr, TRUE, _T("LxSystemsWinMute"));
- if (hMutex == NULL) {
+ if (hMutex == nullptr) {
return FALSE;
}
if (GetLastError() == ERROR_ALREADY_EXISTS) {
ReleaseMutex(hMutex);
- MessageBox(0, _T("WinMute is already running."), PROGRAM_NAME,
- MB_ICONINFORMATION);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("WinMute is already running"),
+ _T("Please look for a blue speaker icon in your Windows ")
+ _T(" taskbar notification area."),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
return FALSE;
}
INITCOMMONCONTROLSEX initComCtrl;
initComCtrl.dwSize = sizeof(INITCOMMONCONTROLSEX);
initComCtrl.dwICC = ICC_LINK_CLASS;
- if (InitCommonControlsEx(&initComCtrl) == FALSE){
- MessageBox(0, _T("Fatal Error:\n")
- _T("Failed to register extended window controls"),
- PROGRAM_NAME, MB_ICONSTOP);
+ if (InitCommonControlsEx(&initComCtrl) == FALSE) {
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to register extended window controls."),
+ _T("Please try to restart the program."),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
ReleaseMutex(hMutex);
return FALSE;
}
// <Init COM>
if (CoInitializeEx(0, COINIT_APARTMENTTHREADED) != S_OK) {
- MessageBox(0, _T("Fatal Error:\nFailed to initialize COM library."),
- PROGRAM_NAME, MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Failed to initialize COM library."),
+ _T("Please try to restart the program."),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
ReleaseMutex(hMutex);
return FALSE;
}
if (IsWindowsVistaOrGreater()) {
audio_ = std::unique_ptr<WinAudio>(new VistaAudio);
} else if (IsWindowsXPOrGreater()) {
- MessageBox(0, _T("Only Windows Vista and newer is supported"),
- 0, MB_ICONERROR);
+ TaskDialog(nullptr,
+ nullptr,
+ PROGRAM_NAME,
+ _T("Only Windows Vista and newer is supported"),
+ _T("For Windows XP support, please download WinMute ")
+ _T(" version 1.4.2 or older"),
+ TDCBF_OK_BUTTON,
+ TD_ERROR_ICON,
+ nullptr);
return false;
}
BEGIN
MENUITEM "Info", ID_TRAYMENU_INFO
MENUITEM SEPARATOR
- MENUITEM "Mute on ...", ID_TRAYMENU_MUTEON, INACTIVE
- MENUITEM "... Workstation lock", ID_TRAYMENU_MUTEONLOCK, CHECKED
- MENUITEM "... Screensaver start", ID_TRAYMENU_MUTEONSCREENSAVER, CHECKED
+ MENUITEM "Mute when ...", ID_TRAYMENU_MUTEON, INACTIVE
+ MENUITEM "... Workstation is locked", ID_TRAYMENU_MUTEONLOCK, CHECKED
+ MENUITEM "... Screensaver starts", ID_TRAYMENU_MUTEONSCREENSAVER, CHECKED
MENUITEM SEPARATOR
- MENUITEM "Restore Audio", ID_TRAYMENU_RESTOREAUDIO, CHECKED
+ MENUITEM "Restore Volume", ID_TRAYMENU_RESTOREAUDIO, CHECKED
MENUITEM SEPARATOR
MENUITEM "Mute now", ID_TRAYMENU_MUTE
MENUITEM SEPARATOR
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,194,7,50,14
- LTEXT "WinMute v1.4.2",IDC_STATIC,43,9,67,11
+ LTEXT "WinMute v1.4.3",IDC_STATIC,43,9,67,11
CONTROL "<a href=""http://lx-s.de"">lx-systems - lx-s.de</a>",IDC_LINK_HOMEPAGE,
"SysLink",WS_TABSTOP,43,31,69,13
- LTEXT "Copyright © 2014 Alexander Steinhöfer",IDC_STATIC,43,20,148,12
+ LTEXT "Copyright © 2016, Alexander Steinhöfer",IDC_STATIC,43,20,148,12
ICON IDI_APP,IDC_STATIC,13,7,20,20
END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,4,2,0
- PRODUCTVERSION 1,4,2,0
+ FILEVERSION 1,4,3,0
+ PRODUCTVERSION 1,4,3,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
BEGIN
VALUE "CompanyName", "lx-systems"
VALUE "FileDescription", "Automatic sound muter."
- VALUE "FileVersion", "1.4.2.0"
+ VALUE "FileVersion", "1.4.3.0"
VALUE "InternalName", "WinMute"
- VALUE "LegalCopyright", "Copyright (C) 2014, Alexander Steinhöfer"
+ VALUE "LegalCopyright", "Copyright (C) 2016, Alexander Steinhöfer"
VALUE "OriginalFilename", "WinMute.exe"
VALUE "ProductName", "WinMute"
- VALUE "ProductVersion", "1.4.2.0"
+ VALUE "ProductVersion", "1.4.3.0"
END
BLOCK "040704b0"
BEGIN
VALUE "CompanyName", "lx-systems"
VALUE "FileDescription", "Automatisches Stummschalten bei PC Sperre."
- VALUE "FileVersion", "1.4.2.0"
+ VALUE "FileVersion", "1.4.3.0"
VALUE "InternalName", "WinMute"
- VALUE "LegalCopyright", "Copyright (C) 2014, Alexander Steinhöfer"
+ VALUE "LegalCopyright", "Copyright (C) 2016, Alexander Steinhöfer"
VALUE "OriginalFilename", "WinMute.exe"
VALUE "ProductName", "WinMute"
- VALUE "ProductVersion", "1.4.2.0"
+ VALUE "ProductVersion", "1.4.3.0"
END
END
BLOCK "VarFileInfo"
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APP ICON "app.ico"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_ABOUT AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // German (Germany) resources
/////////////////////////////////////////////////////////////////////////////