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

后端 未结 5 1263
野的像风
野的像风 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:07

    Yes You are correct. You also need to effect these settings without logging off

    Send Message of borad casting to all windows SETTINGCHANGE for the parameter (LPARAM) "Environment" with SMTO_ABORTIFHUNG for some milliseconds(5000) using SendMessageTimeout API.

    This is what setX.exe provided with resource Kit does.

提交回复
热议问题