<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ScreensaverNotify</RootNamespace>
<ProjectName>ScreensaverNotify</ProjectName>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
- <PlatformToolset>v120_xp</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WINMUTEDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<SDLCheck>true</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
- be used to endorse or promote products derived from this software
+ be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
const std::wstring& tooltip, bool show)
{
if (!hIcon) {
- hIcon_ = LoadIcon(0, MAKEINTRESOURCE(IDI_APPLICATION));
+ hIcon_ = LoadIcon(0, IDI_APPLICATION);
} else {
hIcon_ = hIcon;
}
tnid.uFlags = NIF_ICON|NIF_TIP|NIF_MESSAGE;
tnid.hIcon = hIcon_;
tnid.uCallbackMessage = WM_TRAYICON;
- lstrcpyn(tnid.szTip, tooltip_.c_str(), sizeof(tnid.szTip) / sizeof(TCHAR));
- return Shell_NotifyIcon(NIM_ADD, &tnid) != 0;
+ if (SUCCEEDED(StringCchCopy(tnid.szTip,
+ sizeof(tnid.szTip) / sizeof(TCHAR),
+ tooltip_.c_str()))) {
+ return Shell_NotifyIcon(NIM_ADD, &tnid) != 0;
+ }
+ return false;
}
bool TrayIcon::RemoveNotifyIcon()
tnid.hWnd = hWnd_;
tnid.uID = trayID_;
tnid.uFlags = NIF_TIP;
- lstrcpyn(tnid.szTip, tooltip_.c_str(), sizeof(tnid.szTip) / sizeof(TCHAR));
- return Shell_NotifyIcon(NIM_MODIFY, &tnid) != 0;
+ if (SUCCEEDED(StringCchCopy(tnid.szTip,
+ sizeof(tnid.szTip) / sizeof(TCHAR),
+ tooltip_.c_str()))) {
+ return Shell_NotifyIcon(NIM_MODIFY, &tnid) != 0;
+ }
+ return false;
}
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
- be used to endorse or promote products derived from this software
+ be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#include "StdAfx.h"
-void PrintWindowsError(LPTSTR lpszFunction, DWORD lastError)
-{
+void PrintWindowsError(LPTSTR lpszFunction, DWORD lastError)
+{
// Retrieve the system error message for the last-error code
if (lastError == -1) {
- lastError = GetLastError();
+ lastError = GetLastError();
}
LPVOID lpMsgBuf;
if (FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, lastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
lstrlen(static_cast<LPCTSTR>(lpszFunction)) + 40)
* sizeof(TCHAR)));
if (lpDisplayBuf) {
- StringCchPrintf((LPTSTR)lpDisplayBuf,
- LocalSize(lpDisplayBuf),
- _T("%s failed with error %d: %s"),
- lpszFunction, lastError, lpMsgBuf);
+ StringCchPrintf((LPTSTR)lpDisplayBuf,
+ LocalSize(lpDisplayBuf),
+ _T("%s failed with error %ul: %s"),
+ lpszFunction,
+ lastError,
+ reinterpret_cast<TCHAR*>(lpMsgBuf));
MessageBox(nullptr, static_cast<LPCTSTR>(lpDisplayBuf), _T("Error"),
- MB_ICONERROR | MB_OK);
+ MB_ICONERROR | MB_OK);
LocalFree(lpDisplayBuf);
}
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
- be used to endorse or promote products derived from this software
+ be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#include <mmdeviceapi.h>
#pragma warning(disable : 4201)
-# include <endpointvolume.h>
+# include <endpointvolume.h>
#pragma warning(default : 4201)
#include "WinAudio.h"
wasapiAudioEvents_(nullptr), mmnAudioEvents_(nullptr),
deviceEnumerator_(nullptr), reInit_(false)
{
- CoInitialize(nullptr);
+ if (FAILED(CoInitialize(nullptr))) {
+ throw std::exception("Failed to initialize COM Library");
+ }
}
VistaAudio::~VistaAudio()
return false;
}
- if (FAILED(sessionManager2->GetAudioSessionControl(nullptr, 0,
+ if (FAILED(sessionManager2->GetAudioSessionControl(nullptr, 0,
&sessionControl_))) {
MessageBox(0, _T("Failed to retrieve session control."), PROGRAM_NAME,
MB_ICONERROR);
virtual bool IsMuted() = 0;
virtual void Mute() = 0;
virtual void UnMute() = 0;
- virtual ~WinAudio() { };
+ virtual ~WinAudio() noexcept { };
};
class XPAudio : public WinAudio {
public:
XPAudio();
- ~XPAudio();
+ ~XPAudio() noexcept;
bool Init(HWND hParent);
void ShouldReInit();
time_t muteTime_;
// non copy-able
- XPAudio(const XPAudio& other);
- XPAudio& operator=(const XPAudio& other);
+ XPAudio(const XPAudio& other) = delete;
+ XPAudio& operator=(const XPAudio& other) = delete;
};
// Forwards
class VistaAudio : public WinAudio {
public:
VistaAudio();
- ~VistaAudio();
+ ~VistaAudio() noexcept;
bool Init(HWND hParent);
void ShouldReInit();
HWND hParent_;
// non copy-able
- VistaAudio(const VistaAudio& other);
- VistaAudio& operator=(const VistaAudio& other);
+ VistaAudio(const VistaAudio& other) = delete;
+ VistaAudio& operator=(const VistaAudio& other) = delete;
};
\ No newline at end of file
HINSTANCE hglobInstance;
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
+int WINAPI wWinMain(_In_ HINSTANCE hInstance,
+ _In_opt_ HINSTANCE,
+ _In_ PWSTR,
+ _In_ int)
{
HANDLE hMutex = CreateMutex(nullptr, TRUE, _T("BinaryStudiosWinMute"));
if (hMutex == NULL) {
<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<ProjectGuid>{488617F0-5DD3-42B5-81ED-A1E9B3117551}</ProjectGuid>
<RootNamespace>WinMute</RootNamespace>
<Keyword>Win32Proj</Keyword>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v120_xp</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
- <PlatformToolset>v120</PlatformToolset>
+ <PlatformToolset>v140</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <TreatWarningAsError>true</TreatWarningAsError>
+ <SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <TreatWarningAsError>true</TreatWarningAsError>
+ <SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>strsafe.lib;comctl32.lib;WtsApi32.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
static void PrintMixerError(const tstring& funcName, MMRESULT err)
{
-//#ifdef _DEBUG
+#ifdef _DEBUG
std::basic_string<TCHAR> error = funcName + L" failed with: ";
switch (err) {
case MIXERR_INVALCONTROL:
}
}
MessageBox(0, error.c_str(), 0, MB_ICONERROR);
-//#else
-// UNREFERENCED_PARAMETER(funcName);
-// UNREFERENCED_PARAMETER(err);
-//#endif
+#else
+ UNREFERENCED_PARAMETER(funcName);
+ UNREFERENCED_PARAMETER(err);
+#endif
}
XPAudio::XPAudio() :
mxcd.cChannels = 1;
MIXERCONTROLDETAILS_UNSIGNED mxCtrlDetVolume = { val };
- MIXERCONTROLDETAILS_BOOLEAN mxCtrlDetMuted = { val };
+ MIXERCONTROLDETAILS_BOOLEAN mxCtrlDetMuted = { static_cast<LONG>(val) };
if (md.useMute) {
mxcd.dwControlID = md.muteCtrlID;