Post
by Lumir Paul » 28 May 2008, 10:49
Posted by: Lumir Paul
Hi Philip,
I think that the explanation can be found in the MSDN - from the following
feature.
Every process has an environment block that contains a set of environment
variables and their values.....
*Setting it*
BOOL SetEnvironmentVariable(
LPCTSTR lpName -> pointer to a null-terminated string that specifies the
name of the environment variable
LPCTSTR lpValue -> pointer to a null-terminated string that specifies the
contents of the environment variable (max. 32,767 chars)
)
SetEnvironmentVariable function sets the contents of the specified
environment variable for the current process only !!!
This function has no effect on the system environment variables or the
environment variables of other processes !!!
*Getting it*
LPVOID GetEnvironmentStrings(void)
GetEnvironmentStrings function retrieves the environment variables for the
current process.
If the function succeeds, the return value is a pointer to the environment
block of the current process.
If the function fails, the return value is NULL
DWORD GetEnvironmentVariable(
LPCTSTR lpName -> pointer to a null-terminated string that specifies the
name of the environment variable.
LPTSTR lpBuffer -> pointer to a buffer that receives the contents of the
specified environment variable (max. 32,767 chars)
DWORD nSize -> size of the buffer pointed to by the lpBuffer parameter
)
GetEnvironmentVariable function retrieves the contents of the specified
variable from the environment block of the calling process.
The contents are in the form of a null-terminated string of characters.
If the function succeeds, the return value is the number of chars stored
into the buffer pointed to by lpBuffer
If the function fails, the return value is zero
The GetEnvironmentStrings function returns a pointer to the environment
block of the calling process.
This should be treated as a read-only block; do not modify it directly.
Instead, use the SetEnvironmentVariable function to change an environment
variable.
When you are finished with the environment block obtained from
GetEnvironmentStrings, call the FreeEnvironmentStrings function to free the
block.
Calling SetEnvironmentVariable has no effect on the system environment
variables.
The user can add or modify system environment variables using the Control
Panel. To programmatically add or modify system environment variables,
add them to the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session
Manager\Environment registry key,
then broadcast a WM_SETTINGCHANGE message. This allows applications, such as
the shell, to pick up your updates.
The GetEnvironmentVariable function determines whether a specified variable
is defined in the environment of the calling process, and, if so, what its
value is.
Regards, have a nice day.
Lumir Paul
paul@mikropost.cz