You can use the methods of the IPosNav interface to communicate with a GPS device.
The following code example shows how to do this:
HRESULT hResult = CoCreateInstance(CLSID_PosNav, NULL,
CLSCTX_INPROC_SERVER, IID_IPosNav,
(LPLPVOID) &pPosNav);
The following code example shows how to do this:
hres = pPosNav->FindDevices(&pDevice, &dwNumDev);
if(FAILED (hres) || dwNumDev == 0)
{
pPosNav->Release();
// Insert error handling here.
}
// Call your selection function to choose one device.
PNDEVICE *pDeviceOfChoice = MySelectDevice(pDevice);
The following code example shows how to do this:
hres = pPosNav->OpenDevice(&hPNAPI, pDeviceOfChoice);
The following code example shows how to do this:
pPosNav->DeleteDeviceList(pDevice);
if(FAILED (hres))
{
g_pPosNav->Release();
// Insert error handling here.
}
The following code example shows how to do this:
hres = pPosNav->CloseDevice(hPNAPI);
// Release the interface.
pPosNav->Release();