Skip to content

Commit 93651c8

Browse files
authored
Merge pull request #2128 from microsoft/user/dlopez/EnableSingleUseForToast2
Modify the CoRegister for Com Activation so if there are not notification handlers registered a new process will be launched every time
2 parents a3966f9 + b326174 commit 93651c8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

dev/AppNotifications/AppNotificationManager.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,14 @@ namespace winrt::Microsoft::Windows::AppNotifications::implementation
8686
{
8787
auto lock{ m_lock.lock_exclusive() };
8888
THROW_HR_IF_MSG(E_INVALIDARG, m_notificationComActivatorRegistration, "Already Registered for App Notifications!");
89+
90+
// Check if the caller has registered event handlers, if so the REGCLS_MULTIPLEUSE flag will cause COM to ensure that all activators
91+
// are routed inproc, otherwise with REGCLS_MULTIPLEUSE COM will launch a new process of the Win32 app for each invocation.
8992
THROW_IF_FAILED(::CoRegisterClassObject(
9093
AppModel::Identity::IsPackagedProcess() ? registeredClsid : winrt::guid(storedComActivatorString),
9194
winrt::make<AppNotificationManagerFactory>().get(),
9295
CLSCTX_LOCAL_SERVER,
93-
REGCLS_MULTIPLEUSE,
96+
m_notificationHandlers ? REGCLS_MULTIPLEUSE : REGCLS_SINGLEUSE,
9497
&m_notificationComActivatorRegistration));
9598
}
9699
}

0 commit comments

Comments
 (0)