System environment variable setting key technology

zhaozj2021-02-16  93

System environment variable setting key technology

(http://blog.9cbs.net/wqf2)

I have prepredited a gadget recently to set the environment variable of the system. Of course, Windows also provides the setting function of environment variables, but the function is weak, so I wrote a powerful function. Let me briefly introduce key technologies to set environment variables.

Setting the environment variables can be operated by two steps by programs:

1. Modify the data stored in the environment variable by modifying the registry key

User Environment Variable List Registry Key: HKEY_CURRENT_USER / ENVIRONMENT

System Environment Variable List Registry Key: HKEY_LOCAL_MACHINE / SYSTEM / CURRENTCONTROLSET / CONTROL / Session Manager / Environment

2. After modifying the registry item of the environment variable, you can notify the environment variable update DWORD dwreturnValue = 0 by the following code; sendMessageTimeout (hwnd_broadcast, wm_settingchange, 0, (lparam) "Environment", SMTO_ABORTIFHUNG, 5000, & DWRETURNVALUE

转载请注明原文地址:https://www.9cbs.com/read-12249.html

New Post(0)