• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

registration checker

Itrying to  have my registration checker will be looking in registry :
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\SEMS\
for key:
Expiration
value in format:
MM/DD/YYYY
(month/day can be 1 or 2 characters in length, year will always be 4)

then warns you if you are <60 days from expiration and has a different message for last day usable.

If not online, use computer clock - if online get online time and update "last time online" to current date. (also in format MM/DD/YYYY)

This is the code I am trying to modify

aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE\SOFTWARE\SEMS\)
I keep getting a syntax error

Open in new window

from _winreg import *

print r"*** Reading from SOFTWARE\Microsoft\Windows\CurrentVersion\Run ***"
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)

aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run") 
for i in range(1024):                                           
    try:
        n,v,t = EnumValue(aKey,i)
        print i, n, v, t
    except EnvironmentError:                                               
        print "You have",i," tasks starting at logon..."
        break          
CloseKey(aKey) 

Open in new window

                                               
0
dolamitejenkins
Asked:
dolamitejenkins
  • 2
1 Solution
 
clockwatcherCommented:
The ConnectRegistry function is looking for the root registry handle to open (e.g,. HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER).  It's not looking for the actual key that you want to work with.  That key is specified in the OpenKey call.

from _winreg import *

aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r"SOFTWARE\SEMS")
expiration = QueryValueEx(aKey, "Expiration")
print expiration
CloseKey(aKey)

Open in new window

0
 
dolamitejenkinsAuthor Commented:
thanks
0
 
dolamitejenkinsAuthor Commented:
Thanks
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now