forked from microsoft/wil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistry.h
3196 lines (2986 loc) · 190 KB
/
registry.h
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
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT.
//
//*********************************************************
#ifndef __WIL_REGISTRY_INCLUDED
#define __WIL_REGISTRY_INCLUDED
#ifdef _KERNEL_MODE
#error This header is not supported in kernel-mode.
#endif
#include <winreg.h>
#include <new.h> // new(std::nothrow)
#include "registry_helpers.h"
#include "resource.h"
// wil registry does not require the use of the STL or C++ exceptions (see _nothrow functions)
// wil registry natively supports std::vector and std::wstring when preferring those types
// wil registry uses the __WIL_WINREG_STL define to enable support for wil::shared_* types (defined in resource.h)
namespace wil
{
namespace reg
{
#if defined(WIL_ENABLE_EXCEPTIONS)
/**
* \brief Opens a new HKEY to the specified path - see RegOpenKeyExW
* \param key An open or well-known registry key
* \param subKey The name of the registry subkey to be opened.
* If `nullptr`, then `key` is used without modification.
* \param access The requested access desired for the opened key
* \return A wil::unique_hkey containing the resulting opened HKEY
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline ::wil::unique_hkey open_unique_key(HKEY key, _In_opt_ PCWSTR subKey, ::wil::reg::key_access access = ::wil::reg::key_access::read)
{
const reg_view_details::reg_view regview{ key };
::wil::unique_hkey return_value;
regview.open_key(subKey, &return_value, access);
return return_value;
}
/**
* \brief Creates a new HKEY to the specified path - see RegCreateKeyExW
* \param key An open or well-known registry key
* \param subKey The name of a subkey that this function opens or creates.
* Note: this cannot be null (see the above referenced API documentation)
* \param access The requested access desired for the opened key
* \return A wil::unique_hkey or wil::shared_hkey containing the resulting opened HKEY
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline ::wil::unique_hkey create_unique_key(HKEY key, PCWSTR subKey, ::wil::reg::key_access access = ::wil::reg::key_access::read)
{
const reg_view_details::reg_view regview{ key };
::wil::unique_hkey return_value;
regview.create_key(subKey, &return_value, access);
return return_value;
}
#if defined(__WIL_WINREG_STL)
/**
* \brief Opens a new HKEY to the specified path - see RegOpenKeyExW
* \param key An open or well-known registry key
* \param subKey The name of the registry subkey to be opened.
* If `nullptr`, then `key` is used without modification.
* \param access The requested access desired for the opened key
* \return A wil::shared_hkey containing the resulting opened HKEY
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline ::wil::shared_hkey open_shared_key(HKEY key, _In_opt_ PCWSTR subKey, ::wil::reg::key_access access = ::wil::reg::key_access::read)
{
const reg_view_details::reg_view regview{ key };
::wil::shared_hkey return_value;
regview.open_key(subKey, &return_value, access);
return return_value;
}
/**
* \brief Creates a new HKEY to the specified path - see RegCreateKeyExW
* \param key An open or well-known registry key
* \param subKey The name of a subkey that this function opens or creates.
* Note: this cannot be null (see the above referenced API documentation)
* \param access The requested access desired for the opened key
* \return A wil::shared_hkey or wil::shared_hkey containing the resulting opened HKEY
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline ::wil::shared_hkey create_shared_key(HKEY key, PCWSTR subKey, ::wil::reg::key_access access = ::wil::reg::key_access::read)
{
const reg_view_details::reg_view regview{ key };
::wil::shared_hkey return_value;
regview.create_key(subKey, &return_value, access);
return return_value;
}
#endif // #if defined(__WIL_WINREG_STL)
#endif // #if defined(WIL_ENABLE_EXCEPTIONS)
/**
* \brief Opens a new HKEY to the specified path - see RegOpenKeyExW
* \param key An open or well-known registry key
* \param subKey The name of the registry subkey to be opened.
* If `nullptr`, then `key` is used without modification.
* \param[out] hkey A reference to a wil::unique_hkey to receive the opened HKEY
* \param access The requested access desired for the opened key
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT open_unique_key_nothrow(HKEY key, _In_opt_ PCWSTR subKey, ::wil::unique_hkey& hkey, ::wil::reg::key_access access = ::wil::reg::key_access::read) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.open_key(subKey, hkey.put(), access);
}
/**
* \brief Creates a new HKEY to the specified path - see RegCreateKeyExW
* \param key An open or well-known registry key
* \param subKey The name of a subkey that this function opens or creates.
* Note: this cannot be null (see the above referenced API documentation)
* \param[out] hkey A reference to a wil::unique_hkey to receive the opened HKEY
* \param access The requested access desired for the opened key
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT create_unique_key_nothrow(HKEY key, PCWSTR subKey, ::wil::unique_hkey& hkey, ::wil::reg::key_access access = ::wil::reg::key_access::read) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.create_key(subKey, hkey.put(), access);
}
#if defined(__WIL_WINREG_STL)
/**
* \brief Opens a new HKEY to the specified path - see RegOpenKeyExW
* \param key An open or well-known registry key
* \param subKey The name of the registry subkey to be opened.
* If `nullptr`, then `key` is used without modification.
* \param[out] hkey A reference to a wil::shared_hkey to receive the opened HKEY
* \param access The requested access desired for the opened key
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT open_shared_key_nothrow(HKEY key, _In_opt_ PCWSTR subKey, ::wil::shared_hkey& hkey, ::wil::reg::key_access access = ::wil::reg::key_access::read) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.open_key(subKey, hkey.put(), access);
}
/**
* \brief Creates a new HKEY to the specified path - see RegCreateKeyExW
* \param key An open or well-known registry key
* \param subKey The name of a subkey that this function opens or creates.
* Note: this cannot be null (see the above referenced API documentation)
* \param[out] hkey A reference to a wil::shared_hkey to receive the opened HKEY
* \param access The requested access desired for the opened key
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT create_shared_key_nothrow(HKEY key, PCWSTR subKey, ::wil::shared_hkey& hkey, ::wil::reg::key_access access = ::wil::reg::key_access::read) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.create_key(subKey, hkey.put(), access);
}
#endif // #define __WIL_WINREG_STL
/**
* \brief Queries for number of sub-keys
* \param key The HKEY to query for number of sub-keys
* \param[out] numSubKeys A pointer to a DWORD to receive the returned count
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT get_child_key_count_nothrow(HKEY key, _Out_ DWORD* numSubKeys) WI_NOEXCEPT
{
RETURN_IF_WIN32_ERROR(
RegQueryInfoKeyW(
key,
nullptr, // null class
nullptr, // null class character count,
nullptr, // null reserved
numSubKeys,
nullptr, // null max subkey length
nullptr, // null max class length
nullptr, // null value count
nullptr, // null max value name length
nullptr, // null max value length
nullptr, // null security descriptor
nullptr)); // null last write filetime
return S_OK;
}
inline HRESULT get_child_key_count_nothrow(HKEY key, _Out_ uint32_t* numSubKeys) WI_NOEXCEPT
{
DWORD subKeys{};
RETURN_IF_FAILED(::wil::reg::get_child_key_count_nothrow(key, &subKeys));
*numSubKeys = subKeys;
return S_OK;
}
/**
* \brief Queries for number of values
* \param key The HKEY to query for number of values
* \param[out] numSubValues A pointer to a DWORD to receive the returned count
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT get_child_value_count_nothrow(HKEY key, _Out_ DWORD* numSubValues) WI_NOEXCEPT
{
RETURN_IF_WIN32_ERROR(
RegQueryInfoKeyW(
key,
nullptr, // null class
nullptr, // null class char count,
nullptr, // null reserved
nullptr, // null subkey count
nullptr, // null max subkey length
nullptr, // null max class length
numSubValues,
nullptr, // null max value name length
nullptr, // null max value length
nullptr, // null security descriptor
nullptr)); // null last write filetime
return S_OK;
}
inline HRESULT get_child_value_count_nothrow(HKEY key, _Out_ uint32_t* numSubValues) WI_NOEXCEPT
{
DWORD subValues{};
RETURN_IF_FAILED(::wil::reg::get_child_value_count_nothrow(key, &subValues));
*numSubValues = subValues;
return S_OK;
}
/**
* \brief Queries for the filetime when the registry key was last written
* \param key The HKEY to query for number of values
* \param[out] lastModified A pointer to a FILETIME to receive the last write time
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline HRESULT get_last_write_filetime_nothrow(HKEY key, _Out_ FILETIME* lastModified) WI_NOEXCEPT
{
RETURN_IF_WIN32_ERROR(
RegQueryInfoKeyW(
key,
nullptr, // null class
nullptr, // null class char count,
nullptr, // null reserved
nullptr, // null subkey count
nullptr, // null max subkey length
nullptr, // null max class length
nullptr, // null value count
nullptr, // null max value name length
nullptr, // null max value length
nullptr, // null security descriptor
lastModified));
return S_OK;
}
#if defined(WIL_ENABLE_EXCEPTIONS)
/**
* \brief Queries for number of sub-keys
* \param key The HKEY to query for number of sub-keys
* \return The queried number of sub-keys if succeeded
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline uint32_t get_child_key_count(HKEY key)
{
uint32_t numSubKeys{};
THROW_IF_FAILED(::wil::reg::get_child_key_count_nothrow(key, &numSubKeys));
return numSubKeys;
}
/**
* \brief Queries for number of values
* \param key The HKEY to query for number of values
* \return The queried number of value if succeeded
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline uint32_t get_child_value_count(HKEY key)
{
uint32_t numSubValues{};
THROW_IF_FAILED(::wil::reg::get_child_value_count_nothrow(key, &numSubValues));
return numSubValues;
}
/**
* \brief Queries for the filetime when the registry key was last written
* \param key The HKEY to query for number of values
* \return The queried filetime if succeeded
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline FILETIME get_last_write_filetime(HKEY key)
{
FILETIME lastModified{};
THROW_IF_FAILED(::wil::reg::get_last_write_filetime_nothrow(key, &lastModified));
return lastModified;
}
#endif // #if defined(WIL_ENABLE_EXCEPTIONS)
#if defined(WIL_ENABLE_EXCEPTIONS)
//
// template <typename T>
// void set_value(...)
//
// - Writes a value to a specified key and subkey, deducing the type from the given data
// - Throws a std::exception on failure (including wil::ResultException)
//
// Examples of usage (the template type does not need to be explicitly specified)
// wil::reg::set_value(key, L"subkey", L"dword_value_name", 0); // writes a REG_DWORD
// wil::reg::set_value(key, L"subkey", L"qword_value_name", 0ull); // writes a REG_QWORD
// wil::reg::set_value(key, L"subkey", L"string_value_name", L"hello"); // writes a REG_SZ
//
// A subkey is not required if the key is opened where this should write the value:
// wil::reg::set_value(key, L"dword_value_name", 0); // writes a REG_DWORD
// wil::reg::set_value(key, L"qword_value_name", 0ull); // writes a REG_QWORD
// wil::reg::set_value(key, L"string_value_name", L"hello"); // writes a REG_SZ
//
// Example usage writing a vector of wstrings to a REG_MULTI_SZ
// std::vector<std::wstring> data { L"string1", L"string2", L"string3" };
// wil::reg::set_value(key, L"multi_string_value_name", data);
// wil::reg::set_value(key, L"multi_string_value_name", data);
//
// Example of usage writing directly to a registry value from a raw byte vector
// - notice the registry type is required, not implied
// std::vector<BYTE> data { 0x00, 0xff, 0xee, 0xdd, 0xcc };
// wil::reg::set_value_binary(key, L"binary_value_name", REG_BINARY, data);
// wil::reg::set_value_binary(key, L"binary_value_name", REG_BINARY, data);
//
/**
* \brief Writes a value to a specified key and subkey, deducing the type from the given data.
* \tparam T The type of the data being set (the registry value type is deduced from T).
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The data (of type T) to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
template <typename T>
void set_value(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, const T& data)
{
const reg_view_details::reg_view regview{ key };
regview.set_value(subkey, value_name, data);
}
/**
* \brief Writes a value under a specified key, the registry type based off the templated type passed as data
* \tparam T The type of the data being set (the registry value type is deduced from T).
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The data (of type T) to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
template <typename T>
void set_value(HKEY key, _In_opt_ PCWSTR value_name, const T& data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a null-terminated string value under a specified key
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data)
{
const reg_view_details::reg_view regview{ key };
regview.set_value(subkey, value_name, data);
}
/**
* \brief Writes a null-terminated string value under a specified key
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_DWORD value from a uint32_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 32-bit value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_dword(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint32_t data)
{
::wil::reg::set_value(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_DWORD value from a uint32_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 32-bit value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_dword(HKEY key, _In_opt_ PCWSTR value_name, uint32_t data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_QWORD value from a uint64_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 64-bit value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_qword(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint64_t data)
{
::wil::reg::set_value(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_QWORD value from a uint64_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 64-bit value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_qword(HKEY key, _In_opt_ PCWSTR value_name, uint64_t data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_string(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data)
{
::wil::reg::set_value(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_string(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_EXPAND_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated, unexpanded string value to write to the specified registry value. For example, `%PATH%`.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_expanded_string(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data)
{
const reg_view_details::reg_view regview{ key };
regview.set_value(subkey, value_name, data, REG_EXPAND_SZ);
}
/**
* \brief Writes a REG_EXPAND_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated, unexpanded string value to write to the specified registry value. For example, `%PATH%`.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_expanded_string(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data)
{
::wil::reg::set_value_expanded_string(key, nullptr, value_name, data);
}
#if defined(_VECTOR_) && defined(_STRING_)
/**
* \brief The generic set_value template function to write a REG_MULTI_SZ value from a std::vector<std::wstring>
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data A std::vector<std::wstring> to write to the specified registry value.
* Each string will be marshalled to a contiguous null-terminator-delimited multi-sz string
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, const ::std::vector<::std::wstring>& data)
{
const auto multiStringWcharVector(reg_view_details::get_multistring_from_wstrings(::std::begin(data), ::std::end(data)));
const reg_view_details::reg_view regview{ key };
regview.set_value(subkey, value_name, multiStringWcharVector, REG_MULTI_SZ);
}
/**
* \brief The generic set_value template function to write a REG_MULTI_SZ value from a std::vector<std::wstring>
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data A std::vector<std::wstring> to write to the specified registry value.
* Each string will be marshalled to a contiguous null-terminator-delimited multi-sz string.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value(HKEY key, _In_opt_ PCWSTR value_name, const ::std::vector<::std::wstring>& data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_MULTI_SZ value from a std::vector<std::wstring>
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data A std::vector<std::wstring> to write to the specified registry value.
* Each string will be marshalled to a contiguous null-terminator-delimited multi-sz string
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_multistring(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, const ::std::vector<::std::wstring>& data)
{
::wil::reg::set_value(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_MULTI_SZ value from a std::vector<std::wstring>
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data A std::vector<std::wstring> to write to the specified registry value.
* Each string will be marshalled to a contiguous null-terminator-delimited multi-sz string.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_multistring(HKEY key, _In_opt_ PCWSTR value_name, const ::std::vector<::std::wstring>& data)
{
::wil::reg::set_value(key, nullptr, value_name, data);
}
#endif // #if defined(_VECTOR_) && defined(_STRING_)
#if defined(_VECTOR_)
/**
* \brief Writes a registry value of the specified type from a std::vector<uint8_t>/std::vector<BYTE>
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param type The registry type for the specified registry value - see RegSetKeyValueW
* \param data A std::vector<uint8_t>/std::vector<BYTE> to write to the specified registry value.
* The vector contents will be directly marshalled to the specified value.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_binary(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint32_t type, const ::std::vector<uint8_t>& data)
{
const reg_view_details::reg_view regview{ key };
regview.set_value(subkey, value_name, data, type);
}
/**
* \brief Writes a registry value of the specified type from a std::vector<uint8_t>/std::vector<BYTE>
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param type The registry type for the specified registry value - see RegSetKeyValueW
* \param data A std::vector<uint8_t>/std::vector<BYTE> to write to the specified registry value.
* The vector contents will be directly marshalled to the specified value.
* \exception std::exception (including wil::ResultException) will be thrown on all failures
*/
inline void set_value_binary(HKEY key, _In_opt_ PCWSTR value_name, uint32_t type, const ::std::vector<uint8_t>& data)
{
::wil::reg::set_value_binary(key, nullptr, value_name, type, data);
}
#endif // #if defined(_VECTOR_)
#endif // #if defined(WIL_ENABLE_EXCEPTIONS)
//
// template <typename T>
// HRESULT set_value_nothrow(...)
//
// - Writes a value under a specified key
// - The type of registry value is determined by the template type T of data given
// - Returns an HRESULT error code indicating success or failure (does not throw C++ exceptions)
//
// Examples of usage (the template type does not need to be explicitly specified)
// hr = wil::reg::set_value_nothrow(key, L"subkey", L"dword_value_name", 0); // writes a REG_DWORD
// hr = wil::reg::set_value_nothrow(key, L"subkey", L"qword_value_name", 0ull); // writes a REG_QWORD
// hr = wil::reg::set_value_nothrow(key, L"subkey", L"string_value_name", L"hello"); // writes a REG_SZ
//
// A subkey is not required if the key is opened where this should write the value:
// hr = wil::reg::set_value_nothrow(key, L"dword_value_name", 0); // writes a REG_DWORD
// hr = wil::reg::set_value_nothrow(key, L"qword_value_name", 0ull); // writes a REG_QWORD
// hr = wil::reg::set_value_nothrow(key, L"string_value_name", L"hello"); // writes a REG_SZ
//
// Example of usage writing a REG_MULTI_SZ
// std::vector<std::wstring> multisz_data { L"string1", L"string2", L"string3" };
// hr = wil::reg::set_value_nothrow(key, L"multi_string_value_name", multisz_data);
//
// Values can be written directly from a vector of bytes - the registry type must be specified; e.g.:
// std::vector<BYTE> data { 0x00, 0xff, 0xee, 0xdd, 0xcc };
// hr = wil::reg::set_value_binary_nothrow(key, L"binary_value_name", REG_BINARY, data);
//
/**
* \brief Writes a value to a specified key and subkey, deducing the type from the given data.
* \tparam T The type of the data being set (the registry value type is deduced from T).
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The data (of type T) to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename T>
HRESULT set_value_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, const T& data) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.set_value(subkey, value_name, data);
}
/**
* \brief Writes a value under a specified key, the registry type based off the templated type passed as data
* \tparam T The type of the data being set (the registry value type is deduced from T).
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The data (of type T) to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename T>
HRESULT set_value_nothrow(HKEY key, _In_opt_ PCWSTR value_name, const T& data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, nullptr, value_name, data);
}
/**
* \brief Writes a null-terminated string value under a specified key
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.set_value(subkey, value_name, data);
}
/**
* \brief Writes a null-terminated string value under a specified key
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_nothrow(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_DWORD value from a uint32_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 32-bit value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_dword_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint32_t data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_DWORD value from a uint32_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 32-bit value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_dword_nothrow(HKEY key, _In_opt_ PCWSTR value_name, uint32_t data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_QWORD value from a uint64_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 64-bit value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_qword_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint64_t data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_QWORD value from a uint64_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The 64-bit value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_qword_nothrow(HKEY key, _In_opt_ PCWSTR value_name, uint64_t data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_string_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, subkey, value_name, data);
}
/**
* \brief Writes a REG_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_string_nothrow(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
return ::wil::reg::set_value_nothrow(key, nullptr, value_name, data);
}
/**
* \brief Writes a REG_EXPAND_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_expanded_string_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
return regview.set_value(subkey, value_name, data, REG_EXPAND_SZ);
}
/**
* \brief Writes a REG_EXPAND_SZ value from a null-terminated string
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param data The null-terminated string value to write to the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_expanded_string_nothrow(HKEY key, _In_opt_ PCWSTR value_name, PCWSTR data) WI_NOEXCEPT
{
return ::wil::reg::set_value_expanded_string_nothrow(key, nullptr, value_name, data);
}
#if defined(__WIL_OBJBASE_H_)
/**
* \brief Writes raw bytes into a registry value under a specified key of the specified type
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param type The registry type for the specified registry value to write to - see RegSetValue
* \param value A ::wil::unique_cotaskmem_array_ptr<BYTE> holding the bytes to write into the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_binary_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, uint32_t type, const ::wil::unique_cotaskmem_array_ptr<uint8_t>& value) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
RETURN_IF_FAILED(regview.set_value<::wil::unique_cotaskmem_array_ptr<uint8_t>>(subkey, value_name, value, type));
return S_OK;
}
/**
* \brief Writes raw bytes into a registry value under a specified key of the specified type
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to write to the unnamed default registry value.
* \param type The registry type for the specified registry value to write to - see RegSetValue
* \param value A ::wil::unique_cotaskmem_array_ptr<BYTE> holding the bytes to write into the specified registry value
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
inline HRESULT set_value_binary_nothrow(HKEY key, _In_opt_ PCWSTR value_name, uint32_t type, const ::wil::unique_cotaskmem_array_ptr<uint8_t>& value) WI_NOEXCEPT
{
return ::wil::reg::set_value_binary_nothrow(key, nullptr, value_name, type, value);
}
#endif
#if defined(WIL_ENABLE_EXCEPTIONS)
//
// template <typename T>
// T get_value(...)
//
// - Reads a value under a specified key.
// - Requires a type T to be specified.
// - Throws a std::exception on failure (including wil::ResultException), including registry value not found.
// If you don't want an exception when the value does not exist, use try_get_value(...)
//
// Examples of usage (ensure the code handles a possible std::exception that will be thrown on all errors)
// uint32_t dword_value = wil::reg::get_value<uint32_t>(key, L"subkey", L"dword_value_name");
// uint64_t qword_value = wil::reg::get_value<uint64_t>(key, L"subkey", L"qword_value_name);
// std::wstring string_value = wil::reg::get_value<std::wstring>(key, L"subkey", L"string_value_name");
//
// A subkey is not required if the key is opened where this should write the value:
// uint32_t dword_value = wil::reg::get_value<uint32_t>(key, L"dword_value_name");
// uint64_t qword_value = wil::reg::get_value<uint64_t>(key, L"qword_value_name);
// std::wstring string_value = wil::reg::get_value<std::wstring>(key, L"string_value_name");
//
// The template type does not need to be specified if using functions written for a targeted type
// uint32_t dword_value = wil::reg::get_value_dword(key, L"dword_value_name");
// uint64_t qword_value = wil::reg::get_value_qword(key, L"qword_value_name");
// std::wstring string_value = wil::reg::get_value_string(key, L"string_value_name");
//
// Values with REG_EXPAND_SZ can be read into each of the string types; e.g.:
// std::wstring expaned_string_value = wil::reg::get_value_expanded_string(key, L"string_value_name_with_environment_variables");
//
// Values can be read directly into a vector of bytes - the registry type must be specified; e.g.:
// std::vector<BYTE> data = wil::reg::get_value_binary(key, L"binary_value_name", REG_BINARY);
//
// Multi-string values can be read into a vector<wstring>; e.g.:
// std::vector<std::wstring> multi_string_value = wil::reg::get_value_multistring(key, L"multi_string_value_name");
// for (const auto& sub_string_value : multi_string_value)
// {
// // can read each string parsed from the multi-string
// PCWSTR string_value = sub_string_value.c_str();
// }
//
// Reading REG_SZ and REG_EXPAND_SZ types are done through the below templated get_value_string and get_value_expanded_string functions
// Where the template type is the type to receive the string value
// The default template type is std::wstring, availble if the caller has included the STL <string> header
//
// Reading a bstr can be stored in a wil::shared_bstr or wil::unique_bstr - wil::shared_bstr has a c'tor taking a wil::unique_bstr
// wil::unique_bstr unique_value { wil::reg::get_value_string<::wil::unique_bstr>(key, L"string_value_name") };
// wil::shared_bstr shared_value { wil::reg::get_value_string<::wil::shared_bstr>(key, L"string_value_name") };
//
// Reading a cotaskmem string can be stored in a wil::unique_cotaskmem_string or wil::shared_cotaskmem_string
// wil::unique_cotaskmem_string unique_value { wil::reg::get_value_string<wil::unique_cotaskmem_string>(key, L"string_value_name") };
// wil::shared_cotaskmem_string shared_value { wil::reg::get_value_string<wil::shared_cotaskmem_string>(key, L"string_value_name") };
//
// Blocking get_value_string template types that are not already specialized - this gives a much friendlier compiler error message
template <typename T>
T get_value_string(HKEY /*key*/, _In_opt_ PCWSTR /*subkey*/, _In_opt_ PCWSTR /*value_name*/)
{
static_assert(sizeof(T) != sizeof(T), "Unsupported type for get_value_string");
}
template <typename T>
T get_value_string(HKEY /*key*/, _In_opt_ PCWSTR /*value_name*/)
{
static_assert(sizeof(T) != sizeof(T), "Unsupported type for get_value_string");
}
template <typename T>
T get_value_expanded_string(HKEY /*key*/, _In_opt_ PCWSTR /*subkey*/, _In_opt_ PCWSTR /*value_name*/)
{
static_assert(sizeof(T) != sizeof(T), "Unsupported type for get_value_expanded_string");
}
template <typename T>
T get_value_expanded_string(HKEY /*key*/, _In_opt_ PCWSTR /*value_name*/)
{
static_assert(sizeof(T) != sizeof(T), "Unsupported type for get_value_expanded_string");
}
/**
* \brief Reads a value from a specified key and subkey, deducing registry type from the type parameter T.
* \tparam T The type to read (the registry value type is deduced from T)
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The value read from the registry value of the template type T
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/
template <typename T>
T get_value(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name)
{
T return_value{};
const reg_view_details::reg_view regview{ key };
regview.get_value<T>(subkey, value_name, return_value);
return return_value;
}
/**
* \brief Reads a value under a specified key, deducing registry type from the type parameter T.
* \tparam T The type to read (the registry value type is deduced from T)
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The value read from the registry value of the template type T
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/
template <typename T>
T get_value(HKEY key, _In_opt_ PCWSTR value_name)
{
return ::wil::reg::get_value<T>(key, nullptr, value_name);
}
/**
* \brief Reads a REG_DWORD value, returning a uint32_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The uint32_t value read from the registry
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/
inline uint32_t get_value_dword(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name)
{
return ::wil::reg::get_value<uint32_t>(key, subkey, value_name);
}
/**
* \brief Reads a REG_DWORD value, returning a uint32_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The uint32_t value read from the registry
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/
inline uint32_t get_value_dword(HKEY key, _In_opt_ PCWSTR value_name)
{
return ::wil::reg::get_value<uint32_t>(key, nullptr, value_name);
}
/**
* \brief Reads a REG_QWORD value, returning a uint64_t
* \param key An open or well-known registry key
* \param subkey The name of the subkey to append to `key`.
* If `nullptr`, then `key` is used without modification.
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The uint64_t value read from the registry
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/
inline uint64_t get_value_qword(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name)
{
return ::wil::reg::get_value<uint64_t>(key, subkey, value_name);
}
/**
* \brief Reads a REG_QWORD value, returning a uint64_t
* \param key An open or well-known registry key
* \param value_name The name of the registry value whose data is to be updated.
* Can be nullptr to read from the unnamed default registry value.
* \return The uint64_t value read from the registry
* \exception std::exception (including wil::ResultException) will be thrown on all failures, including value not found
*/