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
|
||||
DWORD err = 0;
|
||||
HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
|
||||
HMODULE dll = CSystem::RmLoadLibrary(path, &err);
|
||||
if (dll)
|
||||
{
|
||||
ListView_InsertItem(item, &vitem);
|
||||
|
@ -107,21 +107,17 @@ void CMeasureDiskSpace::UpdateValue()
|
||||
BOOL sizeResult = FALSE;
|
||||
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
|
||||
if (!m_DiskQuota)
|
||||
{
|
||||
UINT oldMode = SetErrorMode(0);
|
||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
|
||||
if (!m_DiskQuota)
|
||||
{
|
||||
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
||||
}
|
||||
SetErrorMode(oldMode); // Reset
|
||||
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,15 +144,10 @@ void CMeasureDiskSpace::UpdateValue()
|
||||
BOOL labelResult = FALSE;
|
||||
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);
|
||||
SetErrorMode(oldMode); // Reset
|
||||
}
|
||||
labelResult = GetVolumeInformation(drive, volumeName, MAX_PATH + 1, NULL, NULL, NULL, NULL, 0);
|
||||
}
|
||||
|
||||
m_DriveInfo = (labelResult) ? volumeName : L"";
|
||||
@ -224,12 +215,10 @@ void CMeasureDiskSpace::ReadOptions(CConfigParser& parser, const WCHAR* section)
|
||||
const WCHAR* drive = m_Drive.c_str();
|
||||
UINT type = GetDriveType(drive);
|
||||
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);
|
||||
SetErrorMode(oldMode); // Reset
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -673,6 +673,10 @@ CRainmeter::CRainmeter() :
|
||||
m_GDIplusToken(),
|
||||
m_GlobalOptions()
|
||||
{
|
||||
// Prevent the system error message boxes.
|
||||
UINT oldMode = SetErrorMode(0);
|
||||
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS);
|
||||
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
|
||||
InitCommonControls();
|
||||
|
@ -1074,16 +1074,8 @@ bool CSystem::IsFileWritable(LPCWSTR file)
|
||||
** 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
|
||||
SetDllDirectory(L"");
|
||||
|
||||
@ -1095,11 +1087,6 @@ HMODULE CSystem::RmLoadLibrary(LPCWSTR lpLibFileName, DWORD* dwError, bool ignor
|
||||
*dwError = GetLastError();
|
||||
}
|
||||
|
||||
if (ignoreErrors)
|
||||
{
|
||||
SetErrorMode(oldMode); // Reset
|
||||
}
|
||||
|
||||
return hLib;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
|
||||
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 SetClipboardText(const std::wstring& text);
|
||||
|
Loading…
x
Reference in New Issue
Block a user