-
Notifications
You must be signed in to change notification settings - Fork 26
/
Unit1.cpp
13409 lines (11273 loc) · 384 KB
/
Unit1.cpp
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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// (c) OneOfEleven 2020
//
// This code can be used on terms of WTFPL Version 2 (http://www.wtfpl.net)
#include <vcl.h>
#include <Clipbrd.hpp>
#include <DateUtils.hpp>
#include <Vcl.FileCtrl.hpp>
#include <System.IOUtils.hpp> // TPath
#include <time.h>
#include <stdio.h>
//#include <mmsystem.h> // PlaySound()
#include <float.h>
//#include <math.h>
#include <Math.hpp>
#include <complex>
#pragma hdrstop
#include "Unit1.h"
#include "settings.h"
#include "DataUnit.h"
#include "CommsUnit.h"
#include "VNAUsartUnit.h"
#include "BatteryVoltageUnit.h"
#include "SettingsUnit.h"
#include "UploadFirmwareUnit.h"
#include "UploadFirmwareV2Unit.h"
#include "CalibrationUnit.h"
#include "ScreenCapture.h"
#include "common.h"
#include "LCMatch.h"
#include "Calibration.h"
//#include "shellscalingapi.h"
#include <initguid.h>
#include <Dbt.h>
#define POPUP_MENU_LINE_PADDING 5
const int RBW_DEFAULT[] = {10, 25, 33, 50, 100, 250, 333, 500, 1000, 2000, 3000, 4000, 5000, 7500, 10000, 20000, 25000, 50000};
const int NUM_POINTS_DEFAULT[] = {51, 101, 201, 401, 801, 1024, 1601, 3201, 4501, 6401, 12801, 25601};
const int NUM_POINTS_V1[] = {51, 101, 201, 401, 801, 1601, 3201, 6401, 12801, 25601};
//const int NUM_POINTS_V2[] = {11, 21, 51, 101, 201, 401, 801, 1024, 1601, 3201, 6401, 12801, 25601};
const int NUM_POINTS_V2[] = {11, 21, 51, 101, 201, 401, 801, 1024}; // the V2 does not handle segments very well - they half it's scan speed
const int NUM_POINTS_V2PLUS4[] = {11, 21, 51, 101, 201, 401, 801, 1601, 3201, 6401, 12801, 25601};
const int NUM_POINTS_JANVNA_V2[] = {11, 21, 51, 101, 201, 401, 801, 1601, 3201, 4501};
const int NUM_POINTS_TINYSA[] = {51, 101, 145, 290, 500, 750, 1000, 2000, 5000};
// ************************************************************************
const GUID GUID_BUS1394_CLASS = {0x6BDD1FC1, 0x810F, 0x11d0, {0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F}};
const GUID GUID_61883_CLASS = {0x7EBEFBC0, 0x3200, 0x11d2, {0xB4, 0xC2, 0x00, 0xA0, 0xC9, 0x69, 0x7D, 0x07}};
const GUID GUID_DEVICE_APPLICATIONLAUNCH_BUTTON = {0x629758EE, 0x986E, 0x4D9E, {0x8E, 0x47, 0xDE, 0x27, 0xF8, 0xAB, 0x05, 0x4D}};
const GUID GUID_DEVICE_BATTERY = {0x72631E54, 0x78A4, 0x11D0, {0xBC, 0xF7, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A}};
const GUID GUID_DEVICE_LID = {0x4AFA3D52, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}};
const GUID GUID_DEVICE_MEMORY = {0x3FD0F03D, 0x92E0, 0x45FB, {0xB7, 0x5C, 0x5E, 0xD8, 0xFF, 0xB0, 0x10, 0x21}};
const GUID GUID_DEVICE_MESSAGE_INDICATOR = {0xCD48A365, 0xFA94, 0x4CE2, {0xA2, 0x32, 0xA1, 0xB7, 0x64, 0xE5, 0xD8, 0xB4}};
const GUID GUID_DEVICE_PROCESSOR = {0x97FADB10, 0x4E33, 0x40AE, {0x35, 0x9C, 0x8B, 0xEF, 0x02, 0x9D, 0xBD, 0xD0}};
const GUID GUID_DEVICE_SYS_BUTTON = {0x4AFA3D53, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}};
const GUID GUID_DEVICE_THERMAL_ZONE = {0x4AFA3D51, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}};
const GUID GUID_BTHPORT_DEVICE_INTERFACE = {0x0850302A, 0xB344, 0x4fda, {0x9B, 0xE9, 0x90, 0x57, 0x6B, 0x8D, 0x46, 0xF0}};
const GUID GUID_DEVINTERFACE_BRIGHTNESS = {0xFDE5BBA4, 0xB3F9, 0x46FB, {0xBD, 0xAA, 0x07, 0x28, 0xCE, 0x31, 0x00, 0xB4}};
const GUID GUID_DEVINTERFACE_DISPLAY_ADAPTER = {0x5B45201D, 0xF2F2, 0x4F3B, {0x85, 0xBB, 0x30, 0xFF, 0x1F, 0x95, 0x35, 0x99}};
const GUID GUID_DEVINTERFACE_I2C = {0x2564AA4F, 0xDDDB, 0x4495, {0xB4, 0x97, 0x6A, 0xD4, 0xA8, 0x41, 0x63, 0xD7}};
const GUID GUID_DEVINTERFACE_IMAGE = {0x6BDD1FC6, 0x810F, 0x11D0, {0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F}};
const GUID GUID_DEVINTERFACE_MONITOR = {0xE6F07B5F, 0xEE97, 0x4a90, {0xB0, 0x76, 0x33, 0xF5, 0x7B, 0xF4, 0xEA, 0xA7}};
const GUID GUID_DEVINTERFACE_OPM = {0xBF4672DE, 0x6B4E, 0x4BE4, {0xA3, 0x25, 0x68, 0xA9, 0x1E, 0xA4, 0x9C, 0x09}};
const GUID GUID_DEVINTERFACE_VIDEO_OUTPUT_ARRIVAL = {0x1AD9E4F0, 0xF88D, 0x4360, {0xBA, 0xB9, 0x4C, 0x2D, 0x55, 0xE5, 0x64, 0xCD}};
const GUID GUID_DISPLAY_DEVICE_ARRIVAL = {0x1CA05180, 0xA699, 0x450A, {0x9A, 0x0C, 0xDE, 0x4F, 0xBE, 0x3D, 0xDD, 0x89}};
const GUID GUID_DEVINTERFACE_HID = {0x4D1E55B2, 0xF16F, 0x11CF, {0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}};
const GUID GUID_DEVINTERFACE_KEYBOARD = {0x884b96c3, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}};
const GUID GUID_DEVINTERFACE_MOUSE = {0x378DE44C, 0x56EF, 0x11D1, {0xBC, 0x8C, 0x00, 0xA0, 0xC9, 0x14, 0x05, 0xDD}};
const GUID GUID_DEVINTERFACE_MODEM = {0x2C7089AA, 0x2E0E, 0x11D1, {0xB1, 0x14, 0x00, 0xC0, 0x4F, 0xC2, 0xAA, 0xE4}};
const GUID GUID_DEVINTERFACE_NET = {0xCAC88484, 0x7515, 0x4C03, {0x82, 0xE6, 0x71, 0xA8, 0x7A, 0xBA, 0xC3, 0x61}};
const GUID GUID_DEVINTERFACE_SENSOR = {0xBA1BB692, 0X9B7A, 0X4833, {0X9A, 0X1E, 0X52, 0X5E, 0XD1, 0X34, 0XE7, 0XE2}};
const GUID GUID_DEVINTERFACE_COMPORT = {0x86E0D1E0, 0x8089, 0x11D0, {0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73}}; // NanoVNA V1
const GUID GUID_DEVINTERFACE_PARALLEL = {0x97F76EF0, 0xF883, 0x11D0, {0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C}};
const GUID GUID_DEVINTERFACE_PARCLASS = {0x811FC6A5, 0xF728, 0x11D0, {0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1}};
const GUID GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR = {0x4D36E978, 0xE325, 0x11CE, {0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18}};
const GUID GUID_DEVINTERFACE_CDCHANGER = {0x53F56312, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_CDROM = {0x53F56308, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_DISK = {0x53F56307, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_FLOPPY = {0x53F56311, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_MEDIUMCHANGER = {0x53F56310, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_PARTITION = {0x53F5630A, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_STORAGEPORT = {0x2ACCFE60, 0xC130, 0x11D2, {0xB0, 0x82, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_TAPE = {0x53F5630B, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_VOLUME = {0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_DEVINTERFACE_WRITEONCEDISK = {0x53F5630C, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_IO_VOLUME_DEVICE_INTERFACE = {0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID MOUNTDEV_MOUNTED_DEVICE_GUID = {0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
const GUID GUID_AVC_CLASS = {0x095780C3, 0x48A1, 0x4570, {0xBD, 0x95, 0x46, 0x70, 0x7F, 0x78, 0xC2, 0xDC}};
const GUID GUID_VIRTUAL_AVC_CLASS = {0x616EF4D0, 0x23CE, 0x446D, {0xA5, 0x68, 0xC3, 0x1E, 0xB0, 0x19, 0x13, 0xD0}};
const GUID KSCATEGORY_ACOUSTIC_ECHO_CANCEL = {0xBF963D80, 0xC559, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}};
const GUID KSCATEGORY_AUDIO = {0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_AUDIO_DEVICE = {0xFBF6F530, 0x07B9, 0x11D2, {0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_AUDIO_GFX = {0x9BAF9572, 0x340C, 0x11D3, {0xAB, 0xDC, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0x6F}};
const GUID KSCATEGORY_AUDIO_SPLITTER = {0x9EA331FA, 0xB91B, 0x45F8, {0x92, 0x85, 0xBD, 0x2B, 0xC7, 0x7A, 0xFC, 0xDE}};
const GUID KSCATEGORY_BDA_IP_SINK = {0x71985F4A, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
const GUID KSCATEGORY_BDA_NETWORK_EPG = {0x71985F49, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
const GUID KSCATEGORY_BDA_NETWORK_PROVIDER = {0x71985F4B, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
const GUID KSCATEGORY_BDA_NETWORK_TUNER = {0x71985F48, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
const GUID KSCATEGORY_BDA_RECEIVER_COMPONENT = {0xFD0A5AF4, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}};
const GUID KSCATEGORY_BDA_TRANSPORT_INFORMATION = {0xA2E3074F, 0x6C3D, 0x11d3, {0xB6, 0x53, 0x00, 0xC0, 0x4F, 0x79, 0x49, 0x8E}};
const GUID KSCATEGORY_BRIDGE = {0x085AFF00, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_CAPTURE = {0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_CLOCK = {0x53172480, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_COMMUNICATIONSTRANSFORM = {0xCF1DDA2C, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_CROSSBAR = {0xA799A801, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}};
const GUID KSCATEGORY_DATACOMPRESSOR = {0x1E84C900, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_DATADECOMPRESSOR = {0x2721AE20, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_DATATRANSFORM = {0x2EB07EA0, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_DRM_DESCRAMBLE = {0xFFBB6E3F, 0xCCFE, 0x4D84, {0x90, 0xD9, 0x42, 0x14, 0x18, 0xB0, 0x3A, 0x8E}};
const GUID KSCATEGORY_ENCODER = {0x19689BF6, 0xC384, 0x48fd, {0xAD, 0x51, 0x90, 0xE5, 0x8C, 0x79, 0xF7, 0x0B}};
const GUID KSCATEGORY_ESCALANTE_PLATFORM_DRIVER = {0x74F3AEA8, 0x9768, 0x11D1, {0x8E, 0x07, 0x00, 0xA0, 0xC9, 0x5E, 0xC2, 0x2E}};
const GUID KSCATEGORY_FILESYSTEM = {0x760FED5E, 0x9357, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_INTERFACETRANSFORM = {0xCF1DDA2D, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_MEDIUMTRANSFORM = {0xCF1DDA2E, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_MICROPHONE_ARRAY_PROCESSOR = {0x830A44F2, 0xA32D, 0x476B, {0xBE, 0x97, 0x42, 0x84, 0x56, 0x73, 0xB3, 0x5A}};
const GUID KSCATEGORY_MIXER = {0xAD809C00, 0x7B88, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_MULTIPLEXER = {0x7A5DE1D3, 0x01A1, 0x452c, {0xB4, 0x81, 0x4F, 0xA2, 0xB9, 0x62, 0x71, 0xE8}};
const GUID KSCATEGORY_NETWORK = {0x67C9CC3C, 0x69C4, 0x11D2, {0x87, 0x59, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_PREFERRED_MIDIOUT_DEVICE = {0xD6C50674, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_WAVEIN_DEVICE = {0xD6C50671, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PREFERRED_WAVEOUT_DEVICE = {0xD6C5066E, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}};
const GUID KSCATEGORY_PROXY = {0x97EBAACA, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_QUALITY = {0x97EBAACB, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_REALTIME = {0xEB115FFC, 0x10C8, 0x4964, {0x83, 0x1D, 0x6D, 0xCB, 0x02, 0xE6, 0xF2, 0x3F}};
const GUID KSCATEGORY_RENDER = {0x65E8773E, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_SPLITTER = {0x0A4252A0, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_SYNTHESIZER = {0xDFF220F3, 0xF70F, 0x11D0, {0xB9, 0x17, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_SYSAUDIO = {0xA7C7A5B1, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}};
const GUID KSCATEGORY_TEXT = {0x6994AD06, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_TOPOLOGY = {0xDDA54A40, 0x1E4C, 0x11D1, {0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00}};
const GUID KSCATEGORY_TVAUDIO = {0xA799A802, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}};
const GUID KSCATEGORY_TVTUNER = {0xA799A800, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}};
const GUID KSCATEGORY_VBICODEC = {0x07DAD660, 0x22F1, 0x11D1, {0xA9, 0xF4, 0x00, 0xC0, 0x4F, 0xBB, 0xDE, 0x8F}};
const GUID KSCATEGORY_VIDEO = {0x6994AD05, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_VIRTUAL = {0x3503EAC4, 0x1F26, 0x11D1, {0x8A, 0xB0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};
const GUID KSCATEGORY_VPMUX = {0xA799A803, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}};
const GUID KSCATEGORY_WDMAUD = {0x3E227E76, 0x690D, 0x11D2, {0x81, 0x61, 0x00, 0x00, 0xF8, 0x77, 0x5B, 0xF1}};
const GUID KSMFT_CATEGORY_AUDIO_DECODER = {0x9ea73fb4, 0xef7a, 0x4559, {0x8d, 0x5d, 0x71, 0x9d, 0x8f, 0x04, 0x26, 0xc7}};
const GUID KSMFT_CATEGORY_AUDIO_EFFECT = {0x11064c48, 0x3648, 0x4ed0, {0x93, 0x2e, 0x05, 0xce, 0x8a, 0xc8, 0x11, 0xb7}};
const GUID KSMFT_CATEGORY_AUDIO_ENCODER = {0x91c64bd0, 0xf91e, 0x4d8c, {0x92, 0x76, 0xdb, 0x24, 0x82, 0x79, 0xd9, 0x75}};
const GUID KSMFT_CATEGORY_DEMULTIPLEXER = {0xa8700a7a, 0x939b, 0x44c5, {0x99, 0xd7, 0x76, 0x22, 0x6b, 0x23, 0xb3, 0xf1}};
const GUID KSMFT_CATEGORY_MULTIPLEXER = {0x059c561e, 0x05ae, 0x4b61, {0xb6, 0x9d, 0x55, 0xb6, 0x1e, 0xe5, 0x4a, 0x7b}};
const GUID KSMFT_CATEGORY_OTHER = {0x90175d57, 0xb7ea, 0x4901, {0xae, 0xb3, 0x93, 0x3a, 0x87, 0x47, 0x75, 0x6f}};
const GUID KSMFT_CATEGORY_VIDEO_DECODER = {0xd6c02d4b, 0x6833, 0x45b4, {0x97, 0x1a, 0x05, 0xa4, 0xb0, 0x4b, 0xab, 0x91}};
const GUID KSMFT_CATEGORY_VIDEO_EFFECT = {0x12e17c21, 0x532c, 0x4a6e, {0x8a, 0x1c, 0x40, 0x82, 0x5a, 0x73, 0x63, 0x97}};
const GUID KSMFT_CATEGORY_VIDEO_ENCODER = {0xf79eac7d, 0xe545, 0x4387, {0xbd, 0xee, 0xd6, 0x47, 0xd7, 0xbd, 0xe4, 0x2a}};
const GUID KSMFT_CATEGORY_VIDEO_PROCESSOR = {0x302ea3fc, 0xaa5f, 0x47f9, {0x9f, 0x7a, 0xc2, 0x18, 0x8b, 0xb1, 0x63, 0x02}};
const GUID GUID_DEVINTERFACE_USB_DEVICE = {0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}};
const GUID GUID_DEVINTERFACE_USB_HOST_CONTROLLER = {0x3ABF6F2D, 0x71C4, 0x462A, {0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27}};
const GUID GUID_DEVINTERFACE_USB_HUB = {0xF18A0E88, 0xC30C, 0x11D0, {0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8}};
const GUID GUID_DEVINTERFACE_WPD = {0x6AC27878, 0xA6FA, 0x4155, {0xBA, 0x85, 0xF9, 0x8F, 0x49, 0x1D, 0x4F, 0x33}};
const GUID GUID_DEVINTERFACE_WPD_PRIVATE = {0xBA0C718F, 0x4DED, 0x49B7, {0xBD, 0xD3, 0xFA, 0xBE, 0x28, 0x66, 0x12, 0x11}};
const GUID GUID_DEVINTERFACE_SIDESHOW = {0x152E5811, 0xFEB9, 0x4B00, {0x90, 0xF4, 0xD3, 0x29, 0x47, 0xAE, 0x16, 0x81}};
//const GUID GUID_DFU = {0x3FE809AB, 0xFB91, 0x4CB5, {0xA6, 0x43, 0x69, 0x67, 0x0D, 0x52, 0x36, 0x6E}};
//const GUID GUID_APP = {0xcb979912, 0x5029, 0x420a, {0xae, 0xb1, 0x34, 0xfc, 0x0a, 0x7d, 0x57, 0x26}};
#if 0
const GUID GUID_DEVINTERFACE_ALL[] =
{
{0x6BDD1FC1, 0x810F, 0x11d0, {0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F}},
{0x7EBEFBC0, 0x3200, 0x11d2, {0xB4, 0xC2, 0x00, 0xA0, 0xC9, 0x69, 0x7D, 0x07}},
{0x629758EE, 0x986E, 0x4D9E, {0x8E, 0x47, 0xDE, 0x27, 0xF8, 0xAB, 0x05, 0x4D}},
{0x72631E54, 0x78A4, 0x11D0, {0xBC, 0xF7, 0x00, 0xAA, 0x00, 0xB7, 0xB3, 0x2A}},
{0x4AFA3D52, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}},
{0x3FD0F03D, 0x92E0, 0x45FB, {0xB7, 0x5C, 0x5E, 0xD8, 0xFF, 0xB0, 0x10, 0x21}},
{0xCD48A365, 0xFA94, 0x4CE2, {0xA2, 0x32, 0xA1, 0xB7, 0x64, 0xE5, 0xD8, 0xB4}},
{0x97FADB10, 0x4E33, 0x40AE, {0x35, 0x9C, 0x8B, 0xEF, 0x02, 0x9D, 0xBD, 0xD0}},
{0x4AFA3D53, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}},
{0x4AFA3D51, 0x74A7, 0x11d0, {0xbe, 0x5e, 0x00, 0xA0, 0xC9, 0x06, 0x28, 0x57}},
{0x0850302A, 0xB344, 0x4fda, {0x9B, 0xE9, 0x90, 0x57, 0x6B, 0x8D, 0x46, 0xF0}},
{0xFDE5BBA4, 0xB3F9, 0x46FB, {0xBD, 0xAA, 0x07, 0x28, 0xCE, 0x31, 0x00, 0xB4}},
{0x5B45201D, 0xF2F2, 0x4F3B, {0x85, 0xBB, 0x30, 0xFF, 0x1F, 0x95, 0x35, 0x99}},
{0x2564AA4F, 0xDDDB, 0x4495, {0xB4, 0x97, 0x6A, 0xD4, 0xA8, 0x41, 0x63, 0xD7}},
{0x6BDD1FC6, 0x810F, 0x11D0, {0xBE, 0xC7, 0x08, 0x00, 0x2B, 0xE2, 0x09, 0x2F}},
{0xE6F07B5F, 0xEE97, 0x4a90, {0xB0, 0x76, 0x33, 0xF5, 0x7B, 0xF4, 0xEA, 0xA7}},
{0xBF4672DE, 0x6B4E, 0x4BE4, {0xA3, 0x25, 0x68, 0xA9, 0x1E, 0xA4, 0x9C, 0x09}},
{0x1AD9E4F0, 0xF88D, 0x4360, {0xBA, 0xB9, 0x4C, 0x2D, 0x55, 0xE5, 0x64, 0xCD}},
{0x1CA05180, 0xA699, 0x450A, {0x9A, 0x0C, 0xDE, 0x4F, 0xBE, 0x3D, 0xDD, 0x89}},
{0x4D1E55B2, 0xF16F, 0x11CF, {0x88, 0xCB, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}},
{0x884b96c3, 0x56ef, 0x11d1, {0xbc, 0x8c, 0x00, 0xa0, 0xc9, 0x14, 0x05, 0xdd}},
{0x378DE44C, 0x56EF, 0x11D1, {0xBC, 0x8C, 0x00, 0xA0, 0xC9, 0x14, 0x05, 0xDD}},
{0x2C7089AA, 0x2E0E, 0x11D1, {0xB1, 0x14, 0x00, 0xC0, 0x4F, 0xC2, 0xAA, 0xE4}},
{0xCAC88484, 0x7515, 0x4C03, {0x82, 0xE6, 0x71, 0xA8, 0x7A, 0xBA, 0xC3, 0x61}},
{0xBA1BB692, 0X9B7A, 0X4833, {0X9A, 0X1E, 0X52, 0X5E, 0XD1, 0X34, 0XE7, 0XE2}},
{0x86E0D1E0, 0x8089, 0x11D0, {0x9C, 0xE4, 0x08, 0x00, 0x3E, 0x30, 0x1F, 0x73}}, // NanoVNA V1
{0x97F76EF0, 0xF883, 0x11D0, {0xAF, 0x1F, 0x00, 0x00, 0xF8, 0x00, 0x84, 0x5C}},
{0x811FC6A5, 0xF728, 0x11D0, {0xA5, 0x37, 0x00, 0x00, 0xF8, 0x75, 0x3E, 0xD1}},
{0x4D36E978, 0xE325, 0x11CE, {0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18}},
{0x53F56312, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F56308, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F56307, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F56311, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F56310, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630A, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x2ACCFE60, 0xC130, 0x11D2, {0xB0, 0x82, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630B, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630C, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}},
{0x095780C3, 0x48A1, 0x4570, {0xBD, 0x95, 0x46, 0x70, 0x7F, 0x78, 0xC2, 0xDC}},
{0x616EF4D0, 0x23CE, 0x446D, {0xA5, 0x68, 0xC3, 0x1E, 0xB0, 0x19, 0x13, 0xD0}},
{0xBF963D80, 0xC559, 0x11D0, {0x8A, 0x2B, 0x00, 0xA0, 0xC9, 0x25, 0x5A, 0xC1}},
{0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xFBF6F530, 0x07B9, 0x11D2, {0xA7, 0x1E, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}},
{0x9BAF9572, 0x340C, 0x11D3, {0xAB, 0xDC, 0x00, 0xA0, 0xC9, 0x0A, 0xB1, 0x6F}},
{0x9EA331FA, 0xB91B, 0x45F8, {0x92, 0x85, 0xBD, 0x2B, 0xC7, 0x7A, 0xFC, 0xDE}},
{0x71985F4A, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}},
{0x71985F49, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}},
{0x71985F4B, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}},
{0x71985F48, 0x1CA1, 0x11d3, {0x9C, 0xC8, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}},
{0xFD0A5AF4, 0xB41D, 0x11d2, {0x9C, 0x95, 0x00, 0xC0, 0x4F, 0x79, 0x71, 0xE0}},
{0xA2E3074F, 0x6C3D, 0x11d3, {0xB6, 0x53, 0x00, 0xC0, 0x4F, 0x79, 0x49, 0x8E}},
{0x085AFF00, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0x53172480, 0x4791, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0xCF1DDA2C, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xA799A801, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}},
{0x1E84C900, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0x2721AE20, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0x2EB07EA0, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0xFFBB6E3F, 0xCCFE, 0x4D84, {0x90, 0xD9, 0x42, 0x14, 0x18, 0xB0, 0x3A, 0x8E}},
{0x19689BF6, 0xC384, 0x48fd, {0xAD, 0x51, 0x90, 0xE5, 0x8C, 0x79, 0xF7, 0x0B}},
{0x74F3AEA8, 0x9768, 0x11D1, {0x8E, 0x07, 0x00, 0xA0, 0xC9, 0x5E, 0xC2, 0x2E}},
{0x760FED5E, 0x9357, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xCF1DDA2D, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xCF1DDA2E, 0x9743, 0x11D0, {0xA3, 0xEE, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0x830A44F2, 0xA32D, 0x476B, {0xBE, 0x97, 0x42, 0x84, 0x56, 0x73, 0xB3, 0x5A}},
{0xAD809C00, 0x7B88, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0x7A5DE1D3, 0x01A1, 0x452c, {0xB4, 0x81, 0x4F, 0xA2, 0xB9, 0x62, 0x71, 0xE8}},
{0x67C9CC3C, 0x69C4, 0x11D2, {0x87, 0x59, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xD6C50674, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}},
{0xD6C50671, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}},
{0xD6C5066E, 0x72C1, 0x11D2, {0x97, 0x55, 0x00, 0x00, 0xF8, 0x00, 0x47, 0x88}},
{0x97EBAACA, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0x97EBAACB, 0x95BD, 0x11D0, {0xA3, 0xEA, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xEB115FFC, 0x10C8, 0x4964, {0x83, 0x1D, 0x6D, 0xCB, 0x02, 0xE6, 0xF2, 0x3F}},
{0x65E8773E, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0x0A4252A0, 0x7E70, 0x11D0, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}},
{0xDFF220F3, 0xF70F, 0x11D0, {0xB9, 0x17, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xA7C7A5B1, 0x5AF3, 0x11D1, {0x9C, 0xED, 0x00, 0xA0, 0x24, 0xBF, 0x04, 0x07}},
{0x6994AD06, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xDDA54A40, 0x1E4C, 0x11D1, {0xA0, 0x50, 0x40, 0x57, 0x05, 0xC1, 0x00, 0x00}},
{0xA799A802, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}},
{0xA799A800, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}},
{0x07DAD660, 0x22F1, 0x11D1, {0xA9, 0xF4, 0x00, 0xC0, 0x4F, 0xBB, 0xDE, 0x8F}},
{0x6994AD05, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0x3503EAC4, 0x1F26, 0x11D1, {0x8A, 0xB0, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}},
{0xA799A803, 0xA46D, 0x11D0, {0xA1, 0x8C, 0x00, 0xA0, 0x24, 0x01, 0xDC, 0xD4}},
{0x3E227E76, 0x690D, 0x11D2, {0x81, 0x61, 0x00, 0x00, 0xF8, 0x77, 0x5B, 0xF1}},
{0x9ea73fb4, 0xef7a, 0x4559, {0x8d, 0x5d, 0x71, 0x9d, 0x8f, 0x04, 0x26, 0xc7}},
{0x11064c48, 0x3648, 0x4ed0, {0x93, 0x2e, 0x05, 0xce, 0x8a, 0xc8, 0x11, 0xb7}},
{0x91c64bd0, 0xf91e, 0x4d8c, {0x92, 0x76, 0xdb, 0x24, 0x82, 0x79, 0xd9, 0x75}},
{0xa8700a7a, 0x939b, 0x44c5, {0x99, 0xd7, 0x76, 0x22, 0x6b, 0x23, 0xb3, 0xf1}},
{0x059c561e, 0x05ae, 0x4b61, {0xb6, 0x9d, 0x55, 0xb6, 0x1e, 0xe5, 0x4a, 0x7b}},
{0x90175d57, 0xb7ea, 0x4901, {0xae, 0xb3, 0x93, 0x3a, 0x87, 0x47, 0x75, 0x6f}},
{0xd6c02d4b, 0x6833, 0x45b4, {0x97, 0x1a, 0x05, 0xa4, 0xb0, 0x4b, 0xab, 0x91}},
{0x12e17c21, 0x532c, 0x4a6e, {0x8a, 0x1c, 0x40, 0x82, 0x5a, 0x73, 0x63, 0x97}},
{0xf79eac7d, 0xe545, 0x4387, {0xbd, 0xee, 0xd6, 0x47, 0xd7, 0xbd, 0xe4, 0x2a}},
{0x302ea3fc, 0xaa5f, 0x47f9, {0x9f, 0x7a, 0xc2, 0x18, 0x8b, 0xb1, 0x63, 0x02}},
{0xA5DCBF10, 0x6530, 0x11D2, {0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED}},
{0x3ABF6F2D, 0x71C4, 0x462A, {0x8A, 0x92, 0x1E, 0x68, 0x61, 0xE6, 0xAF, 0x27}},
{0xF18A0E88, 0xC30C, 0x11D0, {0x88, 0x15, 0x00, 0xA0, 0xC9, 0x06, 0xBE, 0xD8}},
{0x6AC27878, 0xA6FA, 0x4155, {0xBA, 0x85, 0xF9, 0x8F, 0x49, 0x1D, 0x4F, 0x33}},
{0xBA0C718F, 0x4DED, 0x49B7, {0xBD, 0xD3, 0xFA, 0xBE, 0x28, 0x66, 0x12, 0x11}},
{0x152E5811, 0xFEB9, 0x4B00, {0x90, 0xF4, 0xD3, 0x29, 0x47, 0xAE, 0x16, 0x81}},
{0x3FE809AB, 0xFB91, 0x4CB5, {0xA6, 0x43, 0x69, 0x67, 0x0D, 0x52, 0x36, 0x6E}},
{0xcb979912, 0x5029, 0x420a, {0xae, 0xb1, 0x34, 0xfc, 0x0a, 0x7d, 0x57, 0x26}}
};
#endif
/*
// FTDI GUID list
const GUID GUID_DEVINTERFACE_FTDI[] =
{
{0x86e0d1e0, 0x8089, 0x11d0, {0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73}}, // COMPORT
{0xa5dcbf10, 0x6530, 0x11d2, {0x90, 0x1f, 0x00, 0xc0, 0x4f, 0xb9, 0x51, 0xed}}, // USB_DEVICE
{0x53f56307, 0xb6bf, 0x11d0, {0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b}}, // DISK
{0x4d1e55b2, 0xf16f, 0x11Cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}}, // HID
{0xad498944, 0x762f, 0x11d0, {0x8d, 0xcb, 0x00, 0xc0, 0x4f, 0xc3, 0x35, 0x8c}}, //
{0x219d0508, 0x57a8, 0x4ff5, {0x97, 0xa1, 0xbd, 0x86, 0x58, 0x7c, 0x6c, 0x7e}} //
};
*/
// VID/PID for STM32F bootloader
#define MD_VID 0x0483
#define MD_PID 0xDF11
// VID's/PID's for GD32 NanoVNA V2's
#define V2A_VID 0x0483 // this when no bootloader and no firmware present ?
#define V2A_PID 0x5740 //
#define V2B_VID 0x04b4 // this when a NanoVNA V2 is present - either DFU bootloader mode or normal mode
#define V2B_PID 0x0008 // " "
// ************************************************************************
#pragma package(smart_init)
#pragma resource "*.dfm"
const float rad_2_deg = 180.0 / M_PI;
const float deg_2_rad = M_PI / 180.0;
TForm1 *Form1 = NULL;
// ***************************************
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
String s;
m_initialised = false;
m_window_not_minimized_count = 0;
// A few quick notes on _control87.
// This function is used to control the behavior of the FPU.
// The flags that are being passed (MCW_EM) tell the FPU not to throw any exceptions.
// This is useful when calling into MS libraries that perform FP calculations partly due
// to the difference in how floating point values are stored.
// The flag MCW_EM suppresses all FPU exceptions but this can be fine tuned.
// See float.h for more info.
// _control87(MCW_EM, MCW_EM);
/*
{
CHighResolutionTick timer;
//value = pow(base, exponent);
//value = exp(exponent);
//exponent = log(value);
//exponent = log10(value);
const double range = 10.0;
const double gamma = 4.0;
const double ig = 1.0 / gamma;
const double d1 = 0.5;
const double d2 = pow(d1 / range, ig) * range;
//const double d2 = exp(log(d1 / range) * ig) * range;
// const double d3 = log(1.0 + d1) * ig;
const double d3 = (exp(d1) - 1.0) * range / (exp(range) - 1.0);
// const double d3 = log(1.0 + d1 * gamma) * range / log(1.0 + range * gamma);
const double d4 = pow(d2 / range, gamma) * range;
const double d5 = d4 - d1;
timer.mark();
for (int i = 0; i < 1000000; i++)
const double d = pow(d1, ig);
const double secs1 = timer.secs();
timer.mark();
for (int i = 0; i < 1000000; i++)
const double d = log(d1);
const double secs2 = timer.secs();
timer.mark();
for (int i = 0; i < 1000000; i++)
const double d = exp(d1);
const double secs3 = timer.secs();
timer.mark();
for (int i = 0; i < 1000000; i++)
const double d = exp(log(d1) * ig);
const double secs4 = timer.secs();
const double da = secs1 / secs4;
const double db = secs1 / secs2;
const double dc = secs1 / secs3;
}
*/
// set_terminate(myTerminate);
// ********************
/*
{
std::complex <float> c3s;
nonstd::complex <float> c3n;
const std::complex <float> c1s(2.5, 0.1);
const std::complex <float> c2s(3.5, 4.1);
const nonstd::complex <float> c1n(2.5, 0.1);
const nonstd::complex <float> c2n(3.5, 4.1);
s.printf(L"%f %f %f %f", c1s.real(), c1s.imag(), c1n.real(), c1n.imag());
s.printf(L"%f %f %f %f", c2s.real(), c2s.imag(), c2n.real(), c2n.imag());
c3s = -c1s;
c3n = -c1n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s + c2s;
c3n = c1n + c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = 1.0f + c2s;
c3n = 1.0f + c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = 1.0f - c2s;
c3n = 1.0f - c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = 2.0f * c2s;
c3n = 2.0f * c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = 2.0f / c2s;
c3n = 2.0f / c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s + 1.6f;
c3n = c1n + 1.6f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s - 1.6f;
c3n = c1n - 1.6f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s * 1.6f;
c3n = c1n * 1.6f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s / 1.6f;
c3n = c1n / 1.6f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s / c2s;
c3n = c1n / c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s = c1s * c2s;
c3n = c1n * c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s /= c2s;
c3n /= c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s *= 2.0f;
c3n *= 2.0f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s *= c2s;
c3n *= c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s += c2s;
c3n += c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s -= c2s;
c3n -= c2n;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s += 2.0f;
c3n += 2.0f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
c3s -= 2.0f;
c3n -= 2.0f;
s.printf(L"%f %f %f %f", c3s.real(), c3s.imag(), c3n.real(), c3n.imag());
}
*/
// ********************
/*
::GetSystemInfo(&SystemInfo);
// sprintf(SystemInfoStr,
// "OEM id: %u"crlf
// "num of cpu's: %u"crlf
// "page size: %u"crlf
// "cpu type: %u"crlf
// "min app addr: %lx"crlf
// "max app addr: %lx"crlf
// "active cpu mask: %u"crlf,
// SystemInfo.dwOemId,
// SystemInfo.dwNumberOfProcessors,
// SystemInfo.dwPageSize,
// SystemInfo.dwProcessorType,
// SystemInfo.lpMinimumApplicationAddress,
// SystemInfo.lpMaximumApplicationAddress,
// SystemInfo.dwActiveProcessorMask);
// MemoAddString(Memo1, SystemInfoStr);
*/
{ // get the phsyical screen size
m_screen_width = 0;
m_screen_height = 0;
SYSTEM_INFO m_system_info;
HDC hDC = GetDC(0);
if (hDC != NULL)
{
//ScreenBitsPerPixel = ::GetDeviceCaps(hDC, BITSPIXEL);
m_screen_width = ::GetDeviceCaps(hDC, HORZRES);
m_screen_height = ::GetDeviceCaps(hDC, VERTRES);
ReleaseDC(0, hDC);
}
}
{ // make a title string to use in the title bar
TVersion version;
common.GetBuildInfo(Application->ExeName, &version);
String s;
#ifdef _DEBUG
s.printf(L"v%u.%u.%u.debug", version.MajorVer, version.MinorVer, version.ReleaseVer);
#else
s.printf(L"v%u.%u.%u", version.MajorVer, version.MinorVer, version.ReleaseVer);
#endif
String windows_ver = common.windowsVer;
String local_name = common.localName;
common.title = Application->Title + " " + s + " by OneOfEleven";
this->Caption = common.title;
StatusBar2->Panels->Items[0]->Text = windows_ver + " " + local_name + " '" + String(common.decimalPoint()) + "'";
}
#ifndef USE_OPENGL
GLPanel->Enabled = false;
GLPanel->Visible = false;
GraphPaintBox->Enabled = true;
GraphPaintBox->Visible = true;
#else
GraphPaintBox->Enabled = false;
GraphPaintBox->Visible = false;
GLPanel->Enabled = true;
GLPanel->Visible = true;
#endif
// help stop flicker
this->ControlStyle = this->ControlStyle << csOpaque;
Panel1->ControlStyle = Panel1->ControlStyle << csOpaque;
Panel2->ControlStyle = Panel2->ControlStyle << csOpaque;
GLPanel->ControlStyle = GLPanel->ControlStyle << csOpaque;
InfoPanel->ControlStyle = InfoPanel->ControlStyle << csOpaque;
GraphPaintBox->ControlStyle = GraphPaintBox->ControlStyle << csOpaque;
// save the current GUI colours
m_info_panel_colours.push_back(InfoPanel->Color);
for (int i = 0; i < InfoPanel->ControlCount; i++)
{
TControl *control = InfoPanel->Controls[i];
TLabel *label = dynamic_cast<TLabel *>(control);
if (label)
m_info_panel_colours.push_back(label->Color);
}
{
const TNotifyEvent ne = HistoryTrackBar->OnChange;
HistoryTrackBar->OnChange = NULL;
HistoryTrackBar->Max = 0;
HistoryTrackBar->Min = -((int)MAX_HISTORY - 1);
HistoryTrackBar->Position = 0;
HistoryTrackBar->OnChange = ne;
HistoryTrackBar->ShowSelRange = true;
HistoryTrackBar->SelStart = HistoryTrackBar->Max;
HistoryTrackBar->SelEnd = HistoryTrackBar->Max;
}
{
const TNotifyEvent ne = TimeAverageLevelTrackBar->OnChange;
TimeAverageLevelTrackBar->OnChange = NULL;
TimeAverageLevelTrackBar->Max = MAX_HISTORY_POWER;
TimeAverageLevelTrackBar->OnChange = ne;
}
SetScanRangeToVNAScanRangeBitBtn->Enabled = false;
{
const TNotifyEvent ne = ConnectDisconnectSpeedButton->OnClick;
ConnectDisconnectSpeedButton->OnClick = NULL;
ConnectDisconnectSpeedButton->Caption = "Disconnected";
ConnectDisconnectSpeedButton->Down = false;
ConnectDisconnectSpeedButton->OnClick = ne;
}
#ifndef TCPIPH
m_comms.tcpip = NULL;
m_comms.tcpip_stream_rx = new TMemoryStream();
#endif
m_comms.connect_timer_tick = 0;
m_comms.rx.buffer_wr = 0;
m_comms.rx.buffer.resize(8192);
m_record.enabled = true;
// RecordSpeedButton->Hint = "Right click to set the recording path .. " + settings.recordFolder;
CaptureVNAScreenBitBtn->Enabled = false;
if (VNAScreenCaptureForm)
VNAScreenCaptureForm->Hide();
MemorySpeedButton0->Down = settings.memoryEnable[0];
MemorySpeedButton0->Caption = "Live";
MemorySpeedButton1->Down = settings.memoryEnable[1];
MemorySpeedButton1->Caption = "m1";
MemorySpeedButton2->Down = settings.memoryEnable[2];
MemorySpeedButton2->Caption = "m2";
MemorySpeedButton3->Down = settings.memoryEnable[3];
MemorySpeedButton3->Caption = "m3";
MemorySpeedButton4->Down = settings.memoryEnable[4];
MemorySpeedButton4->Caption = "m4";
m_thread = NULL;
// gdiplusToken = 0;
// Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
buildMarkerListBox();
EnableNormaliseSpeedButton->Enabled = !data_unit.m_point_norm.empty();
if (!EnableNormaliseSpeedButton->Enabled)
{
EnableNormaliseSpeedButton->Down = false;
settings.normalisationEnabled = false;
}
DeleteFrequencyMarkersBitBtn->Enabled = false;
StatusBar1->Panels->Items[1]->Text = "Points";
StatusBar1->Panels->Items[2]->Text = "Seg";
StatusBar1->Panels->Items[3]->Text = "History";
StatusBar1->Panels->Items[4]->Text = "Scans";
updateStepDisplay();
StatusBar1->Panels->Items[6]->Text = common.libusbVersion;
StatusBar2->Panels->Items[1]->Text = "Points/sec";
StatusBar2->Panels->Items[2]->Text = "Battery";
StatusBar2->Panels->Items[3]->Text = "Threshold (Hz)";
StatusBar2->Panels->Items[4]->Text = "Point RBW (Hz)";
StatusBar2->Panels->Items[5]->Text = "Device";
// ***************
// clear warnings
common.setWarning(StartMHzEdit, "");
common.setWarning(StopMHzEdit, "");
common.setWarning(CenterMHzEdit, "");
common.setWarning(SpanMHzEdit, "");
common.setWarning(CWMHzEdit, "");
common.setWarning(PointBandwidthHzComboBox, "");
common.setWarning(NumberOfPointsComboBox, "");
common.setWarning(VelocityFactorEdit, "");
// ***************
StopScanBitBtn->Enabled = false;
ScanOnceSpeedButton->Enabled = false;
ScanOnceSpeedButton->Down = false;
ScanSpeedButton->Enabled = false;
ScanSpeedButton->Down = false;
SaveDialog1->InitialDir = ExtractFilePath(Application->ExeName);
// NumberOfPointsTrackBarChange(NumberOfPointsTrackBar);
m_memory_but_index = -1;
m_popup_menu_memory_index = -1;
m_popup_menu_mouse_graph = -1;
m_popup_menu_mouse_Hz = -1;
m_popup_menu_mouse_marker = -1;
m_popup_menu_marker_index = -1;
m_popup_menu_graph_type_graph = -1;
graphs.m_mouse.graph_type_select = -1;
createGraphTypeMenus();
updatePointBandwidthComboBox(true);
updateNumberOfPointsComboBox(false);
updateVelocityFactorComboBox();
updateCalibrationSelectComboBox();
// *****************
updateDeviceComboBox();
{
TComboBox *cb = SerialPortBaudrateComboBox;
const TNotifyEvent ne = cb->OnChange;
cb->OnChange = NULL;
cb->Items->BeginUpdate();
cb->Clear();
cb->AddItem("1200", (TObject *)1200);
cb->AddItem("2400", (TObject *)2400);
cb->AddItem("4800", (TObject *)4800);
cb->AddItem("9600", (TObject *)9600);
cb->AddItem("19200", (TObject *)19200);
cb->AddItem("38400", (TObject *)38400);
cb->AddItem("57600", (TObject *)57600);
cb->AddItem("76800", (TObject *)76800);
cb->AddItem("115200", (TObject *)115200);
cb->AddItem("230400", (TObject *)230400);
cb->AddItem("250000", (TObject *)250000);
cb->AddItem("460800", (TObject *)460800);
cb->AddItem("500000", (TObject *)500000);
cb->AddItem("921600", (TObject *)921600);
cb->AddItem("1000000", (TObject *)1000000);
cb->AddItem("1843200", (TObject *)1843200);
cb->AddItem("2000000", (TObject *)2000000);
cb->AddItem("3000000", (TObject *)3000000);
cb->AddItem("3686400", (TObject *)3686400);
const int i = cb->Items->IndexOfObject((TObject *)115200);
cb->ItemIndex = (i >= 0) ? i : 8;
cb->Items->EndUpdate();
cb->OnChange = ne;
common.comboBoxAutoWidth(cb);
}
// *****************
InfoPanelToggleSwitch->State = settings.infoPanel ? tssOn : tssOff;
InfoPanel->Visible = settings.infoPanel;
updateInfoPanel();
// move to the saved position
this->Top = settings.mainWindowPos.top;
this->Left = settings.mainWindowPos.left;
this->Width = settings.mainWindowPos.width;
this->Height = settings.mainWindowPos.height;
if (Screen)
{
Screen->OnActiveFormChange = ActiveFormChanged;
Screen->OnActiveControlChange = ActiveControlChanged;
}
init();
Application->OnShowHint = OnShowHint;
// Application->OnHint = OnHint;
#ifdef USE_OPENGL
graphs.glInit(GLPanel);
#endif
this->WindowProc = WndProc;
// Application->OnIdle = onIdle;
Application->OnRestore = onRestore;
// ::PostMessage(this->Handle, WM_UPDATE_INFO_PANEL, 0, 0);
::PostMessage(this->Handle, WM_INIT_GUI, 0, 0);
}
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
if (Screen)
{
Screen->OnActiveFormChange = NULL;
Screen->OnActiveControlChange = NULL;
}
Timer1->Enabled = false;
if (connected())
{
stop();
disconnect();
}
for (int i = (int)m_notification_handle.size() - 1; i >= 0; i--)
{
if (m_notification_handle[i])
::UnregisterDeviceNotification(m_notification_handle[i]);
m_notification_handle[i] = NULL;
}
m_notification_handle.resize(0);
#ifndef TCPIPH
//if (m_comms.tcpip_stream_tx)
// delete m_comms.tcpip_stream_tx;
//m_comms.tcpip_stream_tx = NULL;
if (m_comms.tcpip_stream_rx)
delete m_comms.tcpip_stream_rx;
m_comms.tcpip_stream_rx = NULL;
if (m_comms.tcpip)
{
try
{
delete m_comms.tcpip;
m_comms.tcpip = NULL;
}
catch (Exception &exception)
{
//Application->ShowException(&exception);
//String s = exception.ToString();
m_comms.tcpip = NULL;
}
}
#endif
// if (gdiplusToken != 0)
// Gdiplus::GdiplusShutdown(gdiplusToken);
// gdiplusToken = 0;
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
Timer1->Enabled = false;
if (connected())
{
stop();
disconnect();
}
// save the memories
for (int i = 0; i < MAX_MEMORIES; i++)
{
String filename;
filename.printf(L"mem_%d.s2p", i);
//filename.printf(L"mem_%d.csv", i);
filename = ExtractFilePath(Application->ExeName) + filename;
if (!data_unit.m_point_mem[i].empty())
{
common.saveSParams(data_unit.m_point_mem[i], 4, filename);
//common.saveCSV(data_unit.m_point_mem[i], 1, false, filename);
//common.saveCSV(data_unit.m_point_mem[i], 4, false, filename);
}
else
{ // memory is empty, so don't load anything in next time we are run
if (FileExists(filename))
DeleteFile(filename);
}
}
{ // save the normalisation memory
String filename = "norm.s2p";
filename = ExtractFilePath(Application->ExeName) + filename;
if (!data_unit.m_point_norm.empty())
{
common.saveSParams(data_unit.m_point_norm, 4, filename);
}
else
{ // memory is empty, so don't load anything in next time we are run
if (FileExists(filename))
DeleteFile(filename);
}
}
saveSettings();
}
void __fastcall TForm1::myTerminate()
{
pushCommMessage("exception not caught");
}
void __fastcall TForm1::onIdle(TObject *Sender, bool &done)
{
// done = false;
}
void __fastcall TForm1::onRestore(TObject *Sender)
{
//
}
bool __fastcall TForm1::scanUSB(const GUID guid, const uint16_t vid, const uint16_t pid)
{
// const GUID guid = GUID_DEVINTERFACE_USB_DEVICE;
// const GUID guid = GUID_DEVINTERFACE_COMPORT;
HDEVINFO dev_info = ::SetupDiGetClassDevs(&guid, NULL, NULL, DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
if (dev_info == INVALID_HANDLE_VALUE)
return false;
int devIndex = -1;
std::vector <uint8_t> buffer;
bool found = false;
while (true)
{
BOOL res;
char str[512];
t_usb_device usb_device;
usb_device.index = ++devIndex;
usb_device.vid = -1;
usb_device.pid = -1;
SP_INTERFACE_DEVICE_DATA ifData;
memset(&ifData, 0, sizeof(SP_INTERFACE_DEVICE_DATA));
ifData.cbSize = sizeof(ifData);
res = ::SetupDiEnumDeviceInterfaces(dev_info, NULL, &guid, devIndex, &ifData);
if (!res)
{ // not found
::SetupDiDestroyDeviceInfoList(dev_info);
//dev_info = NULL;
break;
}
SP_DEVINFO_DATA did;
memset(&did, 0, sizeof(SP_DEVINFO_DATA));
did.cbSize = sizeof(SP_DEVINFO_DATA);
DWORD needed = 0;
::SetupDiGetDeviceInterfaceDetail(dev_info, &ifData, NULL, 0, &needed, &did);
//res = ::SetupDiGetDeviceInterfaceDetail(dev_info, &ifData, NULL, 0, &needed, NULL);
if (needed <= 0)
continue;
buffer.resize(needed);
memset(&buffer[0], 0, needed);
SP_INTERFACE_DEVICE_DETAIL_DATA *detail = (SP_INTERFACE_DEVICE_DETAIL_DATA *)&buffer[0];
detail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
//SP_DEVINFO_DATA did;
//memset(&did, 0, sizeof(SP_DEVINFO_DATA));
//did.cbSize = sizeof(SP_DEVINFO_DATA);
//res = ::SetupDiGetDeviceInterfaceDetail(dev_info, &ifData, detail, needed, NULL, &did);
res = ::SetupDiGetDeviceInterfaceDetail(dev_info, &ifData, detail, needed, NULL, NULL);
if (!res)
continue;
usb_device.path = AnsiString(detail->DevicePath);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_DEVICEDESC, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.description = AnsiString(str);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_ENUMERATOR_NAME, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.enumerator_name = AnsiString(str);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_FRIENDLYNAME, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.friendly_name = AnsiString(str);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_LOCATION_INFORMATION, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.location_information = AnsiString(str);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_MFG, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.mfg = AnsiString(str);
memset(str, 0, sizeof(str));
res = ::SetupDiGetDeviceRegistryProperty(dev_info, &did, SPDRP_SERVICE, NULL, (PBYTE)str, sizeof(str), NULL);
if (res)
usb_device.service = AnsiString(str);
if (!usb_device.path.IsEmpty())
{
int i;