GetEnvironment

  int GetEnvironment(lpszPort, lpvEnviron, cbMaxCopy)    
  LPCSTR lpszPort; /* address of port name */
  void FAR* lpvEnviron; /* address of buffer for environment */
  UINT cbMaxCopy; /* maximum number of bytes to copy */

The GetEnvironment function retrieves the current environment that is associated with the device attached to the specified system port and copies it into the specified DEVMODE structure. The environment, maintained by graphics device interface (GDI), contains binary data that GDI uses whenever a device context is created for the device on the given port.

Parameters

lpszPort

Points to the null-terminated string that specifies the name of the desired port.

lpvEnviron

Points to the DEVMODE structure that will receive the environment. The DEVMODE structure has the following form:

typedef struct _devicemode { /* dm */

char dmDeviceName[CCHDEVICENAME];

WORD dmSpecVersion;

WORD dmDriverVersion;

WORD dmSize;

WORD dmDriverExtra;

DWORD dmFields;

short dmOrientation;

short dmPaperSize;

short dmPaperLength;

short dmPaperWidth;

short dmScale;

short dmCopies;

short dmDefaultSource;

short dmPrintQuality;

short dmColor;

short dmDuplex;

short dmYResolution;

short dmTTOption;

} DEVMODE;

cbMaxCopy

Specifies the maximum number of bytes to be copied to the structure.

Return Value

The return value specifies the number of bytes copied to the DEVMODE structure pointed to by the lpvEnviron parameter, if the function is successful. If lpvEnviron is NULL, the return value is the number of bytes required to hold the environment. It is zero if the environment cannot be found.

Comments

The GetEnvironment function is used by drivers only.

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

An application can call this function with the lpvEnviron parameter set to NULL to determine the size of the structure required to hold the environment. It can then allocate the required number of bytes and call the GetEnvironment function a second time to retrieve the environment. The first member in the block pointed to by the lpEnviron parameter should be an atom that the printer driver has added to the global atom table.

See Also

SetEnvironment