Enable

  WORD Enable(lpDevInfo, wStyle, lpDestDevType, lpOutputFile, lpData)    
  LPVOID lpDevInfo;    
  WORD wStyle;    
  LPSTR lpDestDevType;    
  LPSTR lpOutputFile;    
  LPVOID lpData;    

The Enable function returns information about the driver or initializes the driver. GDI calls this function when it creates a device or information context for an application, or when it restores the context after Windows returns from a full-screen application.

Every graphics driver must export an Enable function.

Parameters

lpDevInfo

Points to a PDEVICE or GDIINFO structure depending on the value of the wStyle parameter.

wStyle

Specifies whether to return information or initialize the driver and device. This parameter can be one of the following values.

Value Meaning

0x0000 Initializes the driver and associated hardware, then copies device-specific information needed by the driver to the PDEVICE structure pointed to by the lpDevInfo parameter.
0x0001 Copies the device driver information to the GDIINFO structure pointed to by lpDevInfo.
0x8000 Initializes the PDEVICE structure pointed to by the lpDevInfo parameter, but does not initialize the driver and peripheral hardware.
0x8001 Means the same as the 0x0001 value.

GDI sets the high bit of wStyle if an application has requested an information context only.

lpDestDevType

Points to a null-terminated ASCII string specifying the device name. This string only applies to device drivers that support more than one model of the same device. The parameter can be NULL if only one model is supported.

lpOutputFile

Points to a null-terminated ASCII string specifying the name of the output port or file to receive output from the driver. The string must be a valid MS-DOS filename.

For a display driver, if the lpOutputFile parameter is NULL, the output device is the system display.

lpData

Points a DEVMODE structure containing information Enable uses to initialize the device. It can be NULL if no such information is needed.

Return Value

The return value is zero if the function is unsuccessful (that is, the hardware is not initialized). Otherwise, the function returns a nonzero value.

Comments

The export ordinal for this function is 5.

For most devices, GDI calls Enable twice: first to retrieve the driver's GDIINFO structure, and then to initialize the device and PDEVICE structure. For a display driver, GDI typically calls the function each time the user switches between Windows and a non-Windows application. When called for the first time, however, Enable saves the current hardware context in static storage (for example, in the PDEVICE structure) so that the driver can restore that context when Windows terminates.

In some cases, GDI may request a raster device to write on a memory bitmap without enabling the device first. This occurs only with raster devices that can write to memory bitmaps.

See Also

Disable