EnumProcesses() vs CreateToolhelp32Snapshot()

后端 未结 5 684
既然无缘
既然无缘 2020-12-30 22:42

I was wondering if there are any differences - mostly performance wise - between the two Win32 API functions EnumProcesses() and CreateToolhelp32Snapshot()

5条回答
  •  甜味超标
    2020-12-30 22:58

    IMO the key difference is in priviledges requirements. I've seen cases in which EnumProcesses() would fail, but CreateToolhelp32Snapshot() ran perfectly well.

    So once I needed to write code that would detect a certain process on a system and react appropriately. I wrote it using EnumProcesses() and it worked fine on my machine, but not on testers' machines. I just rewrote it with CreateToolhelp32Snapshot() and I've never heard of any problems with it anymore.

提交回复
热议问题