tag:blogger.com,1999:blog-6384958535100911644.post6194753017953610474..comments2024-02-18T04:26:46.052+01:00Comments on (Sittin' on the) Dock of the Bay: Finding the owner of a Process in C#Diederik Krolshttp://www.blogger.com/profile/11152194058353599890noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-6384958535100911644.post-78155279004668488232017-03-02T14:14:01.112+01:002017-03-02T14:14:01.112+01:00It only returns me the current users name, but the...It only returns me the current users name, but the same process is executed by other users it can't access their name even the current users is administrator.Imran Khan Hunzaihttps://www.blogger.com/profile/13242224650098423934noreply@blogger.comtag:blogger.com,1999:blog-6384958535100911644.post-59920530990317853362017-03-02T13:55:51.511+01:002017-03-02T13:55:51.511+01:00Hi,
I added the code in my app, it returned me th...Hi, <br />I added the code in my app, it returned me the following error.<br />Token cannot be zero.<br /><br />Could you please help me out?Imran Khan Hunzaihttps://www.blogger.com/profile/13242224650098423934noreply@blogger.comtag:blogger.com,1999:blog-6384958535100911644.post-74961141938994176122017-02-25T01:55:21.976+01:002017-02-25T01:55:21.976+01:00Hi,
I know you wrote this a long time ago, but I&...Hi,<br /><br />I know you wrote this a long time ago, but I'm currently writing a service that monitors all processes and your class does not work for me. I always have an access denied error...<br />Can you help me ?Anonymoushttps://www.blogger.com/profile/07014316221394227105noreply@blogger.comtag:blogger.com,1999:blog-6384958535100911644.post-22265635043911576042011-10-13T22:05:08.875+02:002011-10-13T22:05:08.875+02:00Just to clarify, I was using your class like this:...Just to clarify, I was using your class like this:<br /> using (Process ownerProcess = Process.GetProcessById((int) info.ProcessId))<br />{<br /> using (WindowsImpersonationContext impersonationContext = ownerProcess.WindowsIdentity().Impersonate())<br /> {<br /> // Do Access / ACL stuff<br /> }<br />}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6384958535100911644.post-54651531431212284882011-10-13T22:01:19.927+02:002011-10-13T22:01:19.927+02:00Great post, and what I was looking for, BUT, it ne...Great post, and what I was looking for, BUT, it needed the following to get it working for me:<br />I'm sure you can work out the tidyup and const definition code:-)<br /><br />OpenProcessToken(process.Handle, TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY, out ph);<br /><br />wi = new WindowsIdentity(DuplicateToken(ph, SecurityImpersonation, ref dupeTokenHandle)?dupeTokenHandle:ph);Anonymousnoreply@blogger.com