Solved

registration checker

Posted on 2011-03-17
3
340 Views
Last Modified: 2012-06-27
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
Comment
Question by:dolamitejenkins
  • 2
3 Comments
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 35161357
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
 

Author Comment

by:dolamitejenkins
ID: 35162069
thanks
0
 

Author Closing Comment

by:dolamitejenkins
ID: 35173802
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question