Python _winreg.REG_DWORD Examples

The following are 14 code examples of _winreg.REG_DWORD(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module _winreg , or try the search function .
Example #1
Source File: registry_obj.py    From Fastir_Collector with GNU General Public License v3.0 6 votes vote down vote up
def get_str_type(reg_type):
    if reg_type == _winreg.REG_BINARY:
        return "REG_BINARY"
    elif reg_type == _winreg.REG_DWORD:
        return "REG_DWORD"
    elif reg_type == _winreg.REG_DWORD_BIG_ENDIAN:
        return "REG_DWORD_BIG_ENDIAN"
    elif reg_type == _winreg.REG_DWORD_LITTLE_ENDIAN:
        return "REG_DWORD_LITTLE_ENDIAN"
    elif reg_type == _winreg.REG_EXPAND_SZ:
        return "REG_EXPAND_SZ"
    elif reg_type == _winreg.REG_LINK:
        return "REG_LINK"
    elif reg_type == _winreg.REG_MULTI_SZ:
        return "REG_MULTI_SZ"
    elif reg_type == _winreg.REG_SZ:
        return "REG_SZ" 
Example #2
Source File: registry_obj.py    From Fastir_Collector with GNU General Public License v3.0 6 votes vote down vote up
def get_data(self):
        reg_type = self.value.get_type()
        if reg_type == _winreg.REG_DWORD:
            return self.value.get_data_as_integer()
        elif reg_type == _winreg.REG_DWORD_LITTLE_ENDIAN:
            return self.value.get_data_as_integer()
        elif reg_type == _winreg.REG_DWORD_BIG_ENDIAN:
            return self.value.get_data_as_integer()
        elif reg_type == _winreg.REG_SZ:
            return self.value.get_data_as_string()
        elif reg_type == _winreg.REG_EXPAND_SZ:
            return self.value.get_data_as_string()
        elif reg_type == _winreg.REG_LINK:
            return self.value.get_data_as_string()

        return self.value.get_data() 
Example #3
Source File: Install.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
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" 
Example #4
Source File: excelAddin.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def RegisterAddin(klass):
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins")
    subkey = _winreg.CreateKey(key, klass._reg_progid_)
    _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0)
    _winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3)
    _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "Excel Addin")
    _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "A Simple Excel Addin") 
Example #5
Source File: outlookAddin.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def RegisterAddin(klass):
    import _winreg
    key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins")
    subkey = _winreg.CreateKey(key, klass._reg_progid_)
    _winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0)
    _winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3)
    _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, klass._reg_progid_)
    _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, klass._reg_progid_) 
Example #6
Source File: Install.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def AddOrRemoveHIDKeys(isInstall):
    HID_SUB_KEY = "SYSTEM\\CurrentControlSet\\Services\\HidIr\\Remotes\\745a17a0-74d3-11d0-b6fe-00a0c90f57d"
    ValuesToCheck = ['a','b']
    for a in ValuesToCheck:
        tmpkey = HID_SUB_KEY+a
        try:
            key = reg.OpenKey(reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_ALL_ACCESS)
            for i in xrange(4):
                valueName = 'CodeSetNum%i' % i
                if isInstall:
                    reg.DeleteValue(key, valueName)
                else:
                    reg.SetValueEx(key, valueName, 0, reg.REG_DWORD, i + 1)
        except WindowsError:
            continue 
Example #7
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Finish(self):
        """
        This will be called inside the thread when it finishes. It will even
        be called if the thread exits through an exception.
        """

        self.abort = True
        self.lock.acquire()

        if self.dll:
            self.dll.IR_Close(self.hwnd, 0);

        #print "Irremote is stopped"

        if self.timerInit :
            self.timerInit.cancel()
            #print "Init aborted"

        if self.hwnd:
            windll.user32.KillTimer(self.hwnd, 1)
            DestroyWindow(self.hwnd)
            UnregisterClass(self.wc.lpszClassName, self.hinst)


        if self.defaultPollTime != -1 :

            regHandle = _winreg.OpenKey(
                            _winreg.HKEY_LOCAL_MACHINE,
                            'SOFTWARE\hauppauge\IR',
                            0,
                            _winreg.KEY_WRITE | _winreg.KEY_READ
            )

            _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.defaultPollTime) )

            _winreg.CloseKey( regHandle )

        self.lock.release() 
Example #8
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def SetHidState(self, disableHid):
        """
        Sets the HID registry values. Will raise WindowsError if not
        successful.
        """
        key = reg.OpenKey(
            reg.HKEY_LOCAL_MACHINE, HID_SUB_KEY, 0, reg.KEY_ALL_ACCESS
        )
        for i in xrange(4):
            valueName = 'CodeSetNum%i' % i
            if disableHid:
                reg.DeleteValue(key, valueName)
            else:
                reg.SetValueEx(key, valueName, 0, reg.REG_DWORD, i + 1) 
Example #9
Source File: support.py    From CIS-ESP with Apache License 2.0 5 votes vote down vote up
def printReg(hive, value, type, fullkey, outFile, objRegistry, key=None):
	if not key:
		key = fullkey
		
	if type == _winreg.REG_SZ:
		result,reg_value = objRegistry.GetStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
	elif type == _winreg.REG_EXPAND_SZ:
		result,reg_value = objRegistry.GetExpandedStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
	elif type == _winreg.REG_BINARY:
		result,reg_value = objRegistry.GetBinaryValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
		r_value = ""
		if result == 0:
			for decimal in reg_value:
				r_value += "%0.2X" % decimal
		reg_value = "[BINARY DATA] " + r_value
	elif type == _winreg.REG_DWORD:
		result,reg_value = objRegistry.GetDWORDValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
	elif type == _winreg.REG_MULTI_SZ:
		result,reg_value = objRegistry.GetMultiStringValue(hDefKey=hive,sSubKeyName=fullkey,sValueName=value)
	else:
		reg_value = "OTHER_TYPE"
	
	if reg_value == None:
		reg_value = "NULL"
	
	reg_value = convert_to_string(reg_value)
	outFile.write(key.replace(","," ") + "," + value.replace(","," ") + "," + reg_value.replace(","," ") + "\n")

#convert windows datetime to nicely formatted date 
Example #10
Source File: resolver.py    From luscan-devel with GNU General Public License v2.0 4 votes vote down vote up
def _win32_is_nic_enabled(self, lm, guid, interface_key):
         # Look in the Windows Registry to determine whether the network
         # interface corresponding to the given guid is enabled.
         #
         # (Code contributed by Paul Marks, thanks!)
         #
         try:
             # This hard-coded location seems to be consistent, at least
             # from Windows 2000 through Vista.
             connection_key = _winreg.OpenKey(
                 lm,
                 r'SYSTEM\CurrentControlSet\Control\Network'
                 r'\{4D36E972-E325-11CE-BFC1-08002BE10318}'
                 r'\%s\Connection' % guid)

             try:
                 # The PnpInstanceID points to a key inside Enum
                 (pnp_id, ttype) = _winreg.QueryValueEx(
                     connection_key, 'PnpInstanceID')

                 if ttype != _winreg.REG_SZ:
                     raise ValueError

                 device_key = _winreg.OpenKey(
                     lm, r'SYSTEM\CurrentControlSet\Enum\%s' % pnp_id)

                 try:
                     # Get ConfigFlags for this device
                     (flags, ttype) = _winreg.QueryValueEx(
                         device_key, 'ConfigFlags')

                     if ttype != _winreg.REG_DWORD:
                         raise ValueError

                     # Based on experimentation, bit 0x1 indicates that the
                     # device is disabled.
                     return not (flags & 0x1)

                 finally:
                     device_key.Close()
             finally:
                 connection_key.Close()
         except (EnvironmentError, ValueError):
             # Pre-vista, enabled interfaces seem to have a non-empty
             # NTEContextList; this was how dnspython detected enabled
             # nics before the code above was contributed.  We've retained
             # the old method since we don't know if the code above works
             # on Windows 95/98/ME.
             try:
                 (nte, ttype) = _winreg.QueryValueEx(interface_key,
                                                     'NTEContextList')
                 return nte is not None
             except WindowsError:
                 return False 
Example #11
Source File: resolver.py    From Cloudmare with GNU General Public License v3.0 4 votes vote down vote up
def _win32_is_nic_enabled(self, lm, guid, interface_key):
        # Look in the Windows Registry to determine whether the network
        # interface corresponding to the given guid is enabled.
        #
        # (Code contributed by Paul Marks, thanks!)
        #
        try:
            # This hard-coded location seems to be consistent, at least
            # from Windows 2000 through Vista.
            connection_key = _winreg.OpenKey(
                lm,
                r'SYSTEM\CurrentControlSet\Control\Network'
                r'\{4D36E972-E325-11CE-BFC1-08002BE10318}'
                r'\%s\Connection' % guid)

            try:
                # The PnpInstanceID points to a key inside Enum
                (pnp_id, ttype) = _winreg.QueryValueEx(
                    connection_key, 'PnpInstanceID')

                if ttype != _winreg.REG_SZ:
                    raise ValueError

                device_key = _winreg.OpenKey(
                    lm, r'SYSTEM\CurrentControlSet\Enum\%s' % pnp_id)

                try:
                    # Get ConfigFlags for this device
                    (flags, ttype) = _winreg.QueryValueEx(
                        device_key, 'ConfigFlags')

                    if ttype != _winreg.REG_DWORD:
                        raise ValueError

                    # Based on experimentation, bit 0x1 indicates that the
                    # device is disabled.
                    return not (flags & 0x1)

                finally:
                    device_key.Close()
            finally:
                connection_key.Close()
        except (EnvironmentError, ValueError):
            # Pre-vista, enabled interfaces seem to have a non-empty
            # NTEContextList; this was how dnspython detected enabled
            # nics before the code above was contributed.  We've retained
            # the old method since we don't know if the code above works
            # on Windows 95/98/ME.
            try:
                (nte, ttype) = _winreg.QueryValueEx(interface_key,
                                                    'NTEContextList')
                return nte is not None
            except WindowsError:
                return False 
Example #12
Source File: resolver.py    From arissploit with GNU General Public License v3.0 4 votes vote down vote up
def _win32_is_nic_enabled(self, lm, guid, interface_key):
        # Look in the Windows Registry to determine whether the network
        # interface corresponding to the given guid is enabled.
        #
        # (Code contributed by Paul Marks, thanks!)
        #
        try:
            # This hard-coded location seems to be consistent, at least
            # from Windows 2000 through Vista.
            connection_key = _winreg.OpenKey(
                lm,
                r'SYSTEM\CurrentControlSet\Control\Network'
                r'\{4D36E972-E325-11CE-BFC1-08002BE10318}'
                r'\%s\Connection' % guid)

            try:
                # The PnpInstanceID points to a key inside Enum
                (pnp_id, ttype) = _winreg.QueryValueEx(
                    connection_key, 'PnpInstanceID')

                if ttype != _winreg.REG_SZ:
                    raise ValueError

                device_key = _winreg.OpenKey(
                    lm, r'SYSTEM\CurrentControlSet\Enum\%s' % pnp_id)

                try:
                    # Get ConfigFlags for this device
                    (flags, ttype) = _winreg.QueryValueEx(
                        device_key, 'ConfigFlags')

                    if ttype != _winreg.REG_DWORD:
                        raise ValueError

                    # Based on experimentation, bit 0x1 indicates that the
                    # device is disabled.
                    return not (flags & 0x1)

                finally:
                    device_key.Close()
            finally:
                connection_key.Close()
        except (EnvironmentError, ValueError):
            # Pre-vista, enabled interfaces seem to have a non-empty
            # NTEContextList; this was how dnspython detected enabled
            # nics before the code above was contributed.  We've retained
            # the old method since we don't know if the code above works
            # on Windows 95/98/ME.
            try:
                (nte, ttype) = _winreg.QueryValueEx(interface_key,
                                                    'NTEContextList')
                return nte is not None
            except WindowsError:
                return False 
Example #13
Source File: resolver.py    From Tautulli with GNU General Public License v3.0 4 votes vote down vote up
def _win32_is_nic_enabled(self, lm, guid, interface_key):
        # Look in the Windows Registry to determine whether the network
        # interface corresponding to the given guid is enabled.
        #
        # (Code contributed by Paul Marks, thanks!)
        #
        try:
            # This hard-coded location seems to be consistent, at least
            # from Windows 2000 through Vista.
            connection_key = _winreg.OpenKey(
                lm,
                r'SYSTEM\CurrentControlSet\Control\Network'
                r'\{4D36E972-E325-11CE-BFC1-08002BE10318}'
                r'\%s\Connection' % guid)

            try:
                # The PnpInstanceID points to a key inside Enum
                (pnp_id, ttype) = _winreg.QueryValueEx(
                    connection_key, 'PnpInstanceID')

                if ttype != _winreg.REG_SZ:
                    raise ValueError

                device_key = _winreg.OpenKey(
                    lm, r'SYSTEM\CurrentControlSet\Enum\%s' % pnp_id)

                try:
                    # Get ConfigFlags for this device
                    (flags, ttype) = _winreg.QueryValueEx(
                        device_key, 'ConfigFlags')

                    if ttype != _winreg.REG_DWORD:
                        raise ValueError

                    # Based on experimentation, bit 0x1 indicates that the
                    # device is disabled.
                    return not (flags & 0x1)

                finally:
                    device_key.Close()
            finally:
                connection_key.Close()
        except (EnvironmentError, ValueError):
            # Pre-vista, enabled interfaces seem to have a non-empty
            # NTEContextList; this was how dnspython detected enabled
            # nics before the code above was contributed.  We've retained
            # the old method since we don't know if the code above works
            # on Windows 95/98/ME.
            try:
                (nte, ttype) = _winreg.QueryValueEx(interface_key,
                                                    'NTEContextList')
                return nte is not None
            except WindowsError:
                return False 
Example #14
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def PostInit( self ) :

        self.lock.acquire()
        if self.abort :
            self.lock.release()
            return
        self.timerInit = Timer( 60.0, self.OnPostInitTimeOut)        # Init timeout timer
        self.timerInit.start()

        returnVal = False

        if ( not self.useDefaultPollTime ) :

            regHandle = _winreg.OpenKey(
                            _winreg.HKEY_LOCAL_MACHINE,
                            'SOFTWARE\hauppauge\IR',
                            0,
                            _winreg.KEY_WRITE | _winreg.KEY_READ
            )

            self.defaultPollTime = int( _winreg.QueryValueEx(regHandle, 'PollRate')[0] )

            _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.pollTime) )

            returnVal = self.IR_Open(self.hwnd, 0, 0, 0);

            _winreg.SetValueEx( regHandle, 'PollRate', 0, _winreg.REG_DWORD, int(self.defaultPollTime) )

            _winreg.CloseKey( regHandle )

            self.defaultPollTime = -1

        else :
            returnVal = self.IR_Open(self.hwnd, 0, 0, 0);

        self.timerInit.cancel()

        if not self.initTerminated :

            if not returnVal and not self.initTerminated :
                self.plugin.PrintError("Couldn't start the Hauppauge remote control")
                self.Stop()
                self.plugin.TriggerEvent("InitError")
            else :
                #print "Irremote is started"
                pass

        del self.timerInit
        self.timerInit = None
        self.lock.release()