- var
- MutexHandle: THandle;
- begin
- Application.Initialize;
- MutexHandle := CreateMutex(nil, TRUE, 'CodeEditorMuteX');
- if MutexHandle <> 0 then
- begin
- if GetLastError = ERROR_ALREADY_EXISTS then
- begin
- CloseHandle(MutexHandle);
- Application.Terminate;
- Halt;
- end;
- end;
- [...]
- end;