Prevent user logout or shutdown

I am developing an application for Mac OS, and one of the requirements is that this application blocks the user upon logging out or shutting down the computer if the user has not completed some tasks in the application. Is it possible to achieve this with Cocoa or carbon? If so, how could I implement such functionality?

thanks

+4
source share
2 answers

This can be achieved in kiosk mode ( documentation ). Note that there are often ways around it.

+2
source

When a user tries to log out or disconnect, the system will ask all applications to log out. If any statements refuse to terminate, the action will be canceled. Since you want to undo these actions, you probably also want to prevent the application from closing normally. As part of the completion sequence, the application requests permission from its delegate. Therefore, to cancel exits and shutdowns, and also to prevent the user from exiting the application normally, you can use the application delegate to refuse the action.

- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender if([self shouldPreventTermination]) return NSTerminateCancel; return NSTerminateNow; } 
+4
source

Source: https://habr.com/ru/post/1401061/


All Articles