当前位置: 首页>>代码示例>>Python>>正文


Python _winreg.CreateKey方法代码示例

本文整理汇总了Python中_winreg.CreateKey方法的典型用法代码示例。如果您正苦于以下问题:Python _winreg.CreateKey方法的具体用法?Python _winreg.CreateKey怎么用?Python _winreg.CreateKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_winreg的用法示例。


在下文中一共展示了_winreg.CreateKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: modify

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def modify():
    pythonpath = os.path.dirname(os.path.normpath(sys.executable))
    scripts = os.path.join(pythonpath, "Scripts")
    appdata = os.environ["APPDATA"]
    if hasattr(site, "USER_SITE"):
        userpath = site.USER_SITE.replace(appdata, "%APPDATA%")
        userscripts = os.path.join(userpath, "Scripts")
    else:
        userscripts = None

    with _winreg.CreateKey(HKCU, ENV) as key:
        try:
            envpath = _winreg.QueryValueEx(key, PATH)[0]
        except WindowsError:
            envpath = DEFAULT

        paths = [envpath]
        for path in (pythonpath, scripts, userscripts):
            if path and path not in envpath and os.path.isdir(path):
                paths.append(path)

        envpath = os.pathsep.join(paths)
        _winreg.SetValueEx(key, PATH, 0, _winreg.REG_EXPAND_SZ, envpath)
        return paths, envpath 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:26,代码来源:win_add2path.py

示例2: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolderRoot._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    print ShellFolderRoot._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:shell_view.py

示例3: unregister

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def unregister(classobj):
    import _winreg
    subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_
    try:
        hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
        subKey = _winreg.DeleteValue( hKey, "ButtonText" )
        _winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
        _winreg.DeleteValue( hKey, "CLSID" )
        _winreg.DeleteValue( hKey, "Default Visible" )
        _winreg.DeleteValue( hKey, "ToolTip" )
        _winreg.DeleteValue( hKey, "Icon" )
        _winreg.DeleteValue( hKey, "HotIcon" )
        _winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
    except WindowsError:
        print "Couldn't delete Standard toolbar regkey."
    else:
        print "Deleted Standard toolbar regkey."

#
# test implementation
# 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:iebutton.py

示例4: save

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def save(self):
        if USE_WINDOWS:
            import _winreg
            try:
                key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, self.keyname,
                                      sam=_winreg.KEY_SET_VALUE | _winreg.KEY_WRITE)
            except:
                key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, self.keyname)
            try:
                for k, v in self.values.iteritems():
                    _winreg.SetValueEx(key, str(k), 0, _winreg.REG_SZ, str(v))
            finally:
                key.Close()
        else:
            d = os.path.dirname(self.filename)
            if not os.path.isdir(d):
                os.makedirs(d)
            
            f = open(self.filename, 'w')
            try:
                data = '\n'.join(["%s=%s" % (k,v)
                                  for k,v in self.values.iteritems()])
                f.write(data)
            finally:
                f.close() 
开发者ID:fsmMLK,项目名称:inkscapeMadeEasy,代码行数:27,代码来源:textext.py

示例5: run

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def run(args=None):
    """
    Run the ransom module

    `Required`
    :param str args:  encrypt, decrypt, payment

    """
    global usage
    if args:
        cmd, _, action = str(args).partition(' ')
        if 'payment' in cmd:
            return request_payment(action)
        elif 'decrypt' in cmd:
            return decrypt_files(action)
        elif 'encrypt' in cmd:
            reg_key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, globals()['registry_key'])
            return encrypt_files(action)
    return usage 
开发者ID:malwaredllc,项目名称:byob,代码行数:21,代码来源:ransom.py

示例6: enforce_shortcut

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def enforce_shortcut(config, log_func):
    if os.name != 'nt':
        return

    path = win32api.GetModuleFileName(0)

    if 'python' in path.lower():
        # oops, running the .py too lazy to make that work
        path = r"C:\Program Files\BitTorrent\bittorrent.exe"

    root_key = _winreg.HKEY_CURRENT_USER
    subkey = r'Software\Microsoft\Windows\CurrentVersion\run'
    key = _winreg.CreateKey(root_key, subkey)
    if config['launch_on_startup']:
        _winreg.SetValueEx(key, app_name, 0, _winreg.REG_SZ,
                           '"%s" --force_start_minimized' % path)
    else:
        try:
            _winreg.DeleteValue(key, app_name)
        except WindowsError, e:
            # value doesn't exist
            pass 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:24,代码来源:platform.py

示例7: Install

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def Install():
    AddOrRemoveHIDKeys(True)
    osExtension = "x86"
    if Is64BitOS():
        osExtension = "x64"
    pluginDir =  dirname(__file__.decode(sys.getfilesystemencoding()))
    tmpExe = join(pluginDir, "AlternateMceIrService_%s.exe"%osExtension)
    myExe = join(pluginDir, "AlternateMceIrService.exe")
    try:
        os.remove(myExe)
    except:
        pass
    shutil.copyfile(tmpExe,myExe)
    key = reg.CreateKey(reg.HKEY_LOCAL_MACHINE, ServiceKey+"\\AlternateMceIrService")
    reg.SetValueEx(key, "EventMessageFile", 0, reg.REG_SZ, myExe)
    reg.SetValueEx(key, "TypesSupported", 0, reg.REG_DWORD, 7)
    service = Service(u"AlternateMceIrService")
    service.Install(myExe)
    service.Start()
    print "Service successfully installed" 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:22,代码来源:Install.py

示例8: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                            "directory\\shellex\\CopyHookHandlers\\" +
                            ShellExtension._reg_desc_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                            "*\\shellex\\CopyHookHandlers\\" +
                            ShellExtension._reg_desc_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
    print ShellExtension._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:copy_hook.py

示例9: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    import _winreg
    # Special ColumnProvider key
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "Folder\\ShellEx\\ColumnHandlers\\" + \
                        str(ColumnProvider._reg_clsid_ ))
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ColumnProvider._reg_desc_)
    print ColumnProvider._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:column_provider.py

示例10: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    # Also need to register specially in:
    # HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches
    # See link at top of file.
    import _winreg
    kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \
         % (EmptyVolumeCache._reg_desc_,)
    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, kn)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, EmptyVolumeCache._reg_clsid_) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:empty_volume_cache.py

示例11: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                            "Python.File\\shellex")
    subkey = _winreg.CreateKey(key, "ContextMenuHandlers")
    subkey2 = _winreg.CreateKey(subkey, "PythonSample")
    _winreg.SetValueEx(subkey2, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_)
    print ShellExtension._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:context_menu.py

示例12: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    import _winreg
    if sys.getwindowsversion()[0] < 6:
        print "This sample only works on Vista"
        sys.exit(1)

    key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE,
                            "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \
                            "Explorer\\Desktop\\Namespace\\" + \
                            ShellFolder._reg_clsid_)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_)
    # And special shell keys under our CLSID
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT,
                        "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder")
    # 'Attributes' is an int stored as a binary! use struct
    attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \
           shellcon.SFGAO_BROWSABLE
    import struct
    s = struct.pack("i", attr)
    _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s)
    # register the context menu handler under the FolderViewSampleType type.
    keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_)
    key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath)
    _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_)
    propsys.PSRegisterPropertySchema(get_schema_fname())
    print ShellFolder._reg_desc_, "registration complete." 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:28,代码来源:folder_view.py

示例13: _doregister

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def _doregister(mod_name, dll_name):
    assert os.path.isfile(dll_name), "Shouldn't get here if the file doesn't exist!"
    try:
        key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
    except _winreg.error:
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, mod_name))
        except _winreg.error:
            print "Could not find the existing '%s' module registered in the registry" % (mod_name,)
            usage_and_die(4)
    # Create the debug key.
    sub_key = _winreg.CreateKey(key, "Debug")
    _winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
    print "Registered '%s' in the registry" % (dll_name,) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:setup_d.py

示例14: DllRegisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllRegisterServer():
    comclass = IEToolbar

    # register toolbar with IE
    try:
        print "Trying to register Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        subKey = _winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, _winreg.REG_BINARY, "\0" )
    except WindowsError:
        print "Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    # TODO: implement reg settings for standard toolbar button

# unregister plugin 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:ietoolbar.py

示例15: DllUnregisterServer

# 需要导入模块: import _winreg [as 别名]
# 或者: from _winreg import CreateKey [as 别名]
def DllUnregisterServer():
    comclass = IEToolbar

    # unregister toolbar from internet explorer
    try:
        print "Trying to unregister Toolbar.\n"
        hkey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" )
        _winreg.DeleteValue( hkey, comclass._reg_clsid_ )
    except WindowsError:
        print "Couldn't delete registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )
    else:
        print "Deleting reg key succeeded.\n"

# entry point 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:ietoolbar.py


注:本文中的_winreg.CreateKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。