Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
dumps Foxit Reader history from registry
#
# lists Foxit Reader last opened files from registry
# 2015.08.31 darell tan
#
from _winreg import *
from ctypes import windll, create_unicode_buffer
def GetLongPathName(path):
buf = create_unicode_buffer(1024)
try:
rv = windll.kernel32.GetLongPathNameW(path, buf, 1024)
return buf.value
except:
return None
# regkey helper
class RegKey:
def __init__(self, key, *subpath):
if key in (HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, \
HKEY_USERS, HKEY_PERFORMANCE_DATA, HKEY_CURRENT_CONFIG):
self.parent = ConnectRegistry(None, key)
elif isinstance(key, self.__class__):
self.parent = key.key
else:
self.parent = key
self.key = OpenKey(self.parent, '\\'.join(subpath))
def open(self, *subpath):
return RegKey(self, *subpath)
def keys(self):
i = 0
try:
while True:
yield EnumKey(self.key, i)
i += 1
except WindowsError:
pass
def __getitem__(self, key):
return QueryValueEx(self.key, key)[0]
# # #
if __name__ == '__main__':
foxitSw = RegKey(HKEY_CURRENT_USER, r"Software\Foxit Software")
for ver in foxitSw.keys():
if "Reader" not in ver:
continue
print '\n' + ver
print '-' * 20
foxitKey = foxitSw.open(ver, r"Preferences\History\LastOpen")
for histNum in foxitKey.keys():
name = RegKey(foxitKey, histNum)["FileName"]
lfn = GetLongPathName(name)
print lfn or name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.