home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.7)
-
- import win32api
- import win32con
- import sys
- import os
- error = 'Registry utility error'
- CLSIDPyFile = '{b51df050-06ae-11cf-ad3b-524153480001}'
- RegistryIDPyFile = 'Python.File'
- RegistryIDPycFile = 'Python.CompiledFile'
-
- def GetRootKey():
- return win32con.HKEY_LOCAL_MACHINE
-
-
- def GetRegistryDefaultValue(subkey, rootkey = None):
- if rootkey is None:
- rootkey = GetRootKey()
- return win32api.RegQueryValue(rootkey, subkey)
-
-
- def SetRegistryDefaultValue(subKey, value, rootkey = None):
- if rootkey is None:
- rootkey = GetRootKey()
- if type(value) == str:
- typeId = win32con.REG_SZ
- elif type(value) == int:
- typeId = win32con.REG_DWORD
- else:
- raise TypeError('Value must be string or integer - was passed ' + repr(value))
- None.RegSetValue(rootkey, subKey, typeId, value)
-
-
- def BuildDefaultPythonKey():
- return 'Software\\Python\\PythonCore\\' + sys.winver
-
-
- def GetAppPathsKey():
- return 'Software\\Microsoft\\Windows\\CurrentVersion\\App Paths'
-
-
- def RegisterPythonExe(exeFullPath, exeAlias = None, exeAppPath = None):
- if exeAppPath:
- raise error('Do not support exeAppPath argument currently')
- if exeAlias is None:
- exeAlias = os.path.basename(exeFullPath)
- win32api.RegSetValue(GetRootKey(), GetAppPathsKey() + '\\' + exeAlias, win32con.REG_SZ, exeFullPath)
-
-
- def GetRegisteredExe(exeAlias):
- return win32api.RegQueryValue(GetRootKey(), GetAppPathsKey() + '\\' + exeAlias)
-
-
- def UnregisterPythonExe(exeAlias):
-
- try:
- win32api.RegDeleteKey(GetRootKey(), GetAppPathsKey() + '\\' + exeAlias)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
- return None
-
-
-
- def RegisterNamedPath(name, path):
- keyStr = BuildDefaultPythonKey() + '\\PythonPath'
- if name:
- keyStr = keyStr + '\\' + name
- win32api.RegSetValue(GetRootKey(), keyStr, win32con.REG_SZ, path)
-
-
- def UnregisterNamedPath(name):
- keyStr = BuildDefaultPythonKey() + '\\PythonPath\\' + name
-
- try:
- win32api.RegDeleteKey(GetRootKey(), keyStr)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
- return None
-
-
-
- def GetRegisteredNamedPath(name):
- keyStr = BuildDefaultPythonKey() + '\\PythonPath'
- if name:
- keyStr = keyStr + '\\' + name
-
- try:
- return win32api.RegQueryValue(GetRootKey(), keyStr)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
- return None
-
-
-
- def RegisterModule(modName, modPath):
-
- try:
- import os
- os.stat(modPath)
- except os.error:
- print 'Warning: Registering non-existant module %s' % modPath
-
- win32api.RegSetValue(GetRootKey(), BuildDefaultPythonKey() + '\\Modules\\%s' % modName, win32con.REG_SZ, modPath)
-
-
- def UnregisterModule(modName):
-
- try:
- win32api.RegDeleteKey(GetRootKey(), BuildDefaultPythonKey() + '\\Modules\\%s' % modName)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
-
-
-
- def GetRegisteredHelpFile(helpDesc):
-
- try:
- return GetRegistryDefaultValue(BuildDefaultPythonKey() + '\\Help\\' + helpDesc)
- except win32api.error:
-
- try:
- return GetRegistryDefaultValue(BuildDefaultPythonKey() + '\\Help\\' + helpDesc, win32con.HKEY_CURRENT_USER)
- except win32api.error:
- pass
-
-
-
-
-
- def RegisterHelpFile(helpFile, helpPath, helpDesc = None, bCheckFile = 1):
- if helpDesc is None:
- helpDesc = helpFile
- fullHelpFile = os.path.join(helpPath, helpFile)
-
- try:
- if bCheckFile:
- os.stat(fullHelpFile)
- except os.error:
- raise ValueError('Help file does not exist')
-
- win32api.RegSetValue(GetRootKey(), BuildDefaultPythonKey() + '\\Help\\%s' % helpDesc, win32con.REG_SZ, fullHelpFile)
-
-
- def UnregisterHelpFile(helpFile, helpDesc = None):
- key = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\Windows\\Help', 0, win32con.KEY_ALL_ACCESS)
-
- try:
- win32api.RegDeleteValue(key, helpFile)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
- finally:
- win32api.RegCloseKey(key)
-
- if helpDesc is None:
- helpDesc = helpFile
-
- try:
- win32api.RegDeleteKey(GetRootKey(), BuildDefaultPythonKey() + '\\Help\\%s' % helpDesc)
- except win32api.error:
- exc = None
- import winerror
- if exc.winerror != winerror.ERROR_FILE_NOT_FOUND:
- raise
-
-
-
- def RegisterCoreDLL(coredllName = None):
- if coredllName is None:
- coredllName = win32api.GetModuleFileName(sys.dllhandle)
- else:
-
- try:
- os.stat(coredllName)
- except os.error:
- print 'Warning: Registering non-existant core DLL %s' % coredllName
-
- hKey = win32api.RegCreateKey(GetRootKey(), BuildDefaultPythonKey())
-
- try:
- win32api.RegSetValue(hKey, 'Dll', win32con.REG_SZ, coredllName)
- finally:
- win32api.RegCloseKey(hKey)
-
- win32api.RegSetValue(GetRootKey(), 'Software\\Python\\PythonCore\\CurrentVersion', win32con.REG_SZ, sys.winver)
-
-
- def RegisterFileExtensions(defPyIcon, defPycIcon, runCommand):
- pythonFileId = RegistryIDPyFile
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, '.py', win32con.REG_SZ, pythonFileId)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, pythonFileId, win32con.REG_SZ, 'Python File')
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, '%s\\CLSID' % pythonFileId, win32con.REG_SZ, CLSIDPyFile)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, '%s\\DefaultIcon' % pythonFileId, win32con.REG_SZ, defPyIcon)
- base = '%s\\Shell' % RegistryIDPyFile
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\Open', win32con.REG_SZ, 'Run')
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\Open\\Command', win32con.REG_SZ, runCommand)
- pythonFileId = RegistryIDPycFile
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, '.pyc', win32con.REG_SZ, pythonFileId)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, pythonFileId, win32con.REG_SZ, 'Compiled Python File')
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, '%s\\DefaultIcon' % pythonFileId, win32con.REG_SZ, defPycIcon)
- base = '%s\\Shell' % pythonFileId
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\Open', win32con.REG_SZ, 'Run')
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\Open\\Command', win32con.REG_SZ, runCommand)
-
-
- def RegisterShellCommand(shellCommand, exeCommand, shellUserCommand = None):
- base = '%s\\Shell' % RegistryIDPyFile
- if shellUserCommand:
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\%s' % shellCommand, win32con.REG_SZ, shellUserCommand)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\%s\\Command' % shellCommand, win32con.REG_SZ, exeCommand)
-
-
- def RegisterDDECommand(shellCommand, ddeApp, ddeTopic, ddeCommand):
- base = '%s\\Shell' % RegistryIDPyFile
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\%s\\ddeexec' % shellCommand, win32con.REG_SZ, ddeCommand)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\%s\\ddeexec\\Application' % shellCommand, win32con.REG_SZ, ddeApp)
- win32api.RegSetValue(win32con.HKEY_CLASSES_ROOT, base + '\\%s\\ddeexec\\Topic' % shellCommand, win32con.REG_SZ, ddeTopic)
-
-