Welcome, guest | Sign In | My Account | Store | Cart

RegObj is an ActiveX server for registry manipulation that can be driven using Python. Its object model provides significant advantages over the use of the registry API.

Python, 27 lines
 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
RegObj.dll is an ActiveX server--and, hence, has an automation interface--that is available with documentation in 
the distribution file known as RegObji.exe, from the following page:

    http://msdn.microsoft.com/vbasic/downloads/addins.asp
    
To provide early binding for RegObj use 

 >>> from win32com.client import gencache
 >>> gencache.EnsureModule('{DE10C540-810E-11CF-BBE7-444553540000}', 0, 1, 0)
 
or the MakePy utility within PythonWin, referring to "Regstration Manipulation Classes (1.0)" (Please notice
the spelling error.)
 
Sample use, to determine what command is associated with a Python file:

>>> from win32com.client import Dispatch, gencache
>>> from win32con import HKEY_CLASSES_ROOT

>>> gencache.EnsureModule('{DE10C540-810E-11CF-BBE7-444553540000}', 0, 1, 0)

>>> regobj = Dispatch ( 'RegObj.Registry' )

>>> HKCR = regobj.RegKeyFromHKey ( HKEY_CLASSES_ROOT )

>>> PythonFileKey = HKCR.ParseKeyName('Python.File\Shell\Open\command')
>>> PythonFileKey.Value
u'J:\\Python22\\pythonw.exe "%1" %*'

See the Esposito article mentioned below for example using VBA that parallel what is possible with Python.

I am indebted to Dino Esposito for the article entitled "Windows 2000 Registry: Latest Features and APIs Provide the Power to Customize and Extend Your Apps" which is available on msdn.microsoft.com; and to Mark Hammond and Andy Robinson, for the book "Python Programming on Win32".

Request for information:

  1. The module created by MakePy contains a class called "Constants" that defines values that are needed for some tasks involving RegObj. What is the best way of gaining access to them?

  2. For some purposes it might be better to express tasks for the registry using an '.rgs' registration script, as MCVC does. Has someone seen a Python module that does this?

Created by Bill Bell on Wed, 3 Jul 2002 (PSF)
Python recipes (4591)
Bill Bell's recipes (16)

Required Modules

  • (none specified)

Other Information and Tasks