Click here to Skip to main content
15,912,897 members
Home / Discussions / System Admin
   

System Admin

 
GeneralWindows' Handle Pin
ladder3-Jul-03 23:23
ladder3-Jul-03 23:23 
GeneralRe: Windows' Handle Pin
Michael Dunn4-Jul-03 5:36
sitebuilderMichael Dunn4-Jul-03 5:36 
GeneralRe: Windows' Handle Pin
ladder5-Jul-03 6:00
ladder5-Jul-03 6:00 
GeneralRe: Windows' Handle Pin
Michael Dunn5-Jul-03 6:07
sitebuilderMichael Dunn5-Jul-03 6:07 
GeneralRe: Windows' Handle Pin
Alexander M.,22-Jul-03 9:40
Alexander M.,22-Jul-03 9:40 
GeneralEnvironment Vars - using Pin
john john mackey1-Jul-03 10:04
john john mackey1-Jul-03 10:04 
GeneralRe: Environment Vars - using Pin
John M. Drescher1-Jul-03 10:18
John M. Drescher1-Jul-03 10:18 
GeneralRe: Environment Vars - using Pin
jlb1-Jul-03 13:35
jlb1-Jul-03 13:35 
Hi,

> 1) use my own environment vars in links and shortcuts
> (e.g. Target and Start In fields in a shortcut's property dialog

Surround the variable name with percent symbols; e.g.
%PROJECTS%\SomeTool.exe %LAUNCH_ARGS%

Also, if the variable represents a path and it may have a space in it I'd recommend changing the above to:
"%PROJECTS%\SomeTool.exe" %LAUNCH_ARGS%

> 2) use my own environment vars in batch files

Same again.

> 3) set my own environment vars programmatically (from VC++)

You can use the SetEnvironmentVariable API but this function only sets the variable for the current process (and any child processes that you may launch that inherit the current environment).

To set persistent environment variables you have to save them in the registry on NT/2K/XP and in AUTOEXEC.BAT on 95/98/Me. The rest of these notes are for NT/2K/XP only.

There are three types of environment variables: user, system and volatile.
The system variables are loaded first and are the same for every user on the system. They are stored as values of this registry key:
[HKLM\System\CurrentControlSet\Control\Session Manager\Environment]

If the value is a straight string the registry value type is REG_SZ, but if the value contains another environment variable name (in percent symbols) the value type is REG_EXPAND_SZ.

Next come the user environment variables. These are per user (duh!) and are stored in each user's registry hive under:
[HKCU\Environment]

These follow the same rules as the system variables; they can also refer to a system variable name (in percent symbols).

The final category is volatile variables; these are also per-user but are not saved between logon sessions; the system stores things such as the current logon server and domain name here. They are stored in:
[HKCU\Volatile Environment]

All three types are joined to create the final environment block your process is started with.

BTW, if you do create a tool to modify the environment and you want a running process (such as Explorer) to pick up the changes, you have to broadcast a WM_SETTINGSCHANGE message to notify them. A snippet of C++ does this:
const DWORD dwTimeout= 3000;
DWORD dwResult= 0;
SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE,
        0, (LPARAM)_T("Environment"), SMTO_NORMAL,
        dwTimeout, &dwResult);

Hope this helps.

Regards,

John Bates.
GeneralRe: Environment Vars - using Pin
john john mackey2-Jul-03 5:32
john john mackey2-Jul-03 5:32 
GeneralRe: Environment Vars - using Pin
Michael Dunn4-Jul-03 7:00
sitebuilderMichael Dunn4-Jul-03 7:00 
GeneralRe: Environment Vars - using Pin
john john mackey4-Jul-03 9:17
john john mackey4-Jul-03 9:17 
GeneralRe: Environment Vars - using Pin
Atlantys11-Jul-03 20:05
Atlantys11-Jul-03 20:05 
GeneralDNS Insert/Delete/Modify Pin
vss-130-Jun-03 13:55
vss-130-Jun-03 13:55 
GeneralIIS ASP.NET Rant/Question Pin
Matt Newman29-Jun-03 18:45
Matt Newman29-Jun-03 18:45 
GeneralRe: IIS ASP.NET Rant/Question Pin
Richard Deeming1-Jul-03 4:57
mveRichard Deeming1-Jul-03 4:57 
GeneralRe: IIS ASP.NET Rant/Question Pin
Matt Newman1-Jul-03 6:06
Matt Newman1-Jul-03 6:06 
GeneralProcesses in Windows XP Pin
Anonymous28-Jun-03 19:00
Anonymous28-Jun-03 19:00 
GeneralRe: Processes in Windows XP Pin
Venet29-Jun-03 4:49
Venet29-Jun-03 4:49 
GeneralRe: Processes in Windows XP Pin
jhaga29-Jun-03 9:39
professionaljhaga29-Jun-03 9:39 
GeneralRe: Processes in Windows XP Pin
Venet29-Jun-03 10:17
Venet29-Jun-03 10:17 
GeneralRe: Processes in Windows XP Pin
jhaga29-Jun-03 11:53
professionaljhaga29-Jun-03 11:53 
GeneralRe: Processes in Windows XP Pin
Venet30-Jun-03 5:53
Venet30-Jun-03 5:53 
GeneralRe: Processes in Windows XP Pin
Roger Wright29-Jun-03 12:28
professionalRoger Wright29-Jun-03 12:28 
GeneralProblem with new harddrive in Windows 2000 Pin
Rickard Andersson2027-Jun-03 6:48
Rickard Andersson2027-Jun-03 6:48 
GeneralRe: Problem with new harddrive in Windows 2000 Pin
Bruce Duncan27-Jun-03 8:55
Bruce Duncan27-Jun-03 8:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.