tk2reg                package:tcltk2                R Documentation

_M_a_n_i_p_u_l_a_t_e _t_h_e _r_e_g_i_s_t_r_y _u_n_d_e_r _W_i_n_d_o_w_s

_D_e_s_c_r_i_p_t_i_o_n:

     These functions access the Windows registry.

_U_s_a_g_e:

       tk2reg.broadcast()
       tk2reg.delete(keyname, valuename)
       tk2reg.deletekey(keyname)
       tk2reg.get(keyname, valuename)
       tk2reg.keys(keyname)
       tk2reg.set(keyname, valuename, data, type = c("sz", "expand_sz", "multi_sz",
           "dword", "dword_big_endian", "binary", "link", "resource_list", "none"))
       tk2reg.setkey(keyname)
       tk2reg.type(keyname, valuename)
       tk2reg.values(keyname)

_A_r_g_u_m_e_n_t_s:

 keyname: The name of the key. 

valuename: A value in this key. 

    data: The data to place in the value. 

    type: The type of value in the registry. By default, it is "sz",
          that is, a string. 

_V_a_l_u_e:

     Functions that should return a registry value return it in a
     character string no mather the type of value in the registry. You
     are responsible to coerce it to the correct type.

_N_o_t_e:

     For Windows only. These functions issue an error when they are
     called under other platforms. Take care while manipulating the
     Windows registry! You can easily lock the system completelly, if
     you delete important items, especially if you are logged as
     administrator on your computer. Make a backup of your registry
     first before experimenting with these function!!!

_A_u_t_h_o_r(_s):

     Philippe Grosjean

_S_e_e _A_l_s_o:

     'tk2dde', 'tk2ico'

_E_x_a_m_p_l_e_s:

       ## Not run: 
         ## These cannot be run by examples() but should be OK when pasted
         ## into an interactive R session with the tcltk package loaded

             ## Examples of tk2reg - registry manipulation under Windows
         # Rem: HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER,
         #      HKEY_CURRENT_CONFIG, HKEY_PERFORMANCE_DATA, HKEY_DYN_DATA
         Rkey <- "HKEY_LOCAL_MACHINE\\Software\\R-core\\R"   # The R key
         Rsubkey <- paste(Rkey, "subkey", sep = "\\")        # A subkey

         # Get all subkeys for Software in the local machine
         tk2reg.keys("HKEY_LOCAL_MACHINE\\Software")

         # Get all names in the R key
         tk2reg.values(Rkey)
         # Get info about registered R
         tk2reg.get(Rkey, "Current Version")
         tk2reg.get(Rkey, "InstallPath")

         # Create a subkey (explore the registry with regedit.exe to see it)
         tk2reg.setkey(Rsubkey)
         # Add something in it
         tk2reg.set(Rsubkey, "test", "a key added with tcltk2 registry!", type = "sz")

         # Get the type of a value
         tk2reg.type(Rsubkey, "test")
         # Get a value in a key
         tk2reg.get(Rsubkey, "test")

         # Delete a name in a key (take care: dangerous!)
         tk2reg.delete(Rsubkey, "test")
         # Delete a whole key (take care: very dangerous!)
         tk2reg.deletekey(Rsubkey)

         # An alternate way to get the path
         tk2reg.get("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "path")

         # Make sure that currently running apps are warned of your changes in the registry
         tk2reg.broadcast()

         # Delete temporary variables
         rm(list = c("Rkey", "Rsubkey"))
       ## End(Not run)

