Is there a way to set the environment path programmatically in C++ on Windows?

后端 未结 5 1261
野的像风
野的像风 2020-12-08 16:24

Is there a way to set the global windows path environment variable programmatically (C++)?

As far as I can see, putenv sets it only for the current application.

5条回答
  •  难免孤独
    2020-12-08 17:06

    As was pointed out earlier, to change the PATH at the machine level just change this registry entry:

    HLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
    

    But you can also set the PATH at the user level by changing this registry entry:

    HKEY_CURRENT_USER\Environment\Path
    

    And you can also set the PATH at the application level by adding the application\Path details to this registry entry:

    HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\
    

提交回复
热议问题