The DRV_OPEN Message

On the DRV_OPEN system message, the lParam2 parameter specifies which device is being opened. This value is JOYSTICKID1 for the first device and JOYSTICKID2 for the second device.

The value that DriverProc returns for the DRV_OPEN message becomes the dwDriverID parameter for all subsequent messages sent to the driver. The driver can use this value for any purpose; for example, to identify a structure containing information about the client.