@@ -30,7 +30,7 @@ public static class PythonWinReg {
3030
3131 public static PythonType error = PythonExceptions . OSError ;
3232
33- #region Constants
33+ #region Constants
3434
3535 public static BigInteger HKEY_CLASSES_ROOT = 0x80000000L ;
3636 public static BigInteger HKEY_CURRENT_USER = 0x80000001L ;
@@ -69,6 +69,7 @@ public static class PythonWinReg {
6969 public const int REG_RESOURCE_LIST = 0X8 ;
7070 public const int REG_FULL_RESOURCE_DESCRIPTOR = 0X9 ;
7171 public const int REG_RESOURCE_REQUIREMENTS_LIST = 0XA ;
72+ public const int REG_QWORD = 0xB ;
7273
7374 public const int REG_NOTIFY_CHANGE_NAME = 0X1 ;
7475 public const int REG_NOTIFY_CHANGE_ATTRIBUTES = 0X2 ;
@@ -88,9 +89,9 @@ public static class PythonWinReg {
8889 public const int REG_LEGAL_OPTION = 0XF ;
8990 public const int REG_WHOLE_HIVE_VOLATILE = 0X1 ;
9091
91- #endregion
92+ #endregion
9293
93- #region Module Methods
94+ #region Module Methods
9495
9596 public static void CloseKey ( HKEYType key ) {
9697 key . Close ( ) ;
@@ -106,7 +107,7 @@ public static HKEYType CreateKey(object key, string sub_key) {
106107 //if key is a system key and no subkey is specified return that.
107108 if ( key is BigInteger && string . IsNullOrEmpty ( sub_key ) )
108109 return rootKey ;
109-
110+
110111 HKEYType subKey = new HKEYType ( rootKey . GetKey ( ) . CreateSubKey ( sub_key ) ) ;
111112 return subKey ;
112113 }
@@ -124,7 +125,7 @@ public static HKEYType CreateKeyEx(object key, string sub_key, int reserved = 0,
124125
125126 SafeRegistryHandle handle ;
126127 int disposition ;
127-
128+
128129 int result = RegCreateKeyEx (
129130 rootKey . GetKey ( ) . Handle ,
130131 sub_key ,
@@ -233,7 +234,7 @@ public static void DeleteKey(object key, string sub_key) {
233234 }
234235 }
235236
236- public static void DeleteKeyEx ( object key , string sub_key , int access = KEY_WOW64_64KEY , int reserved = 0 ) {
237+ public static void DeleteKeyEx ( object key , string sub_key , int access = KEY_WOW64_64KEY , int reserved = 0 ) {
237238 HKEYType rootKey = GetRootKey ( key ) ;
238239
239240 if ( key is BigInteger && string . IsNullOrEmpty ( sub_key ) )
@@ -365,10 +366,9 @@ private static void QueryValueExImpl(SafeRegistryHandle handle, string valueName
365366
366367 }
367368
368- public static string ExpandEnvironmentStrings ( string value )
369- {
369+ public static string ExpandEnvironmentStrings ( string value ) {
370370 if ( value == null )
371- throw PythonExceptions . CreateThrowable ( PythonExceptions . TypeError , "must be unicode, not None" ) ;
371+ throw PythonExceptions . CreateThrowable ( PythonExceptions . TypeError , "must be unicode, not None" ) ;
372372
373373 return Environment . ExpandEnvironmentVariables ( value ) ;
374374 }
@@ -379,7 +379,7 @@ private static string ExtractString(byte[] data, int start, int end) {
379379 }
380380 char [ ] chars = new char [ ( end - start ) / 2 ] ;
381381 for ( int i = 0 ; i < chars . Length ; i ++ ) {
382- chars [ i ] = ( char ) ( ( data [ i * 2 + start ] ) | ( data [ i * 2 + start + 1 ] << 8 ) ) ;
382+ chars [ i ] = ( char ) ( ( data [ i * 2 + start ] ) | ( data [ i * 2 + start + 1 ] << 8 ) ) ;
383383 }
384384 return new string ( chars ) ;
385385 }
@@ -393,7 +393,7 @@ public static HKEYType OpenKey(object key, string sub_key) {
393393 return OpenKey ( key , sub_key , 0 , KEY_READ ) ;
394394 }
395395
396- public static HKEYType OpenKey ( object key , string sub_key , int reserved = 0 , int access = KEY_READ ) {
396+ public static HKEYType OpenKey ( object key , string sub_key , int reserved = 0 , int access = KEY_READ ) {
397397 HKEYType rootKey = GetRootKey ( key ) ;
398398 RegistryKey newKey = null ;
399399
@@ -409,19 +409,19 @@ public static HKEYType OpenKey(object key, string sub_key, int reserved=0, int a
409409 try {
410410 if ( ( access & KEY_SET_VALUE ) == KEY_SET_VALUE ||
411411 ( access & KEY_CREATE_SUB_KEY ) == KEY_CREATE_SUB_KEY ) {
412- if ( reserved != 0 ) {
413- newKey = nativeRootKey . OpenSubKey ( sub_key , RegistryKeyPermissionCheck . Default , ( RegistryRights ) reserved ) ;
414- } else {
415- newKey = nativeRootKey . OpenSubKey ( sub_key , true ) ;
416- }
412+ if ( reserved != 0 ) {
413+ newKey = nativeRootKey . OpenSubKey ( sub_key , RegistryKeyPermissionCheck . Default , ( RegistryRights ) reserved ) ;
414+ } else {
415+ newKey = nativeRootKey . OpenSubKey ( sub_key , true ) ;
416+ }
417417 } else if ( ( access & KEY_QUERY_VALUE ) == KEY_QUERY_VALUE ||
418418 ( access & KEY_ENUMERATE_SUB_KEYS ) == KEY_ENUMERATE_SUB_KEYS ||
419419 ( access & KEY_NOTIFY ) == KEY_NOTIFY ) {
420- if ( reserved != 0 ) {
421- newKey = nativeRootKey . OpenSubKey ( sub_key , RegistryKeyPermissionCheck . ReadSubTree , ( RegistryRights ) reserved ) ;
422- } else {
423- newKey = nativeRootKey . OpenSubKey ( sub_key , false ) ;
424- }
420+ if ( reserved != 0 ) {
421+ newKey = nativeRootKey . OpenSubKey ( sub_key , RegistryKeyPermissionCheck . ReadSubTree , ( RegistryRights ) reserved ) ;
422+ } else {
423+ newKey = nativeRootKey . OpenSubKey ( sub_key , false ) ;
424+ }
425425 } else {
426426 throw new Win32Exception ( "Unexpected mode" ) ;
427427 }
@@ -437,7 +437,7 @@ public static HKEYType OpenKey(object key, string sub_key, int reserved=0, int a
437437 return new HKEYType ( newKey ) ;
438438 }
439439
440- public static HKEYType OpenKeyEx ( object key , string sub_key , int reserved = 0 , int access = KEY_READ ) {
440+ public static HKEYType OpenKeyEx ( object key , string sub_key , int reserved = 0 , int access = KEY_READ ) {
441441 return OpenKey ( key , sub_key , reserved , access ) ;
442442 }
443443
@@ -540,12 +540,10 @@ public static HKEYType ConnectRegistry(string computer_name, BigInteger key) {
540540 try {
541541 if ( computer_name == string . Empty ) {
542542 newKey = RegistryKey . OpenBaseKey ( MapSystemKey ( key ) , RegistryView . Default ) ;
543- }
544- else {
543+ } else {
545544 newKey = RegistryKey . OpenRemoteBaseKey ( MapSystemKey ( key ) , computer_name ) ;
546545 }
547- }
548- catch ( IOException ioe ) {
546+ } catch ( IOException ioe ) {
549547 throw PythonExceptions . CreateThrowable ( PythonExceptions . OSError , PythonExceptions . _OSError . ERROR_BAD_NETPATH , ioe . Message , null , PythonExceptions . _OSError . ERROR_BAD_NETPATH ) ;
550548 } catch ( Exception e ) {
551549 throw new ExternalException ( e . Message ) ;
@@ -583,7 +581,7 @@ public static bool QueryReflectionKey(object key) {
583581 HKEYType rootKey = GetRootKey ( key ) ;
584582 bool isDisabled ;
585583
586- if ( ! Environment . Is64BitOperatingSystem ) {
584+ if ( ! Environment . Is64BitOperatingSystem ) {
587585 throw new NotImplementedException ( "not implemented on this platform" ) ;
588586 }
589587
@@ -594,9 +592,9 @@ public static bool QueryReflectionKey(object key) {
594592 return isDisabled ;
595593 }
596594
597- #endregion
595+ #endregion
598596
599- #region Helpers
597+ #region Helpers
600598 private static HKEYType GetRootKey ( object key ) {
601599 HKEYType rootKey ;
602600 rootKey = key as HKEYType ;
@@ -630,7 +628,7 @@ private static RegistryHive MapSystemKey(BigInteger hKey) {
630628 throw new ValueErrorException ( "Unknown system key" ) ;
631629 }
632630
633- #endregion
631+ #endregion
634632
635633
636634 [ PythonType ]
@@ -694,13 +692,13 @@ public RegistryKey GetKey() {
694692 }
695693 }
696694
697- #region IDisposable Members
695+ #region IDisposable Members
698696
699697 void IDisposable . Dispose ( ) {
700698 Close ( ) ;
701699 }
702700
703- #endregion
701+ #endregion
704702 }
705703 }
706704}
0 commit comments