uses tregistry;
function setglobalenvironment(const name, value: string;
const user: boolean = true): boolean;
resourcestring
reg_machine_location = 'system/currentcontrolset/control/session manager/environment';
reg_user_location = 'environment';
begin
with tregistry.create do
try
if user then
result := openkey(reg_user_location, true)
else
begin
rootkey := hkey_local_machine;
result := openkey(reg_machine_location, true);
end;
if result then
begin
writestring(name, value);
setenvironmentvariable(pchar(name), pchar(value));
sendmessage(hwnd_broadcast, wm_settingchange, 0, integer(pchar('environment')));
end;
finally
free;
end;
end;
setx exe設定系統環境變數
setx 有三種使用方式 語法 1 setx s system u domain user p password var value m 語法 2 setx s system u domain user p password var k regpath m 語法 3 setx s system u ...
linux設定系統環境變數
1 用於當前終端 export path usr local jdk bin pat2 用於當前使用者 推薦 使用者主目錄 目錄 下有.bash profile或.bashrc隱藏檔案,在其末行加入 export path path source bashrc or profile 讓環境變數立即生...
Delphi利用系統環境變數獲取常用系統目錄
譬如 windir 是表示系統目錄的系統變數,可以這樣獲取 vars string begin s getenvironmentvariable windir showmessage s end 一些系統目錄變數列表 變數描述 windir systemroot systemdrive homedr...