How do I view the environment variable of a Windows process? Looking for Windows equivalent for something like environ
开发者_运维技巧 file in procfs on Unix.
Process Explorer or one of its friends should help.
Check out GetEnvironmentStrings
.
As ziya suggests, you can use the SysInternal's Process Explorer or, for example, slighly more feature rich Process Hacker.
Even though it's really trivial, I'll describe how to find the environment variables used by a specific process in any of those two applications:
- in the list of running processes, select the process you're interested in (in Process Hacker or Process Explorer 16.40 and newer, you can use the search box on the main toolbar)
- open the process' Properties dialog (double-click, press Enter or click Properties in the contect menu)
- open the Environment tab
Process Explorer is displaying all environment variables in a single list, but Process Hacker organizes them into three sections by their scope:
- Process: environment variables specific to the current process (e.g. passed from the command line or defined during the process creation
- User: environment variables defined for the user who owns the process
- System: system-wide environment variables shared by all processes
Take a look at the _environ
variable.
To get process environment, you must be able to obtain its context. And within the context, use getenv()
to get specific variable.
精彩评论