My situation is that app runs under user rights, but installer runs with admin rights. And I need to shutdown all the instances of the app before install.
Maybe it makes sense to add this or similar code to help as it quite common task?
Following code will create or open existing event and make it signaled.
Following C++ code will create event with full access rights for everyone to the event.
Function .onInit
StrCpy $7 'Global\ExitNowEvent'
System::Call 'kernel32::CreateEvent(p0, i0, i0, tr7) p.r8'
System::Call 'kernel32::SetEvent(pr8)'
FunctionEnd
SECURITY_ATTRIBUTES sa = { 0 };
sa.nLength = sizeof(sa);
sa.bInheritHandle = false;
PSECURITY_DESCRIPTOR pSD = 0;
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD && InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION))
{
SetSecurityDescriptorDacl(pSD, true, NULL, false);// Passing NULL as DACL to allow full access by everyone
sa.lpSecurityDescriptor = pSD;
}
hExitImmediatelyEvent = CreateEvent(sa.lpSecurityDescriptor ? &sa : NULL,
false, false, L"Global\\ExitNowEvent");