⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gps.cpp

📁 Sample GPS on windows CE
💻 CPP
字号:
// GPS.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include "GPS.h"
#include <windows.h>
#include <commctrl.h>
#include <Gpsapi.h>

#define MAX_LOADSTRING 100

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	HANDLE hNewLocationData = CreateEvent(NULL, FALSE, FALSE, NULL);
	HANDLE hDeviceStateChange = CreateEvent(NULL, FALSE, FALSE, NULL);

	HANDLE hGPSDevice = ::GPSOpenDevice(hNewLocationData, hDeviceStateChange, NULL, NULL);
	if (!hGPSDevice)
		return 0;

	static const int GPS_CONTROLLER_EVENT_COUNT = 2;
	HANDLE gpsHandles[GPS_CONTROLLER_EVENT_COUNT] = 
	{	hNewLocationData, hDeviceStateChange };

	GPS_POSITION gpsPosition = { 0 };
	gpsPosition.dwSize = sizeof(GPS_POSITION);
	gpsPosition.dwVersion = GPS_VERSION_1;

	GPS_DEVICE gpsDev = { 0 };
	gpsDev.dwSize = sizeof(GPS_DEVICE);
	gpsDev.dwVersion = GPS_VERSION_1;

	DWORD dwRet;
	do {

		dwRet = WaitForMultipleObjects(GPS_CONTROLLER_EVENT_COUNT, 	gpsHandles, FALSE, INFINITE);
		if (dwRet == WAIT_OBJECT_0) {

			dwRet = GPSGetPosition(hGPSDevice, &gpsPosition, 3000, 0);
			if (ERROR_SUCCESS != dwRet)
				continue;
		}
		else

		if (dwRet == WAIT_OBJECT_0 + 1) {

			dwRet = GPSGetDeviceState(&gpsDev);	
			if (ERROR_SUCCESS != dwRet)
				continue;
		}

	} while (1);

	::GPSCloseDevice(hGPSDevice);
	hGPSDevice =  NULL;

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -