+
    )j*                         R t ^ RIt^ RIt^ RIHt ^RIHt ]! ]4      tRR/R lt	RR lt
RR ltRR	 ltRR
 lt]P                  R3R ltR tR# )a  
Utilities for Windows Registry manipulation

Notes:

winreg.SetValue -> sets _keys_ with default ("") values
winreg.SetValueEx -> sets values with named contents

This is important when the argument has backslashes.
SetValue will process the backslashes into a path of keys
SetValueEx will create a value with name "path\with\keys"


Mnemonic: SetValueEx for "excalars" (scalars, named values)
N)	getLogger
logged_runcheckTc                 &    \        R .VORNV R7      # )zreg.exez/fr   r   )r   argss   $*Elib/python3.14/site-packages/menuinst/platforms/win_utils/registry.py_reg_exer
      s    y.4..e<<    c                   VR8X  d   RpMRp\        V RV  RV 2R4       \        V RV R2V  RV R	24       \        V RV R
2V4       V'       d7   \        V RV R2V4       \        V RV R2V4       \        V RV R2V4       V'       d   \        V RV R2V4       V'       d%   \        V RV R2V4       \        V RV R2V4       V'       d   \        V RV R2V4       R# R# )a  
We want to achieve this. Entries ending in / denote keys; no trailing / means named value.
If the item has a value attached to it, it's written after the : symbol.

HKEY_*/ # current user or local machine
  Software/
    Classes/
      .<extension>/
        OpenWithProgids/
          <extension-handler>
      ...
      <extension-handler>/: "a description of the file being handled"
        DefaultIcon/: "path to the app icon"
        FriendlyAppName/: "Name of the program"
        AppUserModelID: "AUMI string"
        shell/
          open/: "Name of the program"
            icon: "path to the app icon"
            FriendlyAppName: "name of the program"
            command/: "the command to be executed when opening a file with this extension"
systemz#HKEY_LOCAL_MACHINE/Software/Classesz"HKEY_CURRENT_USER/Software/Classes/z/OpenWithProgids/ /@ z file/shell/open/command/@/shell/open/@/FriendlyAppName/@/shell/open/FriendlyAppNamez/AppUserModelID/DefaultIcon/@/shell/open/Iconz/FriendlyTypeNameN)regvalue)		extension
identifiercommandiconapp_namefriendly_type_nameapp_user_model_idmodekeys	   &&&&&&&& r	   register_file_extensionr"      s0   > x32 uAi[ 1*>C uAj\$1ZL&FG uAj\!67AC5*]3X>C5*%78(CC5*%@A8LC5*_57HI 	C5*^4d;C5*%56= 	C5*%679KL	 r   c                    VR 8X  d   \         P                  R3M\         P                  R3w  r4\        RV RV 2RR7        \         P                  ! VRV  R2^ \         P
                  4      ;_uu_ 4       p\         P                  ! WQ4       R	R	R	4       R	#   + '       g   i     R	# ; i  \         d    \        P                  R
Y4        R	# \         d#   p\        P                  RYR7        R	p?R# R	p?ii ; i)r   HKLMHKCUdeletez\Software\Classes\Fr   Software\Classes\z\OpenWithProgidsNz2Handler '%s' is not associated with extension '%s'z%Could not check key '%s' for deletionexc_info)winregHKEY_LOCAL_MACHINEHKEY_CURRENT_USERr
   OpenKeyKEY_ALL_ACCESSDeleteValueFileNotFoundErrorlogdebug	Exception)r   r   r    rootroot_strr!   excs   &&&    r	   unregister_file_extensionr7   b   s     8 
	"	"F+&&/ D
 X8*$6zlC5Q	^^&yk1ABAvG\G\
 
s/
 
 
 
  _		F
^ 		99	SsB   3B* 5BB* B'	!B* 'B* *!C:C:C:C55C:c                    VR 8X  d   RV  2pMRV  2p\        V R2RV P                  4        24       \        V R2R4       \        V R2V4       V'       d.   \        V R2V4       \        V R	2V4       \        V R
2V4       V'       d   \        V R2V4       \        V R2V4       V'       d   \        V R2V4       V'       d   \        V R2V4       R# R# )r   zHKEY_CLASSES_ROOT/z#HKEY_CURRENT_USER/Software/Classes/r   zURL:z/URL Protocolr   r   r   r   r   r   r   z/AppUserModelIdz
/_menuinstN)r   title)protocolr   r   r   r   r   r    r!   s   &&&&&&& r	   register_url_protocolr;   v   s     x"8*-3H:>uBZ4 0123uM"B'u)*G4C5&1C5*+X6C534h?C5'.C5()40C5(*;<C5
#Z0 r   c                    VR 8X  d   \         P                  V 3pRV  2pM\         P                  RV  23pRV  2p \         P                  ! V!  ;_uu_ 4       p\         P                  ! VR4      w  rgVRJ ;'       g    Wa8H  pRRR4       X'       d   \        RTR	R
7       R# R#   + '       g   i     L*; i  \
         d#   p	\        P                  RY	R7        Rp	?	R# Rp	?	ii ; i)r   zHKCR\r'   zHKCU\Software\Classes\	_menuinstNz#Could not check key %s for deletionr(   r&   Fr   )	r*   HKEY_CLASSES_ROOTr,   r-   QueryValueExOSErrorr1   	exceptionr
   )
r:   r   r    	key_tuplekey_strr!   value_r&   r6   s
   &&&       r	   unregister_url_protocolrF      s    x,,h6	8*%,,1B8*.MM	+H:6^^Y''3**3<HE4'>>5+>F ( 7%0  ('  ;XTs5   B6 *B#B6 #B3	.B6 3B6 6C#CC#c           	        \         P                  RW4       V P                  RR4      P                  R4      ;rV P	                  R4      EvrVrx\        \        V4      p	\        P                  p
 VR8X  d   V'       d'   \        P                  ! V	RP                  V4      4       \        P                  ! V	RP                  V4      V
R7      ;_uu_ 4       p \        P                  ! WW!4       RRR4       R# \        P                  ! V	RP                  . VOVN4      4       \        P                  ! V	RP                  . VOVN4      V
R7      ;_uu_ 4       p \        P                  ! W^ W!4       RRR4       R#   + '       g   i     R# ; i  + '       g   i     R# ; i  \         d-   pT'       d   h \         P                  RYATR7        Rp?R# Rp?ii ; i)	ax  
Convenience wrapper to set different types of registry values.

For practical purposes we distinguish between three cases:

- A key with no value (think of a directory with no contents).
  Use value = "".
- A key with an unnamed value (think of a directory with a file 'index.html')
  Use a key with '@' as the last component.
- A key with named values (think of non-index.html files in the directory)

The first component of the key is the root, and must be one of the winreg.HKEY_*
variable _names_ (their actual value will be fetched from winreg).

Key must be at least three components long (root key, *key, @ or named value).
z Setting registry value %s = '%s'\r   @)accessNzCould not set %s to %sr(   )r1   r2   replacestripsplitgetattrr*   KEY_SET_VALUE	CreateKeyjoinr-   SetValue
SetValueExr@   warning)r!   rD   
value_typeraise_on_errorsoriginal_keyr4   midkeysubkeynamed_valuerootkeyrJ   r6   s   &&&&        r	   r   r      sk   " II0#=T3/55c::C),3&D6fd#G!!FQ#  $))F*;<6):6JJcZ? KJ Wdii0A&0A&0A&BC3DV3DV3D)EfUUY\!!#AzI VU	 KJJ VUU Q,lCPPQsb   .F =AF E6+F 5AF F
,F 6F	F F 
F	F F G)!GGc                     \         P                  ! R4      p RV P                  n        Rp^ pV P                  WRR4       R# )z
Needed to propagate registry changes without having to reboot.

https://discuss.python.org/t/is-there-a-library-to-change-windows-10-default-program-icon/5846/2
shell32Ni   )ctypesOleDLLSHChangeNotifyrestype)r]   eventflagss      r	   notify_shell_changesrd      s<     mmI&G%)G"EE5t4r   )NNNNuser)re   )Nre   )__doc__r^   r*   loggingr   utilsr   __name__r1   r
   r"   r7   r;   rF   REG_SZr   rd    r   r	   <module>rl      s[        =$ =>MH(1<1& %+MM4 #QL
5r   