當前位置: 首頁>>代碼示例>>Python>>正文


Python win32api.RegSetValueEx方法代碼示例

本文整理匯總了Python中win32api.RegSetValueEx方法的典型用法代碼示例。如果您正苦於以下問題:Python win32api.RegSetValueEx方法的具體用法?Python win32api.RegSetValueEx怎麽用?Python win32api.RegSetValueEx使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32api的用法示例。


在下文中一共展示了win32api.RegSetValueEx方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testValues

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def testValues(self):
        key_name = r'PythonTestHarness\win32api'
        ## tuples containing value name, value type, data
        values=(
            (None, win32con.REG_SZ, 'This is default unnamed value'),
            ('REG_SZ', win32con.REG_SZ,'REG_SZ text data'),
            ('REG_EXPAND_SZ', win32con.REG_EXPAND_SZ, '%systemdir%'),
            ## REG_MULTI_SZ value needs to be a list since strings are returned as a list
            ('REG_MULTI_SZ', win32con.REG_MULTI_SZ, ['string 1','string 2','string 3','string 4']),
            ('REG_DWORD', win32con.REG_DWORD, 666),
            ('REG_BINARY', win32con.REG_BINARY, str2bytes('\x00\x01\x02\x03\x04\x05\x06\x07\x08\x01\x00')),
            )

        hkey = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER, key_name)
        for value_name, reg_type, data in values:
            win32api.RegSetValueEx(hkey, value_name, None, reg_type, data)

        for value_name, orig_type, orig_data in values:
            data, typ=win32api.RegQueryValueEx(hkey, value_name)
            self.assertEqual(typ, orig_type)
            self.assertEqual(data, orig_data) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_win32api.py

示例2: __setitem__

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def __setitem__(self, item, value):
        item = str(item)
        pyvalue = type(value)
        if pyvalue is dict or isinstance(value, RegistryDict):
            d = RegistryDict(self.keyhandle, item)
            d.clear()
            d.update(value)
            return
        if pyvalue is str:
            valuetype = win32con.REG_SZ
        elif pyvalue is int:
            valuetype = win32con.REG_DWORD
        else:
            valuetype = win32con.REG_BINARY
            value = 'PyPickle' + cPickle.dumps(value)
        win32api.RegSetValueEx(self.keyhandle, item, 0, valuetype, value) 
開發者ID:ActiveState,項目名稱:code,代碼行數:18,代碼來源:recipe-174627.py

示例3: _register

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def _register(cls):
    """Register an inproc com server in HKEY_CURRENT_USER.

    This may be used as a replacement for win32com.server.register.UseCommandLine
    to register the server into the HKEY_CURRENT_USER area of the registry
    instead of HKEY_LOCAL_MACHINE.
    """
    clsid_path = "Software\\Classes\\CLSID\\" + cls._reg_clsid_
    progid_path = "Software\\Classes\\" + cls._reg_progid_
    spec = cls.__module__ + "." + cls.__name__

    # register the class information
    win32api.RegSetValue(win32con.HKEY_CURRENT_USER, clsid_path, win32con.REG_SZ, cls._reg_desc_)
    win32api.RegSetValue(win32con.HKEY_CURRENT_USER, clsid_path + "\\ProgID", win32con.REG_SZ, cls._reg_progid_)
    win32api.RegSetValue(win32con.HKEY_CURRENT_USER, clsid_path + "\\PythonCOM", win32con.REG_SZ, spec)
    hkey = win32api.RegCreateKey(win32con.HKEY_CURRENT_USER, clsid_path + "\\InprocServer32")
    win32api.RegSetValueEx(hkey, None, None, win32con.REG_SZ, pythoncom.__file__)
    win32api.RegSetValueEx(hkey, "ThreadingModel", None, win32con.REG_SZ, "Both")

    # and add the progid
    win32api.RegSetValue(win32con.HKEY_CURRENT_USER, progid_path, win32con.REG_SZ, cls._reg_desc_)
    win32api.RegSetValue(win32con.HKEY_CURRENT_USER, progid_path + "\\CLSID", win32con.REG_SZ, cls._reg_clsid_)

# make sure the example RTD server is registered 
開發者ID:pyxll,項目名稱:pyxll-examples,代碼行數:26,代碼來源:rtd_function.py

示例4: SetItemsCurrentValue

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def SetItemsCurrentValue(self, item, valueName, value):
		# ** Assumes already checked is a string.
		hkey = win32api.RegOpenKey(item.keyRoot, item.keyName , 0, win32con.KEY_SET_VALUE)
		try:
			win32api.RegSetValueEx(hkey, valueName, 0, win32con.REG_SZ, value)
		finally:
			win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:regedit.py

示例5: SetServiceCustomOption

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def SetServiceCustomOption(serviceName, option, value):
    try:
        serviceName = serviceName._svc_name_
    except AttributeError:
        pass
    key = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, "System\\CurrentControlSet\\Services\\%s\\Parameters" % serviceName)
    try:
        if type(value)==type(0):
            win32api.RegSetValueEx(key, option, 0, win32con.REG_DWORD, value);
        else:
            win32api.RegSetValueEx(key, option, 0, win32con.REG_SZ, value);
    finally:
        win32api.RegCloseKey(key) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:15,代碼來源:win32serviceutil.py

示例6: setWallPaper

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def setWallPaper(imagepath='download/cache_wallpaper.png'):
	keyex = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, win32con.KEY_SET_VALUE)
	win32api.RegSetValueEx(keyex, "WallpaperStyle", 0, win32con.REG_SZ, "0")
	win32api.RegSetValueEx(keyex, "TileWallpaper", 0, win32con.REG_SZ, "0")
	win32gui.SystemParametersInfo(win32con.SPI_SETDESKWALLPAPER, imagepath, win32con.SPIF_SENDWININICHANGE) 
開發者ID:CharlesPikachu,項目名稱:Tools,代碼行數:7,代碼來源:earthWallpaper.py

示例7: modifyVariableInRegister

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def modifyVariableInRegister( name , value ):
    key = win32api.RegOpenKey( win32con.HKEY_CURRENT_USER,"Environment",0,win32con.KEY_ALL_ACCESS)
    if not key : raise
    win32api.RegSetValueEx( key , name , 0 , win32con.REG_SZ , value )
    win32api.RegCloseKey( key ) 
開發者ID:ActiveState,項目名稱:code,代碼行數:7,代碼來源:recipe-576431.py

示例8: WriteRegistryValue

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def WriteRegistryValue(hiveKey, key, name, data, typeId=win32con.REG_SZ):
    """ Write one value to Windows registry. If 'name' is empty string, writes default value.
        Creates subkeys as necessary"""
    try:
        keyHandle = OpenRegistryKey(hiveKey, key)
        win32api.RegSetValueEx(keyHandle, name, 0, typeId, data)
        win32api.RegCloseKey(keyHandle)
    except Exception, e:
        print "WriteRegistryValue failed:", hiveKey, name, e 
開發者ID:ActiveState,項目名稱:code,代碼行數:11,代碼來源:recipe-528896.py

示例9: __setitem__

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def __setitem__(self, name, value):
        if isinstance(value, (tuple, list)):
            value = list(map(str, value))
            win32api.RegSetValueEx( self.handle, name, None, win32con.REG_MULTI_SZ, value)
        elif isinstance(value, bytes):
            win32api.RegSetValueEx( self.handle, name, None, win32con.REG_SZ, value.decode("UTF8"))
        else:
            win32api.RegSetValueEx( self.handle, name, None, win32con.REG_SZ, str(value)) 
開發者ID:wxGlade,項目名稱:wxGlade,代碼行數:10,代碼來源:msw.py

示例10: set

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def set(self, valueName, valueType, valueData):
        return Api.RegSetValueEx(self.hKey, valueName, None, valueType, valueData) 
開發者ID:grawity,項目名稱:code,代碼行數:4,代碼來源:registry.py

示例11: AddSourceToRegistry

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def AddSourceToRegistry(appName, msgDLL = None, eventLogType = "Application", eventLogFlags = None):
    """Add a source of messages to the event log.

    Allows Python program to register a custom source of messages in the
    registry.  You must also provide the DLL name that has the message table, so the
    full message text appears in the event log.

    Note that the win32evtlog.pyd file has a number of string entries with just "%1"
    built in, so many Python programs can simply use this DLL.  Disadvantages are that
    you do not get language translation, and the full text is stored in the event log,
    blowing the size of the log up.
    """

    # When an application uses the RegisterEventSource or OpenEventLog
    # function to get a handle of an event log, the event loggging service
    # searches for the specified source name in the registry. You can add a
    # new source name to the registry by opening a new registry subkey
    # under the Application key and adding registry values to the new
    # subkey.

    if msgDLL is None:
        msgDLL = win32evtlog.__file__

    # Create a new key for our application
    hkey = win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE, \
        "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, appName))

    # Add the Event-ID message-file name to the subkey.
    win32api.RegSetValueEx(hkey,
        "EventMessageFile",    # value name \
        0,                     # reserved \
        win32con.REG_EXPAND_SZ,# value type \
        msgDLL)

    # Set the supported types flags and add it to the subkey.
    if eventLogFlags is None:
        eventLogFlags = win32evtlog.EVENTLOG_ERROR_TYPE | win32evtlog.EVENTLOG_WARNING_TYPE | win32evtlog.EVENTLOG_INFORMATION_TYPE
    win32api.RegSetValueEx(hkey, # subkey handle \
        "TypesSupported",        # value name \
        0,                       # reserved \
        win32con.REG_DWORD,      # value type \
        eventLogFlags)
    win32api.RegCloseKey(hkey) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:45,代碼來源:win32evtlogutil.py

示例12: InstallPerfmonForService

# 需要導入模塊: import win32api [as 別名]
# 或者: from win32api import RegSetValueEx [as 別名]
def InstallPerfmonForService(serviceName, iniName, dllName = None):
    # If no DLL name, look it up in the INI file name
    if not dllName: # May be empty string!
        dllName = win32api.GetProfileVal("Python", "dll", "", iniName)
    # Still not found - look for the standard one in the same dir as win32service.pyd
    if not dllName:
        try:
            tryName = os.path.join(os.path.split(win32service.__file__)[0], "perfmondata.dll")
            if os.path.isfile(tryName):
                dllName = tryName
        except AttributeError:
            # Frozen app? - anyway, can't find it!
            pass
    if not dllName:
        raise ValueError("The name of the performance DLL must be available")
    dllName = win32api.GetFullPathName(dllName)
    # Now setup all the required "Performance" entries.
    hkey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\%s" % (serviceName), 0, win32con.KEY_ALL_ACCESS)
    try:
        subKey = win32api.RegCreateKey(hkey, "Performance")
        try:
            win32api.RegSetValueEx(subKey, "Library", 0, win32con.REG_SZ, dllName)
            win32api.RegSetValueEx(subKey, "Open", 0, win32con.REG_SZ, "OpenPerformanceData")
            win32api.RegSetValueEx(subKey, "Close", 0, win32con.REG_SZ, "ClosePerformanceData")
            win32api.RegSetValueEx(subKey, "Collect", 0, win32con.REG_SZ, "CollectPerformanceData")
        finally:
            win32api.RegCloseKey(subKey)
    finally:
        win32api.RegCloseKey(hkey)
    # Now do the "Lodctr" thang...

    try:
        import perfmon
        path, fname = os.path.split(iniName)
        oldPath = os.getcwd()
        if path:
            os.chdir(path)
        try:
            perfmon.LoadPerfCounterTextStrings("python.exe " + fname)
        finally:
            os.chdir(oldPath)
    except win32api.error, details:
        print "The service was installed OK, but the performance monitor"
        print "data could not be loaded.", details 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:46,代碼來源:win32serviceutil.py


注:本文中的win32api.RegSetValueEx方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。