简体   繁体   中英

Notification on process affinity change

Is it possible to be notified immediately when an external party changes your programs process affinity? Without polling GetProcessAffinityMask(). For example if a user decides to change it via the task manager.

EDIT: This answer happened before the edit that added "Without polling GetProcessAffinityMask()" and did not specify the language of the check.

Yes, it's doable with a PowerShell for example. Set some base data once and make comparisons every once in a while.

You can get processes with Get-Process ( documentation ) which returns System.Diagnostics.Process object ( documentation ) with Process.ProcessorAffinity ( documentation ) property.

So getting the affinity would look like:

Get-Process PROCESS | Select-Object ProcessorAffinity

And with that - you can set your notifications (either mail, desktop or any other).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM