亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gps.cpp

?? VC++環境下的GPS全球定位系統源代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*
Module : GPS.CPP
Purpose: "C" style Implementation to GPS32
Created: PJN / 28-12-1997
History: PJN / 20-01-1998  1.  A number of problems were discovered when GPSLIB was being
                               used in a UNICODE build. These problems have been fixed
                           2.  Mak file now includes all the possible build options
                           3.  Mak file no longer hard codes output to d:\winnt\system32
                           4.  Included release binaries in distribution
			   PJN / 26-08-1998  1.  Small change to stdafx.h to include afxcview.h in gps32exe
				                   2.  The GpsShowControlPanel function now actually works
													 3.  Minor tweaks to the GPS Mak files
													 4.  Removed a number of unused symbols
													 5.  Change ID of a number of GPS32EXE menu items to avoid conflict
													     with new VC 6 defines.
													 6.  Updated all Version Infos to 1.02
													 7.  Removed a level 4 warning from the Test app.
													 8.  Removed unused toolbar from GPS CPL file
													 9.  GPS cpl file now uses standard F2 accelerator for Rename
                           10. GPS32EXE toolbar is now shown flat
													 11. Number of extra TRACE statements have been added to 
													     aid in debugging.
         PJN / 11-08-1999  1.  Now uses the WINAPI calling convention meaning that GPSLIB is now
                               callable from VB.
                           2.  Now also ships a GPS.BAS file for use of GPSLIB in VB
         PJN / 27-09-2001  1.  Fixed a problem where the background serial port thread using causing
                           heavy CPU utilization.
                           2.  Updated the project settings so that all binaries get build to the Bin
                               directory and all Lib files get created in a Lib directory
                           3.  Updated the version info's in all the binaries
                           4.  Updated the copyright message in the code modules
         PJN / 21-08-2002  1.  Fixed a synchronisation problem between the worker thread and the 
                           GpsGetPosition method. Thanks to Bill Oatman for spotting this problem.



Copyright (c) 1997 - 2002 by PJ Naughter.  (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

*/


/////////////////////////////////  Includes  //////////////////////////////////
#include "stdafx.h"
#include "gps.h"
#include "serport.h"
#include "resource.h"
#include "nmea.h"
#include "math.h"
#include "gpssetup.h"



//////////////////////////////////  Macros / Defines //////////////////////////
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif


////////////////////////////////// Locals /////////////////////////////////////
class GPSHandle
{
public:
  GPSHandle();
  ~GPSHandle();

  GPSPOSITION      m_Position;    //the actual data
  CEvent*          m_pKillEvent;  //Event to signal thread to exit
  CEvent*          m_pStartEvent; //Is the background thread running
  GPSDEVINFO       m_DevInfo;     //Settings of the comms port to use
  BOOL             m_bRunning;    //Is the background thread running
  CWinThread*      m_pThread;     //The pointer to the background thread
  CCriticalSection m_csPosition;  //Critical section used to serialized access to m_Position
};


BOOL GetGpsDevice(DWORD dwDevice, LPGPSDEVINFO lpGpsDevInfo);
BOOL SetGpsDevice(DWORD dwDevice, LPCGPSDEVINFO lpGpsDevInfo, BOOL bCheckDefault = TRUE);
BOOL SetGpsNumDevices(DWORD dwDevices);
UINT GpsMonitorThead(LPVOID pParam);


////////////////////////////////// Implementation /////////////////////////////

GPSHandle::GPSHandle()
{
  ZeroMemory(&m_Position, sizeof(GPSPOSITION));
  m_pKillEvent = new CEvent(FALSE, TRUE);
  m_pStartEvent = new CEvent(FALSE, TRUE);
  m_pThread = NULL;
}


GPSHandle::~GPSHandle()
{
  delete m_pStartEvent;
  m_pStartEvent = NULL;

  delete m_pKillEvent;
  m_pKillEvent = NULL;
} 


BOOL GetGpsDevice(DWORD dwDevice, LPGPSDEVINFO lpGpsDevInfo)
{
  BOOL bSuccess = FALSE;
  HKEY hKey;

  CString sValueKey;
  sValueKey.Format(_T("SOFTWARE\\PJ Naughter\\GPS32\\%d"), dwDevice);

  LONG nError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sValueKey, 0, KEY_ALL_ACCESS, &hKey);
  if (nError == ERROR_SUCCESS) 
  {
    DWORD dwType;
    DWORD dwSize;

    RegQueryValueEx(hKey, _T("DeviceName"), 0, &dwType, NULL, &dwSize);
    TCHAR* pszName = new TCHAR[dwSize / sizeof(TCHAR)];
    RegQueryValueEx(hKey, _T("DeviceName"), 0, &dwType, (LPBYTE) pszName, &dwSize);
    _tcscpy(lpGpsDevInfo->szDeviceName, pszName);
    delete [] pszName;

    RegQueryValueEx(hKey, _T("DefaultReceiver"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->bDefaultReceiver, &dwSize);

    RegQueryValueEx(hKey, _T("Port"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommPort, &dwSize);

    RegQueryValueEx(hKey, _T("BaudRate"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->dwCommBaudRate, &dwSize);

    RegQueryValueEx(hKey, _T("DataBits"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommDataBits, &dwSize);

    RegQueryValueEx(hKey, _T("StopBits"), 0, &dwType, (LPBYTE) &lpGpsDevInfo->wCommStopBits, &dwSize);

    bSuccess = TRUE;

    RegCloseKey(hKey);
  }
	else
	{
	  TRACE(_T("GetGpsDevice, Failed to open a registry key, Error was: %d\n"), nError);
	}

  return bSuccess;
}


BOOL GpsSetNumDevices(DWORD dwDevices)
{
  BOOL bSuccess = FALSE;
  HKEY hKey;
  DWORD dwDisposition;

  LONG nError = RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\PJ Naughter\\GPS32"), 0, _T(""),
                               REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
  if (nError == ERROR_SUCCESS) 
  {
    RegSetValueEx(hKey, _T("NumberOfDevices"), 0, REG_DWORD, (CONST BYTE*) &dwDevices, sizeof(DWORD));
    
    RegCloseKey(hKey);

    bSuccess = TRUE;
  }
	else
	{
    TRACE(_T("GpsSetNumDevices, Failed in call to create a registry key, Error was: %d\n"), nError);
	}

  return bSuccess;
}


BOOL SetGpsDevice(DWORD dwDevice, LPCGPSDEVINFO lpDevice, BOOL bCheckDefault)
{
  //Fix up the case where we have just made this device 
  //the default by removing the default flag from all 
  //other devices
  if (bCheckDefault && lpDevice->bDefaultReceiver)
  {
    //make all other devices non default
    for (DWORD i=0; i<GpsGetNumDevices(); i++)
    {
      GPSDEVINFO devInfo;
      GetGpsDevice(i, &devInfo);
      devInfo.bDefaultReceiver = FALSE; 
      SetGpsDevice(i, &devInfo, FALSE);
    }
  }

  BOOL bSuccess = FALSE;
  HKEY hKey;
  DWORD dwDisposition;
  CString sValueKey;
  sValueKey.Format(_T("SOFTWARE\\PJ Naughter\\GPS32\\%d"), dwDevice);
	LONG nError = RegCreateKeyEx(HKEY_LOCAL_MACHINE, sValueKey, 0, _T(""), REG_OPTION_NON_VOLATILE,
                               KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
  if (nError == ERROR_SUCCESS) 
  {
    RegSetValueEx(hKey, _T("DeviceName"), 0, REG_SZ, (CONST BYTE*) lpDevice->szDeviceName, _tcslen(lpDevice->szDeviceName));

    RegSetValueEx(hKey, _T("DefaultReceiver"), 0, REG_DWORD, (CONST BYTE*) &lpDevice->bDefaultReceiver, sizeof(BOOL));

    DWORD dwData = lpDevice->wCommPort;
    RegSetValueEx(hKey, _T("Port"), 0, REG_DWORD, (CONST BYTE*) &dwData, sizeof(DWORD));

    RegSetValueEx(hKey, _T("BaudRate"), 0, REG_DWORD, (CONST BYTE*) &lpDevice->dwCommBaudRate, sizeof(DWORD));

    dwData = lpDevice->wCommDataBits;
    RegSetValueEx(hKey, _T("DataBits"), 0, REG_DWORD, (CONST BYTE*) &dwData, sizeof(DWORD));

    dwData = lpDevice->wCommStopBits;
    RegSetValueEx(hKey, _T("StopBits"), 0, REG_DWORD, (CONST BYTE*) &dwData, sizeof(DWORD));

    RegCloseKey(hKey);

    bSuccess = TRUE;
  }
	else
	{
    TRACE(_T("SetGPSDevice, Failed in call to create a registry key, Error was: %d\n"), nError);
	}

  //make sure that at least one device is default
  if (bCheckDefault && !lpDevice->bDefaultReceiver)
  {
    DWORD dwDevices = GpsGetNumDevices();
    GPSDEVINFO* pGpsDevInfo = new GPSDEVINFO[dwDevices];
    dwDevices = GpsEnumDevices(pGpsDevInfo, dwDevices);
    BOOL bFound = FALSE;
    for (DWORD i=0; i<dwDevices && !bFound; i++)
    {
      if (pGpsDevInfo[i].bDefaultReceiver)
        bFound = TRUE;
    }
    delete [] pGpsDevInfo;

    if (!bFound)
    {
      TRACE(_T("SetGpsDevice, Found no device with default receiver attribute\n"));
      TRACE(_T("  making first device the default\n"));

      GPSDEVINFO devInfo;
      GetGpsDevice(0, &devInfo);
      devInfo.bDefaultReceiver = TRUE; 
      SetGpsDevice(0, &devInfo, FALSE);
    }
  }

  return bSuccess;
}


BOOL WINAPI GpsSetDevice(LPCTSTR lpszEntry, LPCGPSDEVINFO lpGpsDevInfo)
{
  //Find the device with the corresponding entry name
  DWORD dwDevices = GpsGetNumDevices();
  GPSDEVINFO* pGpsDevInfo = new GPSDEVINFO[dwDevices];
  dwDevices = GpsEnumDevices(pGpsDevInfo, dwDevices);
  BOOL bFound = FALSE;
  for (DWORD i=0; i<dwDevices && !bFound; i++)
  {
    if (_tcsicmp(lpszEntry, pGpsDevInfo[i].szDeviceName) == 0)
      bFound = TRUE;
  }
  delete [] pGpsDevInfo;

  if (!bFound)
  {
    TRACE(_T("GpsSetDevice, Failed to find GpsEntry for %s\n"), lpszEntry);
    return FALSE;
  }

  return SetGpsDevice(i-1, lpGpsDevInfo);
}


BOOL WINAPI GpsShowControlPanel()
{
#ifdef _DEBUG
  #ifdef _UNICODE
  	UINT nExec = ::WinExec("GPS103UD.EXE", SW_SHOW);
  #else
		UINT nExec = ::WinExec("GPS103D.EXE", SW_SHOW);
  #endif
#else
  #ifdef _UNICODE
  	UINT nExec = ::WinExec("GPS103U.EXE", SW_SHOW);
  #else
		UINT nExec = ::WinExec("GPS103.EXE", SW_SHOW);
	#endif
#endif
  if (nExec <= 31)
	  TRACE(_T("GpsShowControlPanel, Failed in call to WinExec GPS executable, WinExec returns: %d"), nExec);
  
	return (nExec > 31);
}


BOOL WINAPI GpsCreateEntry(HWND hWnd)
{
  BOOL bSuccess = FALSE;

  CWnd* pParent = CWnd::FromHandle(hWnd);

	CInstallPropertySheet propSheet(IDS_GPS_SETUP, pParent);
  propSheet.m_psh.dwFlags |= PSH_NOAPPLYNOW;
	int nResponse = propSheet.DoModal();

  if (nResponse == ID_WIZFINISH)
  {
    DWORD dwDevices = GpsGetNumDevices();

    GPSDEVINFO GpsInfo;
    _tcscpy(GpsInfo.szDeviceName, propSheet.m_Page3.m_sName); 
    GpsInfo.bDefaultReceiver = (propSheet.m_Page3.m_nMakeDefault == 0);
    GpsInfo.wCommPort = (WORD) propSheet.m_Page2.m_dwPort;
    GpsInfo.dwCommBaudRate = propSheet.m_Page2.m_dwBaudRate;
    GpsInfo.wCommDataBits = 8; 
    GpsInfo.wCommParity = GpsParityNone;
    GpsInfo.wCommStopBits = GpsStopBits1;

    bSuccess = SetGpsDevice(dwDevices, &GpsInfo);

    //increment the number of devices parameter
    GpsSetNumDevices(dwDevices + 1);
  }

  return bSuccess;
}


DWORD WINAPI GpsGetNumDevices()
{
  DWORD dwDevices = 0;
  DWORD dwType;
  DWORD dwSize = sizeof(DWORD);
  HKEY hKey;

  LONG nError = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\PJ Naughter\\GPS32"),
                             0, KEY_ALL_ACCESS, &hKey);
  if (nError == ERROR_SUCCESS) 
  {
    RegQueryValueEx(hKey, _T("NumberOfDevices"), 0, &dwType, (LPBYTE) &dwDevices, &dwSize);
    RegCloseKey(hKey);
  }
	else
	{
    TRACE(_T("GpsGetNumDevices, Failed in call to open the registry, Error was: %d\n"), nError);
	}


  return dwDevices;
}


DWORD WINAPI GpsEnumDevices(LPGPSDEVINFO lpRasDevInfo, DWORD dwRequestedDevices)
{
  DWORD dwDevicesToRetreive = min(GpsGetNumDevices(), dwRequestedDevices);

  for (DWORD i=0; i<dwDevicesToRetreive; i++)
    GetGpsDevice(i, &lpRasDevInfo[i]);

  return dwDevicesToRetreive;
}


BOOL WINAPI GpsDeleteEntry(LPCTSTR lpszEntry)
{
  //Find the device with the corresponding entry name
  DWORD dwDevices = GpsGetNumDevices();
  GPSDEVINFO* pGpsDevInfo = new GPSDEVINFO[dwDevices];
  dwDevices = GpsEnumDevices(pGpsDevInfo, dwDevices);
  BOOL bFound = FALSE;
  for (DWORD i=0; i<dwDevices && !bFound; i++)
  {
    if (_tcsicmp(lpszEntry, pGpsDevInfo[i].szDeviceName) == 0)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区精品久久99| 国产精品中文字幕欧美| 精品国产伦一区二区三区观看方式 | 国产色爱av资源综合区| 91色porny在线视频| 久久成人免费网| 一区二区三区欧美| 久久精品一二三| 欧美日韩一区中文字幕| 国产成人综合在线播放| 日韩高清不卡一区| 亚洲欧美另类在线| 国产亚洲视频系列| 日韩一区国产二区欧美三区| 91亚洲午夜精品久久久久久| 久久精品免费看| 一区二区三区四区乱视频| 国产日韩欧美激情| 日韩一区二区三区免费看 | 成人av免费在线观看| 秋霞影院一区二区| 一区二区成人在线| 国产精品家庭影院| 国产丝袜美腿一区二区三区| 欧美一级高清片| 欧美日韩mp4| 在线观看国产91| 97se亚洲国产综合在线| 成人性生交大片免费看在线播放| 毛片av一区二区| 五月激情综合网| 亚洲国产成人av好男人在线观看| 中文字幕一区二区三| 国产午夜精品理论片a级大结局| 欧美一区二区三区爱爱| 欧美在线免费视屏| 91美女在线看| 91网上在线视频| 不卡的电视剧免费网站有什么| 国产福利视频一区二区三区| 国产中文字幕精品| 精品一区二区三区在线观看| 免费观看一级特黄欧美大片| 污片在线观看一区二区| 五月天欧美精品| 日韩精品电影在线| 蜜臀av亚洲一区中文字幕| 日韩高清在线电影| 日本视频免费一区| 男人的天堂久久精品| 免费人成精品欧美精品| 蜜臀va亚洲va欧美va天堂| 久久国产精品99久久久久久老狼| 蜜桃av一区二区| 精品夜夜嗨av一区二区三区| 激情六月婷婷久久| 高清国产午夜精品久久久久久| 成人一级片网址| 91香蕉视频污| 在线观看日韩高清av| 欧美三级资源在线| 日韩无一区二区| 精品久久久久一区| 国产精品三级视频| 亚洲人吸女人奶水| 婷婷成人综合网| 精品中文av资源站在线观看| 国产一本一道久久香蕉| 成人黄色av网站在线| 色综合欧美在线视频区| 欧美日韩精品欧美日韩精品 | 欧美日韩在线不卡| 日韩三级高清在线| 欧美国产精品专区| 一区二区三区中文字幕| 奇米影视一区二区三区| 国产91高潮流白浆在线麻豆| 色狠狠色噜噜噜综合网| 欧美伦理电影网| 久久午夜电影网| 亚洲婷婷综合久久一本伊一区| 午夜激情综合网| 国产精品18久久久久久久久久久久 | 国产aⅴ精品一区二区三区色成熟| 不卡av在线网| 欧美一区二区视频在线观看2020| 久久久久久亚洲综合影院红桃| 日韩理论片网站| 首页亚洲欧美制服丝腿| 成人午夜免费av| 8v天堂国产在线一区二区| 国产午夜一区二区三区| 亚洲一区在线观看视频| 国产一二三精品| 欧美日韩久久久久久| 国产日产精品1区| 午夜精品国产更新| 成人黄色国产精品网站大全在线免费观看 | 高清成人免费视频| 欧美肥妇bbw| 一区视频在线播放| 韩国一区二区三区| 欧美在线播放高清精品| 久久综合资源网| 亚洲国产欧美在线人成| 成人黄色av网站在线| 日韩一区二区三免费高清| 亚洲精品自拍动漫在线| 国产精品一区二区91| 欧美精品久久久久久久多人混战| 国产精品午夜春色av| 久久成人av少妇免费| 欧美羞羞免费网站| 中文字幕日韩av资源站| 国产伦精品一区二区三区免费| 欧美美女直播网站| 一区二区三区中文字幕电影| 成人三级在线视频| 精品成人免费观看| 免费在线观看视频一区| 欧美在线观看18| 亚洲天堂2016| 成人激情免费视频| 久久久www成人免费毛片麻豆| 毛片一区二区三区| 91精品国产色综合久久| 亚洲第一在线综合网站| 色欧美88888久久久久久影院| 国产精品私人影院| 国产福利一区二区三区视频在线| 日韩三级在线免费观看| 日韩精品一级中文字幕精品视频免费观看 | 成人精品在线视频观看| 欧美精品一区二区久久婷婷| 蜜臀国产一区二区三区在线播放| 欧美挠脚心视频网站| 亚洲国产精品久久一线不卡| 色香蕉成人二区免费| 亚洲男人的天堂av| 色悠久久久久综合欧美99| 成人免费在线播放视频| 97se亚洲国产综合自在线不卡| 日韩一区中文字幕| 99久久99久久综合| 亚洲色图制服丝袜| 日本乱码高清不卡字幕| 亚洲夂夂婷婷色拍ww47| 欧美日韩国产在线观看| 午夜国产精品一区| 91精品国产综合久久久久久漫画| 午夜精品久久久久久久久| 91精品国产高清一区二区三区| 日韩av网站免费在线| 日韩欧美激情在线| 黄页视频在线91| 国产视频一区二区三区在线观看| 国产精品一区二区视频| 亚洲国产精品ⅴa在线观看| 99精品视频在线观看| 亚洲欧美日韩电影| 欧美精品自拍偷拍| 精品亚洲欧美一区| 国产精品久线观看视频| 在线看国产日韩| 日日夜夜精品视频免费| 精品成人a区在线观看| 成人av动漫在线| 亚洲电影在线免费观看| 日韩欧美精品在线| 成人黄色国产精品网站大全在线免费观看| 成人欧美一区二区三区小说| 在线免费观看一区| 久久不见久久见中文字幕免费| 国产精品丝袜91| 欧美日韩国产综合视频在线观看| 精品一区二区久久| 亚洲日穴在线视频| 制服.丝袜.亚洲.中文.综合| 国产剧情一区二区| 一个色妞综合视频在线观看| 日韩视频在线永久播放| www.亚洲人| 肉肉av福利一精品导航| 国产三级三级三级精品8ⅰ区| 一本大道久久a久久精二百| 免费成人在线网站| 国产精品欧美精品| 欧美一区二区成人6969| 成人av第一页| 奇米色一区二区| 亚洲啪啪综合av一区二区三区| 91精品一区二区三区在线观看| 成人免费视频国产在线观看| 三级影片在线观看欧美日韩一区二区 | 日韩免费看网站| 免费观看在线综合色| 日韩美女精品在线| 国产精品蜜臀av| 麻豆成人av在线| 日韩视频国产视频|