File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,7 @@ static BOOLEAN NTAPI PhpPreviousInstancesCallback(
427
427
HANDLE processHandle = NULL ;
428
428
HANDLE tokenHandle = NULL ;
429
429
PTOKEN_USER tokenUser = NULL ;
430
+ ULONG attempts = 50 ;
430
431
431
432
if (objectInfo .ClientId .UniqueProcess == NtCurrentProcessId ())
432
433
goto CleanupExit ;
@@ -439,11 +440,20 @@ static BOOLEAN NTAPI PhpPreviousInstancesCallback(
439
440
if (!RtlEqualSid (tokenUser -> User .Sid , PhGetOwnTokenAttributes ().TokenSid ))
440
441
goto CleanupExit ;
441
442
442
- hwnd = PhGetProcessMainWindowEx (
443
- objectInfo .ClientId .UniqueProcess ,
444
- processHandle ,
445
- FALSE
446
- );
443
+ // Try to locate the window a few times because some users reported issues that it might not yet have been created. (dmex)
444
+ do
445
+ {
446
+ if (hwnd = PhGetProcessMainWindowEx (
447
+ objectInfo .ClientId .UniqueProcess ,
448
+ processHandle ,
449
+ FALSE
450
+ ))
451
+ {
452
+ break ;
453
+ }
454
+
455
+ PhDelayExecution (100 );
456
+ } while (-- attempts != 0 );
447
457
448
458
if (hwnd )
449
459
{
You can’t perform that action at this time.
0 commit comments