diff options
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/regutil.cpp')
-rw-r--r-- | src/libs/dutil/WixToolset.DUtil/regutil.cpp | 180 |
1 files changed, 34 insertions, 146 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/regutil.cpp b/src/libs/dutil/WixToolset.DUtil/regutil.cpp index 458d8586..57093f97 100644 --- a/src/libs/dutil/WixToolset.DUtil/regutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/regutil.cpp | |||
@@ -37,14 +37,9 @@ static HRESULT WriteStringToRegistry( | |||
37 | __in_z_opt LPCWSTR wzName, | 37 | __in_z_opt LPCWSTR wzName, |
38 | __in_z_opt LPCWSTR wzValue, | 38 | __in_z_opt LPCWSTR wzValue, |
39 | __in DWORD dwType | 39 | __in DWORD dwType |
40 | ); | 40 | ); |
41 | 41 | ||
42 | /******************************************************************** | 42 | DAPI_(HRESULT) RegInitialize() |
43 | RegInitialize - initializes regutil | ||
44 | |||
45 | *********************************************************************/ | ||
46 | extern "C" HRESULT DAPI RegInitialize( | ||
47 | ) | ||
48 | { | 43 | { |
49 | HRESULT hr = S_OK; | 44 | HRESULT hr = S_OK; |
50 | 45 | ||
@@ -66,12 +61,7 @@ LExit: | |||
66 | } | 61 | } |
67 | 62 | ||
68 | 63 | ||
69 | /******************************************************************** | 64 | DAPI_(void) RegUninitialize() |
70 | RegUninitialize - uninitializes regutil | ||
71 | |||
72 | *********************************************************************/ | ||
73 | extern "C" void DAPI RegUninitialize( | ||
74 | ) | ||
75 | { | 65 | { |
76 | if (vhAdvApi32Dll) | 66 | if (vhAdvApi32Dll) |
77 | { | 67 | { |
@@ -85,12 +75,7 @@ extern "C" void DAPI RegUninitialize( | |||
85 | } | 75 | } |
86 | 76 | ||
87 | 77 | ||
88 | /******************************************************************** | 78 | DAPI_(void) RegFunctionOverride( |
89 | RegFunctionOverride - overrides the registry functions. Typically used | ||
90 | for unit testing. | ||
91 | |||
92 | *********************************************************************/ | ||
93 | extern "C" void DAPI RegFunctionOverride( | ||
94 | __in_opt PFN_REGCREATEKEYEXW pfnRegCreateKeyExW, | 79 | __in_opt PFN_REGCREATEKEYEXW pfnRegCreateKeyExW, |
95 | __in_opt PFN_REGOPENKEYEXW pfnRegOpenKeyExW, | 80 | __in_opt PFN_REGOPENKEYEXW pfnRegOpenKeyExW, |
96 | __in_opt PFN_REGDELETEKEYEXW pfnRegDeleteKeyExW, | 81 | __in_opt PFN_REGDELETEKEYEXW pfnRegDeleteKeyExW, |
@@ -114,11 +99,7 @@ extern "C" void DAPI RegFunctionOverride( | |||
114 | } | 99 | } |
115 | 100 | ||
116 | 101 | ||
117 | /******************************************************************** | 102 | DAPI_(HRESULT) RegCreate( |
118 | RegCreate - creates a registry key. | ||
119 | |||
120 | *********************************************************************/ | ||
121 | extern "C" HRESULT DAPI RegCreate( | ||
122 | __in HKEY hkRoot, | 103 | __in HKEY hkRoot, |
123 | __in_z LPCWSTR wzSubKey, | 104 | __in_z LPCWSTR wzSubKey, |
124 | __in DWORD dwAccess, | 105 | __in DWORD dwAccess, |
@@ -136,11 +117,7 @@ LExit: | |||
136 | } | 117 | } |
137 | 118 | ||
138 | 119 | ||
139 | /******************************************************************** | 120 | DAPI_(HRESULT) RegCreateEx( |
140 | RegCreate - creates a registry key with extra options. | ||
141 | |||
142 | *********************************************************************/ | ||
143 | HRESULT DAPI RegCreateEx( | ||
144 | __in HKEY hkRoot, | 121 | __in HKEY hkRoot, |
145 | __in_z LPCWSTR wzSubKey, | 122 | __in_z LPCWSTR wzSubKey, |
146 | __in DWORD dwAccess, | 123 | __in DWORD dwAccess, |
@@ -167,11 +144,7 @@ LExit: | |||
167 | } | 144 | } |
168 | 145 | ||
169 | 146 | ||
170 | /******************************************************************** | 147 | DAPI_(HRESULT) RegOpen( |
171 | RegOpen - opens a registry key. | ||
172 | |||
173 | *********************************************************************/ | ||
174 | extern "C" HRESULT DAPI RegOpen( | ||
175 | __in HKEY hkRoot, | 148 | __in HKEY hkRoot, |
176 | __in_z LPCWSTR wzSubKey, | 149 | __in_z LPCWSTR wzSubKey, |
177 | __in DWORD dwAccess, | 150 | __in DWORD dwAccess, |
@@ -193,11 +166,7 @@ LExit: | |||
193 | } | 166 | } |
194 | 167 | ||
195 | 168 | ||
196 | /******************************************************************** | 169 | DAPI_(HRESULT) RegDelete( |
197 | RegDelete - deletes a registry key (and optionally it's whole tree). | ||
198 | |||
199 | *********************************************************************/ | ||
200 | extern "C" HRESULT DAPI RegDelete( | ||
201 | __in HKEY hkRoot, | 170 | __in HKEY hkRoot, |
202 | __in_z LPCWSTR wzSubKey, | 171 | __in_z LPCWSTR wzSubKey, |
203 | __in REG_KEY_BITNESS kbKeyBitness, | 172 | __in REG_KEY_BITNESS kbKeyBitness, |
@@ -282,11 +251,7 @@ LExit: | |||
282 | } | 251 | } |
283 | 252 | ||
284 | 253 | ||
285 | /******************************************************************** | 254 | DAPI_(HRESULT) RegKeyEnum( |
286 | RegKeyEnum - enumerates child registry keys. | ||
287 | |||
288 | *********************************************************************/ | ||
289 | extern "C" HRESULT DAPI RegKeyEnum( | ||
290 | __in HKEY hk, | 255 | __in HKEY hk, |
291 | __in DWORD dwIndex, | 256 | __in DWORD dwIndex, |
292 | __deref_out_z LPWSTR* psczKey | 257 | __deref_out_z LPWSTR* psczKey |
@@ -342,11 +307,7 @@ LExit: | |||
342 | } | 307 | } |
343 | 308 | ||
344 | 309 | ||
345 | /******************************************************************** | 310 | DAPI_(HRESULT) RegValueEnum( |
346 | RegValueEnum - enumerates registry values. | ||
347 | |||
348 | *********************************************************************/ | ||
349 | HRESULT DAPI RegValueEnum( | ||
350 | __in HKEY hk, | 311 | __in HKEY hk, |
351 | __in DWORD dwIndex, | 312 | __in DWORD dwIndex, |
352 | __deref_out_z LPWSTR* psczName, | 313 | __deref_out_z LPWSTR* psczName, |
@@ -377,10 +338,7 @@ LExit: | |||
377 | return hr; | 338 | return hr; |
378 | } | 339 | } |
379 | 340 | ||
380 | /******************************************************************** | 341 | DAPI_(HRESULT) RegGetType( |
381 | RegGetType - reads a registry key value type. | ||
382 | *********************************************************************/ | ||
383 | HRESULT DAPI RegGetType( | ||
384 | __in HKEY hk, | 342 | __in HKEY hk, |
385 | __in_z_opt LPCWSTR wzName, | 343 | __in_z_opt LPCWSTR wzName, |
386 | __out DWORD *pdwType | 344 | __out DWORD *pdwType |
@@ -400,11 +358,7 @@ LExit: | |||
400 | return hr; | 358 | return hr; |
401 | } | 359 | } |
402 | 360 | ||
403 | /******************************************************************** | 361 | DAPI_(HRESULT) RegReadBinary( |
404 | RegReadBinary - reads a registry key binary value. | ||
405 | NOTE: caller is responsible for freeing *ppbBuffer | ||
406 | *********************************************************************/ | ||
407 | HRESULT DAPI RegReadBinary( | ||
408 | __in HKEY hk, | 362 | __in HKEY hk, |
409 | __in_z_opt LPCWSTR wzName, | 363 | __in_z_opt LPCWSTR wzName, |
410 | __deref_out_bcount_opt(*pcbBuffer) BYTE** ppbBuffer, | 364 | __deref_out_bcount_opt(*pcbBuffer) BYTE** ppbBuffer, |
@@ -453,11 +407,7 @@ LExit: | |||
453 | } | 407 | } |
454 | 408 | ||
455 | 409 | ||
456 | /******************************************************************** | 410 | DAPI_(HRESULT) RegReadString( |
457 | RegReadString - reads a registry key value as a string. | ||
458 | |||
459 | *********************************************************************/ | ||
460 | extern "C" HRESULT DAPI RegReadString( | ||
461 | __in HKEY hk, | 411 | __in HKEY hk, |
462 | __in_z_opt LPCWSTR wzName, | 412 | __in_z_opt LPCWSTR wzName, |
463 | __deref_out_z LPWSTR* psczValue | 413 | __deref_out_z LPWSTR* psczValue |
@@ -530,11 +480,7 @@ LExit: | |||
530 | } | 480 | } |
531 | 481 | ||
532 | 482 | ||
533 | /******************************************************************** | 483 | DAPI_(HRESULT) RegReadStringArray( |
534 | RegReadStringArray - reads a registry key value REG_MULTI_SZ value as a string array. | ||
535 | |||
536 | *********************************************************************/ | ||
537 | HRESULT DAPI RegReadStringArray( | ||
538 | __in HKEY hk, | 484 | __in HKEY hk, |
539 | __in_z_opt LPCWSTR wzName, | 485 | __in_z_opt LPCWSTR wzName, |
540 | __deref_out_ecount_opt(*pcStrings) LPWSTR** prgsczStrings, | 486 | __deref_out_ecount_opt(*pcStrings) LPWSTR** prgsczStrings, |
@@ -626,11 +572,7 @@ LExit: | |||
626 | } | 572 | } |
627 | 573 | ||
628 | 574 | ||
629 | /******************************************************************** | 575 | DAPI_(HRESULT) RegReadVersion( |
630 | RegReadVersion - reads a registry key value as a version. | ||
631 | |||
632 | *********************************************************************/ | ||
633 | extern "C" HRESULT DAPI RegReadVersion( | ||
634 | __in HKEY hk, | 576 | __in HKEY hk, |
635 | __in_z_opt LPCWSTR wzName, | 577 | __in_z_opt LPCWSTR wzName, |
636 | __out DWORD64* pdw64Version | 578 | __out DWORD64* pdw64Version |
@@ -672,13 +614,10 @@ LExit: | |||
672 | return hr; | 614 | return hr; |
673 | } | 615 | } |
674 | 616 | ||
675 | /******************************************************************** | 617 | DAPI_(HRESULT) RegReadNone( |
676 | RegReadNone - reads a NONE registry key value. | ||
677 | |||
678 | *********************************************************************/ | ||
679 | extern "C" HRESULT DAPI RegReadNone( | ||
680 | __in HKEY hk, | 618 | __in HKEY hk, |
681 | __in_z_opt LPCWSTR wzName) | 619 | __in_z_opt LPCWSTR wzName |
620 | ) | ||
682 | { | 621 | { |
683 | HRESULT hr = S_OK; | 622 | HRESULT hr = S_OK; |
684 | DWORD er = ERROR_SUCCESS; | 623 | DWORD er = ERROR_SUCCESS; |
@@ -694,18 +633,14 @@ extern "C" HRESULT DAPI RegReadNone( | |||
694 | if (REG_NONE != dwType) | 633 | if (REG_NONE != dwType) |
695 | { | 634 | { |
696 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATATYPE); | 635 | hr = HRESULT_FROM_WIN32(ERROR_INVALID_DATATYPE); |
697 | RegExitOnRootFailure(hr, "Error reading version registry value due to unexpected data type: %u", dwType); | 636 | RegExitOnRootFailure(hr, "Error reading none registry value due to unexpected data type: %u", dwType); |
698 | } | 637 | } |
699 | 638 | ||
700 | LExit: | 639 | LExit: |
701 | return hr; | 640 | return hr; |
702 | } | 641 | } |
703 | 642 | ||
704 | /******************************************************************** | 643 | DAPI_(HRESULT) RegReadNumber( |
705 | RegReadNumber - reads a DWORD registry key value as a number. | ||
706 | |||
707 | *********************************************************************/ | ||
708 | extern "C" HRESULT DAPI RegReadNumber( | ||
709 | __in HKEY hk, | 644 | __in HKEY hk, |
710 | __in_z_opt LPCWSTR wzName, | 645 | __in_z_opt LPCWSTR wzName, |
711 | __out DWORD* pdwValue | 646 | __out DWORD* pdwValue |
@@ -734,11 +669,7 @@ LExit: | |||
734 | } | 669 | } |
735 | 670 | ||
736 | 671 | ||
737 | /******************************************************************** | 672 | DAPI_(HRESULT) RegReadQword( |
738 | RegReadQword - reads a QWORD registry key value as a number. | ||
739 | |||
740 | *********************************************************************/ | ||
741 | extern "C" HRESULT DAPI RegReadQword( | ||
742 | __in HKEY hk, | 673 | __in HKEY hk, |
743 | __in_z_opt LPCWSTR wzName, | 674 | __in_z_opt LPCWSTR wzName, |
744 | __out DWORD64* pqwValue | 675 | __out DWORD64* pqwValue |
@@ -767,11 +698,7 @@ LExit: | |||
767 | } | 698 | } |
768 | 699 | ||
769 | 700 | ||
770 | /******************************************************************** | 701 | DAPI_(HRESULT) RegWriteBinary( |
771 | RegWriteBinary - writes a registry key value as a binary. | ||
772 | |||
773 | *********************************************************************/ | ||
774 | HRESULT DAPI RegWriteBinary( | ||
775 | __in HKEY hk, | 702 | __in HKEY hk, |
776 | __in_z_opt LPCWSTR wzName, | 703 | __in_z_opt LPCWSTR wzName, |
777 | __in_bcount(cbBuffer) const BYTE *pbBuffer, | 704 | __in_bcount(cbBuffer) const BYTE *pbBuffer, |
@@ -789,27 +716,17 @@ LExit: | |||
789 | } | 716 | } |
790 | 717 | ||
791 | 718 | ||
792 | /******************************************************************** | 719 | DAPI_(HRESULT) RegWriteExpandString( |
793 | RegWriteExpandString - writes a registry key value as an expand string. | ||
794 | |||
795 | Note: if wzValue is NULL the value will be removed. | ||
796 | *********************************************************************/ | ||
797 | extern "C" HRESULT DAPI RegWriteExpandString( | ||
798 | __in HKEY hk, | 720 | __in HKEY hk, |
799 | __in_z_opt LPCWSTR wzName, | 721 | __in_z_opt LPCWSTR wzName, |
800 | __in_z_opt LPCWSTR wzValue | 722 | __in_z_opt LPCWSTR wzValue |
801 | ) | 723 | ) |
802 | { | 724 | { |
803 | return WriteStringToRegistry(hk, wzName, wzValue, REG_EXPAND_SZ); | 725 | return WriteStringToRegistry(hk, wzName, wzValue, REG_EXPAND_SZ); |
804 | } | 726 | } |
805 | 727 | ||
806 | 728 | ||
807 | /******************************************************************** | 729 | DAPI_(HRESULT) RegWriteString( |
808 | RegWriteString - writes a registry key value as a string. | ||
809 | |||
810 | Note: if wzValue is NULL the value will be removed. | ||
811 | *********************************************************************/ | ||
812 | extern "C" HRESULT DAPI RegWriteString( | ||
813 | __in HKEY hk, | 730 | __in HKEY hk, |
814 | __in_z_opt LPCWSTR wzName, | 731 | __in_z_opt LPCWSTR wzName, |
815 | __in_z_opt LPCWSTR wzValue | 732 | __in_z_opt LPCWSTR wzValue |
@@ -819,11 +736,7 @@ extern "C" HRESULT DAPI RegWriteString( | |||
819 | } | 736 | } |
820 | 737 | ||
821 | 738 | ||
822 | /******************************************************************** | 739 | DAPIV_(HRESULT) RegWriteStringFormatted( |
823 | RegWriteStringFormatted - writes a registry key value as a formatted string. | ||
824 | |||
825 | *********************************************************************/ | ||
826 | extern "C" HRESULT DAPI RegWriteStringFormatted( | ||
827 | __in HKEY hk, | 740 | __in HKEY hk, |
828 | __in_z_opt LPCWSTR wzName, | 741 | __in_z_opt LPCWSTR wzName, |
829 | __in __format_string LPCWSTR szFormat, | 742 | __in __format_string LPCWSTR szFormat, |
@@ -848,11 +761,7 @@ LExit: | |||
848 | } | 761 | } |
849 | 762 | ||
850 | 763 | ||
851 | /******************************************************************** | 764 | DAPI_(HRESULT) RegWriteStringArray( |
852 | RegWriteStringArray - writes an array of strings as a REG_MULTI_SZ value | ||
853 | |||
854 | *********************************************************************/ | ||
855 | HRESULT DAPI RegWriteStringArray( | ||
856 | __in HKEY hk, | 765 | __in HKEY hk, |
857 | __in_z_opt LPCWSTR wzName, | 766 | __in_z_opt LPCWSTR wzName, |
858 | __in_ecount(cValues) LPWSTR *rgwzValues, | 767 | __in_ecount(cValues) LPWSTR *rgwzValues, |
@@ -913,14 +822,10 @@ LExit: | |||
913 | return hr; | 822 | return hr; |
914 | } | 823 | } |
915 | 824 | ||
916 | /******************************************************************** | 825 | DAPI_(HRESULT) RegWriteNone( |
917 | RegWriteNone - writes a registry key value as none. | ||
918 | |||
919 | *********************************************************************/ | ||
920 | extern "C" HRESULT DAPI RegWriteNone( | ||
921 | __in HKEY hk, | 826 | __in HKEY hk, |
922 | __in_z_opt LPCWSTR wzName | 827 | __in_z_opt LPCWSTR wzName |
923 | ) | 828 | ) |
924 | { | 829 | { |
925 | HRESULT hr = S_OK; | 830 | HRESULT hr = S_OK; |
926 | DWORD er = ERROR_SUCCESS; | 831 | DWORD er = ERROR_SUCCESS; |
@@ -932,11 +837,7 @@ LExit: | |||
932 | return hr; | 837 | return hr; |
933 | } | 838 | } |
934 | 839 | ||
935 | /******************************************************************** | 840 | DAPI_(HRESULT) RegWriteNumber( |
936 | RegWriteNumber - writes a registry key value as a number. | ||
937 | |||
938 | *********************************************************************/ | ||
939 | extern "C" HRESULT DAPI RegWriteNumber( | ||
940 | __in HKEY hk, | 841 | __in HKEY hk, |
941 | __in_z_opt LPCWSTR wzName, | 842 | __in_z_opt LPCWSTR wzName, |
942 | __in DWORD dwValue | 843 | __in DWORD dwValue |
@@ -952,11 +853,7 @@ LExit: | |||
952 | return hr; | 853 | return hr; |
953 | } | 854 | } |
954 | 855 | ||
955 | /******************************************************************** | 856 | DAPI_(HRESULT) RegWriteQword( |
956 | RegWriteQword - writes a registry key value as a Qword. | ||
957 | |||
958 | *********************************************************************/ | ||
959 | extern "C" HRESULT DAPI RegWriteQword( | ||
960 | __in HKEY hk, | 857 | __in HKEY hk, |
961 | __in_z_opt LPCWSTR wzName, | 858 | __in_z_opt LPCWSTR wzName, |
962 | __in DWORD64 qwValue | 859 | __in DWORD64 qwValue |
@@ -972,11 +869,7 @@ LExit: | |||
972 | return hr; | 869 | return hr; |
973 | } | 870 | } |
974 | 871 | ||
975 | /******************************************************************** | 872 | DAPI_(HRESULT) RegQueryKey( |
976 | RegQueryKey - queries the key for the number of subkeys and values. | ||
977 | |||
978 | *********************************************************************/ | ||
979 | extern "C" HRESULT DAPI RegQueryKey( | ||
980 | __in HKEY hk, | 873 | __in HKEY hk, |
981 | __out_opt DWORD* pcSubKeys, | 874 | __out_opt DWORD* pcSubKeys, |
982 | __out_opt DWORD* pcValues | 875 | __out_opt DWORD* pcValues |
@@ -992,12 +885,7 @@ LExit: | |||
992 | return hr; | 885 | return hr; |
993 | } | 886 | } |
994 | 887 | ||
995 | /******************************************************************** | 888 | DAPI_(HRESULT) RegKeyReadNumber( |
996 | RegKeyReadNumber - reads a DWORD registry key value as a number from | ||
997 | a specified subkey. | ||
998 | |||
999 | *********************************************************************/ | ||
1000 | extern "C" HRESULT DAPI RegKeyReadNumber( | ||
1001 | __in HKEY hk, | 889 | __in HKEY hk, |
1002 | __in_z LPCWSTR wzSubKey, | 890 | __in_z LPCWSTR wzSubKey, |
1003 | __in_z_opt LPCWSTR wzName, | 891 | __in_z_opt LPCWSTR wzName, |
@@ -1025,7 +913,7 @@ RegValueExists - determines whether a named value exists in a | |||
1025 | specified subkey. | 913 | specified subkey. |
1026 | 914 | ||
1027 | *********************************************************************/ | 915 | *********************************************************************/ |
1028 | extern "C" BOOL DAPI RegValueExists( | 916 | DAPI_(BOOL) RegValueExists( |
1029 | __in HKEY hk, | 917 | __in HKEY hk, |
1030 | __in_z LPCWSTR wzSubKey, | 918 | __in_z LPCWSTR wzSubKey, |
1031 | __in_z_opt LPCWSTR wzName, | 919 | __in_z_opt LPCWSTR wzName, |