1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Windows : display the correct tray icon when explorer is restarted (i.e. after an explorer crash).

This commit is contained in:
Mounir IDRASSI
2014-09-21 21:48:59 +02:00
parent 8a028aca45
commit b80ee2b7b9
2 changed files with 18 additions and 12 deletions

View File

@@ -4404,7 +4404,7 @@ static void Benchmark (HWND hwndDlg)
} }
static BOOL CheckMountList () static BOOL CheckMountList (BOOL bForceTaskBarUpdate)
{ {
MOUNT_LIST_STRUCT current; MOUNT_LIST_STRUCT current;
static BootEncryptionStatus newBootEncStatus; static BootEncryptionStatus newBootEncStatus;
@@ -4413,7 +4413,7 @@ static BOOL CheckMountList ()
GetMountList (&current); GetMountList (&current);
if ((current.ulMountedDrives != lastUlMountedDrives || bUseDifferentTrayIconIfVolMounted != lastbUseDifferentTrayIconIfVolMounted) if ((bForceTaskBarUpdate || current.ulMountedDrives != lastUlMountedDrives || bUseDifferentTrayIconIfVolMounted != lastbUseDifferentTrayIconIfVolMounted)
&& TaskBarIconMutex != NULL) && TaskBarIconMutex != NULL)
{ {
lastUlMountedDrives = current.ulMountedDrives; lastUlMountedDrives = current.ulMountedDrives;
@@ -4422,6 +4422,11 @@ static BOOL CheckMountList ()
TaskBarIconChange (MainDlg, current.ulMountedDrives != 0 && bUseDifferentTrayIconIfVolMounted ? IDI_TRUECRYPT_MOUNTED_ICON : IDI_TRUECRYPT_ICON); TaskBarIconChange (MainDlg, current.ulMountedDrives != 0 && bUseDifferentTrayIconIfVolMounted ? IDI_TRUECRYPT_MOUNTED_ICON : IDI_TRUECRYPT_ICON);
} }
if (bForceTaskBarUpdate)
{
return TRUE;
}
if (LastKnownLogicalDrives != GetLogicalDrives() if (LastKnownLogicalDrives != GetLogicalDrives()
|| memcmp (&LastKnownMountList, &current, sizeof (current)) != 0) || memcmp (&LastKnownMountList, &current, sizeof (current)) != 0)
{ {
@@ -4910,7 +4915,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
Silent = FALSE; Silent = FALSE;
GetMountList (&LastKnownMountList); GetMountList (&LastKnownMountList);
SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL); SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL);
taskBarCreatedMsg = RegisterWindowMessage ("TaskbarCreated"); taskBarCreatedMsg = RegisterWindowMessage ("TaskbarCreated");
@@ -5065,7 +5070,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
case WM_TIMER: case WM_TIMER:
{ {
// Check mount list and update GUI if needed // Check mount list and update GUI if needed
CheckMountList (); CheckMountList (FALSE);
// Cache status // Cache status
if (IsPasswordCacheEmpty() == IsWindowEnabled (GetDlgItem (hwndDlg, IDC_WIPE_CACHE))) if (IsPasswordCacheEmpty() == IsWindowEnabled (GetDlgItem (hwndDlg, IDC_WIPE_CACHE)))
@@ -5340,7 +5345,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
} }
else if (sel >= TRAYICON_MENU_DRIVE_OFFSET + 26 && sel < TRAYICON_MENU_DRIVE_OFFSET + 26*2) else if (sel >= TRAYICON_MENU_DRIVE_OFFSET + 26 && sel < TRAYICON_MENU_DRIVE_OFFSET + 26*2)
{ {
if (CheckMountList ()) if (CheckMountList (FALSE))
{ {
if (Dismount (hwndDlg, sel - TRAYICON_MENU_DRIVE_OFFSET - 26)) if (Dismount (hwndDlg, sel - TRAYICON_MENU_DRIVE_OFFSET - 26))
{ {
@@ -5524,7 +5529,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile); KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
} }
if (CheckMountList ()) if (CheckMountList (FALSE))
Mount (hwndDlg, 0, 0); Mount (hwndDlg, 0, 0);
} }
return 1; return 1;
@@ -5620,7 +5625,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
break; break;
case IDM_UNMOUNT_VOLUME: case IDM_UNMOUNT_VOLUME:
if (CheckMountList ()) if (CheckMountList (FALSE))
Dismount (hwndDlg, 0); Dismount (hwndDlg, 0);
break; break;
@@ -5651,7 +5656,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
mountOptions = defaultMountOptions; mountOptions = defaultMountOptions;
bPrebootPasswordDlgMode = FALSE; bPrebootPasswordDlgMode = FALSE;
if (CheckMountList ()) if (CheckMountList (FALSE))
Mount (hwndDlg, 0, 0); Mount (hwndDlg, 0, 0);
} }
break; break;
@@ -5708,7 +5713,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
return 1; return 1;
} }
if (CheckMountList ()) if (CheckMountList (FALSE))
Dismount (hwndDlg, 0); Dismount (hwndDlg, 0);
return 1; return 1;
} }
@@ -5794,7 +5799,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
mountOptions.PartitionInInactiveSysEncScope = TRUE; mountOptions.PartitionInInactiveSysEncScope = TRUE;
bPrebootPasswordDlgMode = TRUE; bPrebootPasswordDlgMode = TRUE;
if (CheckMountList ()) if (CheckMountList (FALSE))
Mount (hwndDlg, 0, 0); Mount (hwndDlg, 0, 0);
bPrebootPasswordDlgMode = FALSE; bPrebootPasswordDlgMode = FALSE;
@@ -6509,6 +6514,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{ {
TaskBarIconRemove (hwndDlg); TaskBarIconRemove (hwndDlg);
TaskBarIconAdd (hwndDlg); TaskBarIconAdd (hwndDlg);
CheckMountList(TRUE);
return 1; return 1;
} }
} }
@@ -8529,7 +8535,7 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions)
KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile); KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile);
} }
if (CheckMountList ()) if (CheckMountList (FALSE))
Mount (hwndDlg, 0, 0); Mount (hwndDlg, 0, 0);
} }
else else

View File

@@ -85,7 +85,7 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo);
static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay); static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay);
static void KeyfileDefaultsDlg (HWND hwndDlg); static void KeyfileDefaultsDlg (HWND hwndDlg);
static void HandleHotKey (HWND hwndDlg, WPARAM wParam); static void HandleHotKey (HWND hwndDlg, WPARAM wParam);
static BOOL CheckMountList (); static BOOL CheckMountList (BOOL bForceTaskBarUpdate);
int GetCipherBlockSizeByDriveNo (int nDosDriveNo); int GetCipherBlockSizeByDriveNo (int nDosDriveNo);
int GetModeOfOperationByDriveNo (int nDosDriveNo); int GetModeOfOperationByDriveNo (int nDosDriveNo);
void ChangeMainWindowVisibility (); void ChangeMainWindowVisibility ();