GetEnvironment

Syntax

int GetEnvironment(lpPortName,lpEnviron,nMaxCount)

This function retrieves the current environment that is associated with the device attached to the system port specified by the lpPortName parameter, and copies it into the buffer specified by the lpEnviron parameter. The environment, maintained by GDI, contains binary data used by GDI whenever a device context is created for the device on the given port.

The function fails if there is no environment for the given port.

An application can call this function with the lpEnviron parameter set to NULL to determine the size of the buffer required to hold the environment. It can then allocate the buffer and call GetEnvironment a second time to retrieve the environment.

Parameter Type/Description  
lpPortName LPSTR Points to the null-terminated character string that specifies the name of the desired port.  
lpEnviron LPSTR Points to the buffer that will receive the environment.  
nMaxCount WORD Specifies the maximum number of bytes to copy to the buffer.  

Return Value

The return value specifies the number of bytes copied to lpEnviron. If lpEnviron is NULL, the return value is the size in bytes of the buffer required to hold the environment. It is zero if the environment cannot be found.

Comments

The first field in the buffer pointed to by lpEnviron 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.