mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Disabled system critical error message boxes on startup
http://msdn.microsoft.com/library/windows/desktop/ff805117.aspx
This commit is contained in:
parent
cbee39e5d5
commit
2cbdb2b9f2
@ -1002,7 +1002,7 @@ void CDialogAbout::CTabPlugins::Initialize()
|
|||||||
|
|
||||||
// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
|
// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
|
||||||
DWORD err = 0;
|
DWORD err = 0;
|
||||||
HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
|
HMODULE dll = CSystem::RmLoadLibrary(path, &err);
|
||||||
if (dll)
|
if (dll)
|
||||||
{
|
{
|
||||||
ListView_InsertItem(item, &vitem);
|
ListView_InsertItem(item, &vitem);
|
||||||
|
@ -107,12 +107,10 @@ void CMeasureDiskSpace::UpdateValue()
|
|||||||
BOOL sizeResult = FALSE;
|
BOOL sizeResult = FALSE;
|
||||||
ULONGLONG i64TotalBytes, i64FreeBytes;
|
ULONGLONG i64TotalBytes, i64FreeBytes;
|
||||||
|
|
||||||
if (type != DRIVE_NO_ROOT_DIR)
|
if (type != DRIVE_NO_ROOT_DIR &&
|
||||||
|
type != DRIVE_CDROM &&
|
||||||
|
(!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
|
||||||
{
|
|
||||||
UINT oldMode = SetErrorMode(0);
|
|
||||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
|
|
||||||
if (!m_DiskQuota)
|
if (!m_DiskQuota)
|
||||||
{
|
{
|
||||||
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
|
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
|
||||||
@ -121,8 +119,6 @@ void CMeasureDiskSpace::UpdateValue()
|
|||||||
{
|
{
|
||||||
sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
||||||
}
|
}
|
||||||
SetErrorMode(oldMode); // Reset
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizeResult)
|
if (sizeResult)
|
||||||
@ -148,15 +144,10 @@ void CMeasureDiskSpace::UpdateValue()
|
|||||||
BOOL labelResult = FALSE;
|
BOOL labelResult = FALSE;
|
||||||
WCHAR volumeName[MAX_PATH + 1];
|
WCHAR volumeName[MAX_PATH + 1];
|
||||||
|
|
||||||
if (type != DRIVE_NO_ROOT_DIR)
|
if (type != DRIVE_NO_ROOT_DIR &&
|
||||||
|
(!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore removable drives
|
||||||
{
|
{
|
||||||
if (!m_IgnoreRemovable || type != DRIVE_REMOVABLE) // Ignore removable drives
|
|
||||||
{
|
|
||||||
UINT oldMode = SetErrorMode(0);
|
|
||||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
|
|
||||||
labelResult = GetVolumeInformation(drive, volumeName, MAX_PATH + 1, NULL, NULL, NULL, NULL, 0);
|
labelResult = GetVolumeInformation(drive, volumeName, MAX_PATH + 1, NULL, NULL, NULL, NULL, 0);
|
||||||
SetErrorMode(oldMode); // Reset
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DriveInfo = (labelResult) ? volumeName : L"";
|
m_DriveInfo = (labelResult) ? volumeName : L"";
|
||||||
@ -224,12 +215,10 @@ void CMeasureDiskSpace::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
|||||||
const WCHAR* drive = m_Drive.c_str();
|
const WCHAR* drive = m_Drive.c_str();
|
||||||
UINT type = GetDriveType(drive);
|
UINT type = GetDriveType(drive);
|
||||||
if (type != DRIVE_NO_ROOT_DIR &&
|
if (type != DRIVE_NO_ROOT_DIR &&
|
||||||
type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
type != DRIVE_CDROM &&
|
||||||
|
(!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
UINT oldMode = SetErrorMode(0);
|
|
||||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
|
|
||||||
result = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
result = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
||||||
SetErrorMode(oldMode); // Reset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,6 +673,10 @@ CRainmeter::CRainmeter() :
|
|||||||
m_GDIplusToken(),
|
m_GDIplusToken(),
|
||||||
m_GlobalOptions()
|
m_GlobalOptions()
|
||||||
{
|
{
|
||||||
|
// Prevent the system error message boxes.
|
||||||
|
UINT oldMode = SetErrorMode(0);
|
||||||
|
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS);
|
||||||
|
|
||||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||||
|
|
||||||
InitCommonControls();
|
InitCommonControls();
|
||||||
|
@ -1074,16 +1074,8 @@ bool CSystem::IsFileWritable(LPCWSTR file)
|
|||||||
** Avoids loading a DLL from current directory.
|
** Avoids loading a DLL from current directory.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError, bool ignoreErrors)
|
HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError)
|
||||||
{
|
{
|
||||||
UINT oldMode;
|
|
||||||
|
|
||||||
if (ignoreErrors)
|
|
||||||
{
|
|
||||||
oldMode = SetErrorMode(0);
|
|
||||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove current directory from DLL search path
|
// Remove current directory from DLL search path
|
||||||
SetDllDirectory(L"");
|
SetDllDirectory(L"");
|
||||||
|
|
||||||
@ -1095,11 +1087,6 @@ HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError, bool ignor
|
|||||||
*dwError = GetLastError();
|
*dwError = GetLastError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreErrors)
|
|
||||||
{
|
|
||||||
SetErrorMode(oldMode); // Reset
|
|
||||||
}
|
|
||||||
|
|
||||||
return hLib;
|
return hLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
|
|
||||||
static bool IsFileWritable(LPCWSTR file);
|
static bool IsFileWritable(LPCWSTR file);
|
||||||
|
|
||||||
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL, bool ignoreErrors = false);
|
static HMODULE RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError = NULL);
|
||||||
static void ResetWorkingDirectory();
|
static void ResetWorkingDirectory();
|
||||||
|
|
||||||
static void SetClipboardText(const std::wstring& text);
|
static void SetClipboardText(const std::wstring& text);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user