int SetEnvironment(lpPortName,lpEnviron,nCount)
This function copies the contents of the buffer specified by the lpEnviron parameter into the environment associated with the device attached to the system port specified by the lpPortName parameter. The SetEnvironment function deletes any existing environment. If there is no environment for the given port, SetEnvironment creates one. If the nCount parameter is zero, the existing environment is deleted and not replaced.
Parameter | Type/Description |
lpPortName | LPSTR Points to a null-terminated character string that specifies the name of the desired port. | |
lpEnviron | LPSTR Points to the buffer that contains the new environment. | |
nCount | WORD Specifies the number of bytes to be copied. |
The return value specifies the actual number of bytes copied to the environment. It is zero if there is an error. It is –1 if the environment is deleted.
The first field in the buffer pointed to by the lpEnviron parameter must be the same as that passed in the lpDeviceName parameter of the CreateDC function. If lpPortName specifies a null port (as defined in the WIN.INI file), the device name pointed to by lpEnviron is used to locate the desired environment.