How can I change Windows shell (cmd.exe) environment variables from C++?

前端 未结 4 991
耶瑟儿~
耶瑟儿~ 2021-01-07 09:20

I would like to write a program that sets an environment variable in an instance of the shell (cmd.exe) it was called from. The idea is that I could store some state in thi

4条回答
  •  梦谈多话
    2021-01-07 09:38

    There is a way... Just inject your code into parent process and call SetEnvironmentVariableA inside cmd's process memory. After injecting just free the allocated memory.

提交回复
热议问题