Controlling GPS Intermediate Driver Execution

Send Feedback

While the GPS Intermediate Driver isn't technically a Windows CE service (because it runs in device.exe, not services.exe), it still supports some of the standard service IOCTLs, all of which are explained in more detail in the remainder of this topic:

Often, the most common IOCTL used with the GPS Intermediate Driver is IOCTL_SERVICE_REFRESH. You use this IOCTL to refresh the GPS Intermediate Driver after changing configuration information in the registry. The GPS Intermediate Driver does not reflect any registry changes until it processes the IOCTL_SERVICE_REFRESH IOCTL.

The other IOCTLs can be used to query, disable, or re-enable GPS Intermediate Driver operation. For example, you might use IOCTL_SERVICE_STOP to turn off the GPS Intermediate Driver to save power (although this may be unnecessary in many cases, because the GPS Intermediate Driver intelligently turns the GPS hardware on and off depending on whether it is being used by applications, as explained in GPS Intermediate Driver Power Management).

Sending IOCTLs to the GPS Intermediate Driver

To send these IOCTLs to the GPS Intermediate Driver:

  1. Open a connection to the GPS Intermediate Driver, by calling CreateFile and passing "GPD0:" as the first parameter.

    In contrast to the GPS Intermediate Driver multiplexer, which is exposed through CreateFile using an identifier that can vary - it can be "COM1:", "GPD1:", or one of many other options - and is defined in the registry (using the DriverInterface registry entry), you always control the overall execution of the GPS Intermediate Driver using GPD0. For more information about retrieving location information using the GPS Intermediate Driver multiplexer, see Accessing Raw GPS Data.

  2. Send the desired message to the GPS Intermediate Driver, by calling DeviceIoControl with the appropriate IOCTL.

  3. Close the connection to the GPS Intermediate Driver, by calling CloseHandle.

For example, the following code sends an IOCTL_SERVICE_REFRESH to the GPS Intermediate Driver:

HANDLE hGPS = CreateFile(L"GPD0:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hGPS != INVALID_HANDLE_VALUE) {
   DeviceIoControl(hGPS,IOCTL_SERVICE_REFRESH,0,0,0,0,0,0);
   CloseHandle(hGPS);
}

IOCTL_SERVICE_START

This IOCTL causes the GPS Intermediate Driver to enter a state where it accepts calls for data using the parsed API or the raw interface. You might use this IOCTL to restart the GPS Intermediate Driver after turning it off using IOCTL_SERVICE_STOP.

This IOCTL does not turn on the GPS hardware, to conserve power. Instead, the first parsed API or raw interface call turns on the GPS hardware. For more information about power management when using the GPS Intermediate Driver, see GPS Intermediate Driver Power Management.

IOCTL_SERVICE_STOP

This IOCTL causes the GPS Intermediate Driver to close its connection to the underlying GPS hardware, even if applications are currently using the GPS Intermediate Driver to retrieve GPS data.

Any calls to GPSOpenDevice or CreateFile using the multiplexer identifier will fail after code has used this IOCTL. In addition, the GPS Intermediate Driver closes existing raw interface handles with an error when the GPS Intermediate Driver is stopped. It also signals any event passed in the hDeviceStateChange parameter of GPSOpenDevice when the GPS Intermediate Driver is stopped.

To re-enable the GPS Intermediate Driver after using this IOCTL, use IOCTL_SERVICE_START.

In many cases, using this IOCTL may not be necessary, because the GPS Intermediate Driver automatically turns the GPS hardware on and off only when necessary. That is, even if the GPS Intermediate Driver is loaded and active, the GPS hardware is only turned on when applications actually use the GPS Intermediate parsed or raw interface to request location information. With that said, there may be cases where a target device needs to turn off all GPS hardware. For example, you might do this if the device is extremely low on battery power. Again, for more information about GPS Intermediate Driver power management, see GPS Intermediate Driver Power Management.

IOCTL_SERVICE_STATUS

This IOCTL returns the current state of the GPS Intermediate Driver. For more information, see IOCTL_SERVICE_STATUS.

IOCTL_SERVICE_REFRESH

This IOCTL causes the GPS Intermediate Driver to refresh its configuration parameters from the registry. For more information about how the GPS Intermediate Driver implementation uses IOCTL_SERVICE_REFRESH, see Refreshing GPS Intermediate Driver Configuration using IOCTL_SERVICE_REFRESH.

See Also

GPS Intermediate Driver Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.