forked from jperson2000/GPS.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GpsIntermediateDriver.cs
797 lines (706 loc) · 31.6 KB
/
GpsIntermediateDriver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
#if PocketPC
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.IO.Ports;
using System.Text;
using System.Threading;
using Microsoft.Win32;
using GeoFramework.Gps.Nmea;
namespace GeoFramework.Gps.IO
{
/// <summary>
/// Represents the GPS Intermediate Driver on hand-held Windows Mobile 5.0+ devices.
/// </summary>
/// <remarks><para>The GPS Intermediate Driver (or GPSID for short) is a multiplexer which allows multiple applications
/// to share GPS data. This driver is included in all Windows Mobile 5.0 (and above) devices.
/// When the GPSID is used, applications must not connect directly to a GPS device, but instead needs to connect
/// to a special "Program Port" created by the GPSID. This class serves as a managed interface to the GPSID, allowing
/// developers to perform configuration changes through code.</para>
/// <para>This class is provided as a convenience for advanced GPS developers. In most situations, GPS.NET will assume
/// responsibility for properly configuring the GPSID for the purposes of enabling GPS data with minimal effort by both
/// developers or end-users. Exercise caution when changing settings by hand; it is preferable to use this class on
/// a read-only basis whenever possible.</para>
/// </remarks>
public sealed class GpsIntermediateDriver : SerialDevice
{
private bool _IsRestartRequired = false;
private bool _IsAutomaticallyConfigured = true;
private string _CurrentLogFile = String.Empty;
private string _OldLogFile = string.Empty;
private string _DriverInterface = string.Empty;
private static GpsIntermediateDriver _Current;
#region Constants
internal const string _RootKeyName = @"System\CurrentControlSet\GPS Intermediate Driver";
internal const string _DriversKeyName = _RootKeyName + @"\Drivers";
internal const string _MultiplexerKeyName = _RootKeyName + @"\Multiplexer";
#endregion
#region Fields
/// <summary>
/// Returns the GPS Intermediate Driver for the mobile device.
/// </summary>
public static GpsIntermediateDriver Current
{
get { return _Current; }
}
#endregion
#region Constructors
static GpsIntermediateDriver()
{
if (IsSupported)
_Current = new GpsIntermediateDriver();
}
internal GpsIntermediateDriver()
{
/* Most GPSID registry settings will specify a port to connect to. However, some devices
* have been encountered (such as the Intermic CN3) which has no registry value specified.
* In this situation, we'll have to configure the GPSID to use a default of "GPD1:" (?)
*/
// Is the GPSID supported?
if (string.IsNullOrEmpty(Port))
this.Port = "GPD1:";
// I'm a big baud rate, and I need a big cereal
BaudRate = 115200;
}
#endregion
#region Public Properties
/// <summary>
/// Controls the port used to open a shared connection.
/// </summary>
/// <remarks>This property controls the name of the port used for all shared GPS connections. Applications which use this port can
/// trust that the GPS device will also be available to other applications using the same port. When this property is changed, the
/// GPSID registry control panel will also be updated.</remarks>
public override string Port
{
get
{
return Convert.ToString(LoadSetting(_MultiplexerKeyName, "DriverInterface"));
}
set
{
// Validate
if (value == null)
throw new ArgumentNullException("Port");
// The port name must start with COM or GPD
#if !PocketPC
string name = value.ToUpperInvariant();
#else
string name = value.ToUpper(CultureInfo.InvariantCulture);
#endif
if (!name.StartsWith("COM") && !name.StartsWith("GPD"))
throw new ArgumentOutOfRangeException("Port", "The GPS Intermediate Driver port must begin with 'COM' or 'GPD'. The value '" + value + "' is not allowed.");
// Commit the setting
SaveSetting(_MultiplexerKeyName, "DriverInterface", value);
// We'll need to refresh settings
_IsRestartRequired = true;
// Set the base port name
base.Port = value;
}
}
/// <summary>
/// Controls the serial GPS device managed by the GPS Intermediate Driver.
/// </summary>
public SerialDevice HardwarePort
{
get
{
// We can only return a value if we have a serial device
if (InterfaceType != GpsIntermediateDriverInterfaceType.SerialDevice)
return null;
// Get the port of the serial device
string currentDevice = Convert.ToString(LoadSetting(_DriversKeyName, "CurrentDriver"));
if (currentDevice.Length != 0)
{
// If we get here, we have the current device, but no friendly name. Build a name
string port = Convert.ToString(LoadSetting(_DriversKeyName + @"\" + currentDevice, "CommPort"));
// Look for this device in the cache
IList<SerialDevice> serialDevices = SerialDevice.Cache;
for (int index = 0; index < serialDevices.Count; index++)
{
// Do the ports match?
if (serialDevices[index].Port.Equals(port, StringComparison.InvariantCultureIgnoreCase))
{
// Yes. Return it.
return serialDevices[index];
}
}
// Return a new device
return new SerialDevice(port);
}
// If we get here, no current driver is specified
return null;
}
set
{
/* The GPSID will save any changes made in the Control Panel to the key specified
* as the "CurrentDriver". This value varies on different devices. For example, the
* Samsung Omina saves changes to "Samsung GPS Hardware". So, let's follow suit.
*/
RegistryKey rootKey = null;
try
{
rootKey = Registry.LocalMachine.OpenSubKey(_DriversKeyName, false);
if (rootKey != null)
{
#region Create a brand new device
// Get the active source device
string currentDevice = Convert.ToString(rootKey.GetValue("CurrentDriver"));
// This value may be empty. If so, let's see if there are any drivers at all
if (string.IsNullOrEmpty(currentDevice))
{
// Any subkeys?
if (rootKey.GetSubKeyNames().Length == 0)
{
/* No. This could very well be a hard-reset device with no
* settings whatsoever. Crate a key.
*/
RegistryKey newDeviceKey = null;
try
{
newDeviceKey = rootKey.CreateSubKey("Control Panel Configured Device");
newDeviceKey.SetValue("InterfaceType", "COMM");
newDeviceKey.SetValue("CommPort", value.Port);
newDeviceKey.SetValue("Baud", value.BaudRate);
if (!value.Name.Equals(value.Port))
newDeviceKey.SetValue("FriendlyName", value.Name);
}
catch (UnauthorizedAccessException)
{
throw new InvalidOperationException("The GPS Intermediate Driver cannot be automatically configured because of insufficient registry permissions. Please modify GPSID settings by hand to use '" + value.Port + "' for the 'Program Port' with a baud rate of " + value.BaudRate.ToString());
}
finally
{
if (newDeviceKey != null)
newDeviceKey.Close();
}
}
// Finally, tell the GPSID to use this device
rootKey.SetValue("CurrentDriver", "Control Panel Configured Device");
}
else
{
// Modify existing device settings
RegistryKey newDeviceKey = null;
try
{
newDeviceKey = rootKey.OpenSubKey(currentDevice, true);
newDeviceKey.SetValue("InterfaceType", "COMM");
newDeviceKey.SetValue("CommPort", value.Port);
newDeviceKey.SetValue("Baud", value.BaudRate);
if (!value.Name.Equals(value.Port))
newDeviceKey.SetValue("FriendlyName", value.Name);
}
catch { }
finally
{
if (newDeviceKey != null)
newDeviceKey.Close();
}
}
// And we need a restart
_IsRestartRequired = true;
#endregion
}
}
catch
{
throw;
}
finally
{
if (rootKey != null)
rootKey.Close();
}
}
}
/// <summary>
/// Controls whether changes to the driver are performed automatically.
/// </summary>
/// <remarks>The GPS Intermediate Driver requires accurate information in order to function properly. For example, the
/// serial port name and baud rate of the actual GPS device must be specified or the GPSID will fail. When this property is
/// <strong>True</strong>, GPS.NET will configure the GPSID to what it believes to be the most reliable GPS device. Additional
/// changes may be made, such as the name of the "Program Port," if no value exists.</remarks>
public bool IsAutomaticallyConfigured
{
get
{
return _IsAutomaticallyConfigured;
}
set
{
_IsAutomaticallyConfigured = value;
}
}
/// <summary>
/// Returns whether the GPS Intermediate Driver is supported on this computer.
/// </summary>
public static bool IsSupported
{
get
{
// Look for a registry key
RegistryKey key = null;
try
{
key = Registry.LocalMachine.OpenSubKey(_RootKeyName, false);
return key != null;
}
catch
{
return false;
}
finally
{
if (key != null)
key.Close();
}
}
}
/// <summary>
/// Controls the path to a log file used to capture incoming NMEA data.
/// </summary>
/// <remarks>This property is typically used for debugging purposes only. When this property is set to a path, any incoming NMEA data
/// from the GPSID will be logged to this file. If, however, the property is set to an empty string, no logging will be performed.</remarks>
public string CurrentLogFile
{
get
{
return Convert.ToString(LoadSetting(_RootKeyName, "CurrentLogFile"));
}
set
{
// Save the new value
SaveSetting(_RootKeyName, "CurrentLogFile", value);
// Flag that the driver needs a restart
_IsRestartRequired = true;
}
}
/// <summary>
/// Controls the path to a second log file, used for older GPS data.
/// </summary>
/// <remarks>This property controls the absolute filename for a secondary log file. When NMEA data is being logged,
/// the current log file will be renamed to this filename once it reaches capacity. A secondary log file lets developers access older GPS data while
/// newer data is being collected.</remarks>
public string OldLogFile
{
get
{
return Convert.ToString(LoadSetting(_RootKeyName, "OldLogFile"));
}
set
{
// Save the new value
SaveSetting(_RootKeyName, "OldLogFile", _OldLogFile);
// Flag that the driver needs a restart
_IsRestartRequired = true;
}
}
/// <summary>
/// Controls the maximum number of bytes allowed in the receiving buffer for GPS data.
/// </summary>
/// <remarks>The maximum buffer size </remarks>
public int MaximumBufferSize
{
get
{
return Convert.ToInt32(LoadSetting(_RootKeyName + @"\Multiplexer", "MaxBufferSize"));
}
set
{
// Validate values
if (value <= 0)
{
#if !PocketPC
throw new ArgumentOutOfRangeException("MaximumBufferSize", value, "The maximum GPSID buffer size must be greater than zero.");
#else
throw new ArgumentOutOfRangeException("MaximumBufferSize", "The maximum GPSID buffer size must be greater than zero.");
#endif
}
// Save the new value
SaveSetting(_RootKeyName + @"\Multiplexer", "MaxBufferSize", value);
// Flag that the driver needs a restart
_IsRestartRequired = true;
}
}
/// <summary>
/// Controls the maximum allowed size of a log file, in bytes.
/// </summary>
/// <remarks>This property is typically used for debugging purposes only.</remarks>
public int MaximumLogFileSize
{
get
{
return Convert.ToInt32(LoadSetting(_RootKeyName, "MaxLogFileSize"));
}
set
{
if (value <= 1024)
throw new ArgumentOutOfRangeException("MaximumLogFileSize", "The maximum log file size cannot be less than 1024. A value of several kilobytes is recommended.");
// Set the new value
SaveSetting(_RootKeyName, "MaxLogFileSize", value);
}
}
/// <summary>
/// Controls whether the GPSID will configure itself to use plug-and-play GPS devices.
/// </summary>
/// <remarks>Some newer GPS devices, such as SecureDigital card devices, are usable immediately after they are plugged into
/// a mobile device. When this property is enabled, the GPSID will configure itself to use the device. When this is disabled,
/// GPS hardware settings must be specified manually, or by GPS.NET.</remarks>
public bool AllowPlugAndPlay
{
get
{
return Convert.ToBoolean(LoadSetting(_DriversKeyName, "AllowPlugAndPlay"));
}
set
{
// Set the new value
SaveSetting(_DriversKeyName, "AllowPlugAndPlay", value);
// Indicate we need a restart
_IsRestartRequired = true;
}
}
public override string Name
{
get
{
/* For some devices, a "FriendlyName" registry value will exist. If this exists, we can use the value,
* otherwise, we'll just return what we can.
*/
string currentDevice = Convert.ToString(LoadSetting(_DriversKeyName, "CurrentDriver"));
if (currentDevice.Length != 0)
{
// Try to get the friendly name for this device
string friendlyName = Convert.ToString(LoadSetting(_DriversKeyName + @"\" + currentDevice, "FriendlyName"));
if (friendlyName.Length != 0)
{
// We have a friendly name! Use it
return "GPS Intermediate Driver (" + friendlyName + ")";
}
// If we get here, we have the current device, but no friendly name. Build a name
string interfaceType = Convert.ToString(LoadSetting(_DriversKeyName + @"\" + currentDevice, "InterfaceType"));
#if !PocketPC
interfaceType = interfaceType.ToLowerInvariant();
#else
interfaceType = interfaceType.ToLower(CultureInfo.InvariantCulture);
#endif
switch (interfaceType)
{
case "comm":
// Use the "CommPort" value
string commPort = Convert.ToString(LoadSetting(_DriversKeyName + @"\" + currentDevice, "CommPort"));
if (commPort.Length != 0)
return "GPS Intermediate Driver (Device on " + commPort + ")";
else
return "GPS Intermediate Driver (Invalid serial device)";
case "file":
return "GPS Intermediate Driver (Text File)";
case "poll":
return "GPS Intermediate Driver (Manually polled device)";
default:
return "GPS Intermediate Driver (Unrecognized device)";
}
}
// No current device is specified!
return "GPS Intermediate Driver";
}
}
/// <summary>
/// Returns the source of raw GPS data for the GPS Intermediate Driver.
/// </summary>
public GpsIntermediateDriverInterfaceType InterfaceType
{
get
{
/* For some devices, a "FriendlyName" registry value will exist. If this exists, we can use the value,
* otherwise, we'll just return what we can.
*/
string currentDevice = Convert.ToString(LoadSetting(_DriversKeyName, "CurrentDriver"));
if (currentDevice.Length != 0)
{
// If we get here, we have the current device, but no friendly name. Build a name
string interfaceType = Convert.ToString(LoadSetting(_DriversKeyName + @"\" + currentDevice, "InterfaceType"));
#if !PocketPC
interfaceType = interfaceType.ToLowerInvariant();
#else
interfaceType = interfaceType.ToLower(CultureInfo.InvariantCulture);
#endif
switch (interfaceType)
{
case "comm":
return GpsIntermediateDriverInterfaceType.SerialDevice;
case "file":
return GpsIntermediateDriverInterfaceType.File;
case "poll":
return GpsIntermediateDriverInterfaceType.Manual;
}
}
return GpsIntermediateDriverInterfaceType.Unknown;
}
}
#endregion
#region Public Methods
/// <summary>
/// Causes the GPS Intermediate Driver to restart.
/// </summary>
/// <remarks>This method is only used when changes have been made to GPSID registry settings. When called,
/// the GPSID is instructed to restart itself and load fresh registry settings.</remarks>
public void Restart()
{
/* In order to reset the GPSID, a call is necessary to the "CreateFile" API to "GPD0:" a port
* reserved for the GPSID. Then, a command is sent to refresh the service. This code was written
* based on MSDN documentation here: http://msdn.microsoft.com/en-us/library/bb202123.aspx
*
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);
}
*/
// Open a basic connection to GPD0:
IntPtr handle = NativeMethods.CreateFile("GPD0:",
FileAccess.Read,
FileShare.ReadWrite,
0,
FileMode.Open,
FileAttributes.Normal,
IntPtr.Zero);
// If it succeeded, continue with the refresh command
if (handle == NativeMethods.INVALID_HANDLE)
return;
/* Instruct the driver to refresh all of its settings. What this does is tell the
* GPSID to reload registry settings.
*/
NativeMethods.DeviceIoControl(handle, NativeMethods.IOCTL_SERVICE_REFRESH, IntPtr.Zero, 0, IntPtr.Zero, 0, 0, IntPtr.Zero);
// If the handle is open, close it
NativeMethods.CloseHandle(handle);
}
#endregion
#region Overrides
/// <summary>
/// Controls whether connections are allowed to the GPS Intermediate Driver.
/// </summary>
/// <remarks>When this property is set to <strong>True</strong>, the GPS Intermediate Driver will be responsible
/// for managing all GPS device communications. GPS.NET will only process data arriving from the GPSID. When this
/// property is set to <strong>False</strong>, the GPSID is bypassed and connections will be made directly to a device.</remarks>
public override bool AllowConnections
{
get
{
// If it's forbidden, return false
if (!Devices.AllowGpsIntermediateDriver)
return false;
// Get the raw value
object value = LoadSetting(_RootKeyName, "IsEnabled");
/* If it's null, there's no value! In devices like this, such as the ETEN Glofiish M700,
* the GPSID reports itself as enabled despite no registry value. As a result, I think
* we can assume that no registry value means it's enabled. I'm reluctant to write
* the registry value, however, just because of all the proprietary shit out there. The
* HTC was a disaster when we wrote registry values.
*/
if (value == null)
{
// Set the setting to true
base.AllowConnections = true;
return true;
}
else
{
// Parse the registry value
return Convert.ToBoolean(value);
}
}
set
{
// If it isn't supported then just quit
// Update the registry
SaveSetting(_RootKeyName, "IsEnabled", value);
// For consistency, set the base class
base.AllowConnections = value;
// We'll need a refresh
_IsRestartRequired = true;
}
}
protected override Stream OpenStream(FileAccess access, FileShare sharing)
{
// Yes. Make sure the GPSID is up to snuff.
if (String.IsNullOrEmpty(Port))
Port = "GPD1:";
// If settings have changed, we need to refresh the driver
if (_IsRestartRequired)
{
// We no longer need a restart
_IsRestartRequired = false;
// Refresh the GPSID to use the latest registry settings
Restart();
}
// Yes. Continue as usual
return new SerialStream(Port, 115200, access, sharing);
}
protected override bool DetectProtocol()
{
// If no connections are allowed, exit
if (!AllowConnections)
{
Devices.OnDeviceDetectionAttemptFailed(
new DeviceDetectionException(this, "Connections are not allowed on this device."));
return false;
}
// Open a connection
try
{
Open();
}
catch (Win32Exception ex)
{
/* If the GPSID is misconfigured, or the Hardware Port is not responding, we'll get error 21 (Device not ready)
* So, make it friendly.
*/
if (ex.NativeErrorCode == 21)
{
// Are we allowed to make changes?
if (_IsAutomaticallyConfigured)
{
Devices.OnDeviceDetectionAttemptFailed(
new DeviceDetectionException(this, "The GPS device on " + HardwarePort.Port + " is not responding. The GPSID will be reconfigured if another GPS device is found."));
}
else
{
Devices.OnDeviceDetectionAttemptFailed(
new DeviceDetectionException(this, "The GPS Intermediate Driver can't open the GPS device on " + HardwarePort.Port + ". No repair will be attempted."));
}
return false;
}
throw;
}
// The GPSID works at any baud rate. So, just try and read stuff in
StreamReader reader = new StreamReader(BaseStream, ASCIIEncoding.ASCII, false, NmeaReader.IdealNmeaBufferSize);
for (int count = 0; count < 15; count++)
{
// Read a line
string testLine = null;
try
{
testLine = reader.ReadLine();
}
catch (TimeoutException ex)
{
Devices.OnDeviceDetectionAttemptFailed(
new DeviceDetectionException(this, "A timeout occurred while trying to read from the GPS Intermediate Driver.", ex));
return false;
}
if (
// Is it null?
testLine != null
// Does it begin with a dollar sign?
&& testLine.StartsWith("$")
// Is there an asterisk before that last two characters?
&& testLine.IndexOf("*") == testLine.Length - 3)
{
// Yes! This is an NMEA device.
return true;
}
}
// If we get here, it's garbage
Devices.OnDeviceDetectionAttemptFailed(
new DeviceDetectionException(this, "A connection was opened to the GPS Intermediate Driver but no data was found. The \"Hardware Port\" settings are incorrect, or the GPS device is not responding.", null));
return false;
}
#endregion
#region Internal Methods
// Loads a value from the registry.
internal static object LoadSetting(string keyName, string valueName)
{
RegistryKey rootKey = null;
try
{
rootKey = Registry.LocalMachine.OpenSubKey(keyName, false);
if (rootKey != null)
return rootKey.GetValue(valueName);
else
return null;
}
catch
{
throw;
}
finally
{
if (rootKey != null)
rootKey.Close();
}
}
internal static void DeleteSetting(string keyName, string valueName)
{
RegistryKey rootKey = null;
try
{
rootKey = Registry.LocalMachine.OpenSubKey(keyName, true);
if (rootKey != null)
rootKey.DeleteValue(valueName);
}
catch
{
throw;
}
finally
{
if (rootKey != null)
rootKey.Close();
}
}
// Saves a value to the registry
internal static void SaveSetting(string keyName, string valueName, object value)
{
RegistryKey rootKey = null;
try
{
rootKey = Registry.LocalMachine.OpenSubKey(keyName, true);
if (rootKey != null)
rootKey.SetValue(valueName, value);
}
catch
{
throw;
}
finally
{
if (rootKey != null)
rootKey.Close();
}
}
#endregion
#region Unused Code (Commented Out)
//protected override void OnWriteToCache()
//{
// //throw new NotImplementedException();
//}
//protected override void OnReadFromCache()
//{
// //throw new NotImplementedException();
//}
#endregion
}
public enum GpsIntermediateDriverInterfaceType
{
/// <summary>
/// The setting is custom or unrecognized.
/// </summary>
Unknown,
/// <summary>
/// A serial GPS device is providing raw data.
/// </summary>
SerialDevice,
/// <summary>
/// Raw data is coming from a file.
/// </summary>
File,
/// <summary>
/// Raw GPS data is being polled manually.
/// </summary>
Manual
}
}
#endif