Playing with Registry using Python.,


def regReadValue( regKey, subKey, name ):
 #print regKey
 aReg = ConnectRegistry(None,regKey)
 aKey = OpenKey(aReg, subKey)
 index = 0
 data = []
 while 1:
  try:
   regName = EnumValue(aKey, index)
   if name == regName[0]:
   data = regName[1:]
   print data
   return data
  except:
   break
  index = index + 1
  return data 

def regRead( regKey, subKey):
 #print regKey
 aReg = ConnectRegistry(None,regKey)
 aKey = OpenKey(aReg, subKey) # r'SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
 index = 0
 data = []
 while 1:
  try:
   print("Enumkey =" + subKey + "\\" + EnumKey(aKey, index))
   data.append( subKey + "\\" + EnumKey(aKey, index))
  except:
   break
  index = index + 1
return data

def regWrite(regKey, subKey, regValue, regData, regType):
 aReg = ConnectRegistry(None,regKey)
 print subKey
 aKey = CreateKey(aReg, subKey) #, 0, KE)
 try:
  SetValueEx(aKey,regValue,0, regType, regData)
 except EnvironmentError:
  print "Encountered problems writing into the Registry..."
 CloseKey(aKey)
 CloseKey(aReg)

def regDelete(regKey, subKey):
 #aReg = ConnectRegistry(none,regKey)
 reg = regRead(regKey, subKey)
 for a in reg:
  regDelete(regKey,a)
  print a
  DeleteKey(regKey, subKey)

Advertisements

2 thoughts on “Playing with Registry using Python.,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s