내 프로그램에서 Inno Setup을 사용하여 설치/제거합니다. 내 응용 프로그램 코드에서 CreateMutex
Windows API 함수를 사용하여 전역 뮤텍스를 만듭니다. 그렇다면 Inno Setup 프로그램에서 다음과 같은 코드를 가지고 있습니다.로그온 한 사용자가 설치/제거하려는 응용 프로그램을 실행 중인지 확인하십시오.
AppMutex=Global\MyProgramMutex.2A23834B-2919-4007-8C0A-3C7EDCA7186E
function InitializeSetup(): Boolean;
begin
Result := True;
if (CreateMutex(0, False, '{#SetupSetting('AppId')}') <> 0) and (DLLGetLastError = ERROR_ALREADY_EXISTS) then
begin
Result := False;
MsgBox('Another instance of the Setup program is already running. Please close it and try again', mbCriticalError, MB_OK);
end;
if CheckForMutexes('{#SetupSetting('AppMutex')}') then
begin
Result := False;
MsgBox('{#SetupSetting('AppName')} ' + 'appears to be running. Please close all instances of the program before continuing.', mbCriticalError, MB_OK);
end;
end;
Inno 설치 프로그램을 실행하는 사용자에게는 예상대로 좋았습니다. 내가 가진 질문/문제는 다음과 같습니다. "사용자 전환"을 선택하고 다른 사용자로 응용 프로그램을 시작한 다음 원래 사용자로 다시 전환하면 설치 프로그램이 응용 프로그램이 다른 사용자로 실행되고 있음을 감지하지 못합니다.
설치 프로그램이 실행중인 응용 프로그램을 감지 할 수있는 경우 충분한 정보를 알 수 없습니다. 이노 설치 KB Detect instances running in any user session with AppMutex에 문서화으로
보인다. 위의 코드는 설치 어셈블리 또는 응용 프로그램 어셈블리에서 제공합니까? – Botonomous
AppMutex가 작동하도록 코드를 추가 할 필요는 없습니다. 응용 프로그램의 코드가 의심 스럽습니다. [여기있다] (http://www.jrsoftware.org/iskb.php?mutexsessions) 그것에 대한 kb 엔트리. [Here] (http://stackoverflow.com/q/229565/243614)는 애플리케이션 측면에 대한 질문입니다. –