Mike Torrettinni 198 Posted March 29, 2019 Is there an option to find out if another process is running 'as admin', with elevated rights? My project doesn't run as admin by default, so WM_COPYDATA doesn't work when the other application (which I have no control over) runs as admin. So I would like to check and if it does, to show message "Other application running with elevated rights, close your project and check 'Run as Administrator' and run again"... I was sure this is quite common task, but search didn't provide anything useful, except for plenty of suggestions on how to find if my own process runs with elevated rights. But I need to know for the other process, application. Delphi 10.2. Share this post Link to post
David Heffernan 2345 Posted March 29, 2019 https://stackoverflow.com/a/4497572/505088 1 Share this post Link to post
Mike Torrettinni 198 Posted March 30, 2019 Thank you @David Heffernan, I managed to put the check together... but while testing, it became obvious that there are many more things involved with elevated privileges (multiple levels, the current user, the process owner/user...). So, since in 99% cases the cause for my issue will be that the other process is running with higher privileges than mine, I will just assume this is the cause when error occurs and let user run my project as admin. I'm OK with this, for now. Share this post Link to post
Remy Lebeau 1396 Posted March 31, 2019 On 3/29/2019 at 2:12 PM, Mike Torrettinni said: My project doesn't run as admin by default, so WM_COPYDATA doesn't work when the other application (which I have no control over) runs as admin. So I would like to check and if it does, to show message "Other application running with elevated rights, close your project and check 'Run as Administrator' and run again"... The easiest way to detect this is to simply send the message and handle the case where SendMessage() fails with an ERROR_ACCESS_DENIED error: "When a message is blocked by UIPI the last error, retrieved with GetLastError, is set to 5 (access denied)." Quote I was sure this is quite common task It is not, actually. Quote 1 Share this post Link to post