Add process_iterator helper - #509
Open
Alexander Sklar (asklar) wants to merge 8 commits into
Open
Conversation
Jon Wiswall (jonwis)
requested changes
Mar 5, 2025
Alexander Sklar (asklar)
force-pushed
the
enum_processes
branch
from
March 6, 2025 21:47
743ff83 to
d7181f2
Compare
Comment on lines
+16
to
+21
| #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | ||
|
|
||
| #if (__WI_LIBCPP_STD_VER >= 17) && WI_HAS_INCLUDE(<string_view>, 1) // Assume present if C++17 | ||
| #if defined(WIL_ENABLE_EXCEPTIONS) | ||
|
|
||
| #if __cpp_lib_string_view >= 201606L |
Member
There was a problem hiding this comment.
Suggested change
| #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | |
| #if (__WI_LIBCPP_STD_VER >= 17) && WI_HAS_INCLUDE(<string_view>, 1) // Assume present if C++17 | |
| #if defined(WIL_ENABLE_EXCEPTIONS) | |
| #if __cpp_lib_string_view >= 201606L | |
| #include "common.h" | |
| #if WIL_USE_STL && (__WI_LIBCPP_STD_VER >= 17) && WI_HAS_INCLUDE(<string_view>, 1) // Assume present if C++17 | |
| #include <string_view> | |
| #endif | |
| #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && defined(WIL_ENABLE_EXCEPTIONS) && (__cpp_lib_string_view >= 201606L) |
Use WIL_USE_STL to determine if it's okay to use the STL.
Need to include common.h for WIL_ENABLE_EXCEPTIONS and WIL_USE_STL definitions.
Need to include string_view to get the definition of __cpp_lib_string_view
| #include <string> | ||
| #include <TlHelp32.h> | ||
|
|
||
| #define __WIL_PROCESS_ITERATOR |
Member
There was a problem hiding this comment.
You have an include guard, so this seems unnecessary
Comment on lines
+44
to
+48
| DWORD ProcessID{}; | ||
| ULONG_PTR ThreadCount{}; | ||
| DWORD ParentProcessID{}; | ||
| LONG BasePriority{}; | ||
| std::wstring ProcessName; |
Member
There was a problem hiding this comment.
Suggested change
| DWORD ProcessID{}; | |
| ULONG_PTR ThreadCount{}; | |
| DWORD ParentProcessID{}; | |
| LONG BasePriority{}; | |
| std::wstring ProcessName; | |
| DWORD process_id{}; | |
| ULONG_PTR thread_count{}; | |
| DWORD parent_process_id{}; | |
| LONG base_priority{}; | |
| std::wstring process_name; |
Use snake_case
| }; | ||
| } // namespace details | ||
|
|
||
| struct process_iterator |
Member
There was a problem hiding this comment.
Calling this an "iterator" when it's not actually an iterator is misleading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a little iterator class to abstract away the toolhelp apis.