473,606 Members | 2,825 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resolved: Writing to REG_MULTI_SZ windows registry keys

Sorry to anyone who read this post, but in case it's useful to anyone:
Further experiments reveal that while a tuple comes back if you read a
multi-line string, you set the value using a list (not a tuple). That's
sensible and I don't know why this didn't occur to me before I posted.
Thanks

-----Original Message-----
From: Pat Blair [mailto:pa****** *@prn.com]
Sent: Friday, February 06, 2004 10:10 AM
To: py*********@pyt hon.org
Subject: Writing to REG_MULTI_SZ windows registry keys

Hello. I'm looking for any information I can get about writing values to
keys in the Windows registry when the value type is a multi-string (ie.
REG_MULTI_SZ). When I get the value of a multi-string value using winreg
functions, I get a tuple with tuple[0] being a list, and tuple[1] a number.
If I try to write such a tuple back into a multi-string value, I get the
following exception:

ValueError: Could not convert the data to the specified type.

I haven't been able to find any documents, postings, etc. that deal with
this specifically. My test code is listed below. If any tips can be
offered, they will be much appreciated!

from _winreg import *

import sys

#get the current value of the PendingFileRena meOperations key

def getCurrentValue ():

aReg = ConnectRegistry (

None,

HKEY_LOCAL_MACH INE)

aKey = OpenKey(aReg, r"SYSTEM\Curren tControlSet\Con trol\Session
Manager")

value = QueryValueEx(aK ey, "PendingFileRen ameOperations")

CloseKey(aKey)

return value

#set the value of a test REG_MULTI_SZ key (this key already exists")

def setNewValue(val ue):

aReg = ConnectRegistry (

None,

HKEY_LOCAL_MACH INE)

aKey = OpenKey(aReg, r"SOFTWARE\PRN_ TEST", 0, KEY_WRITE)

SetValueEx(

aKey,

"PendingFileRen ameOperations",

0,

REG_MULTI_SZ,

value

)

CloseKey(aKey)

#the name of some file I want to add to the list

renamedTarget = r"C:\some_file_ i_want_to_delet e.txt"

tuple = getCurrentValue ()

print tuple

list = tuple[0]

list.append(uni code(renamedTar get))

newtuple = (list, tuple[1])

setNewValue(tup le)
Jul 18 '05 #1
0 1974

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4563
by: Pat Blair | last post by:
Hello. I'm looking for any information I can get about writing values to keys in the Windows registry when the value type is a multi-string (ie. REG_MULTI_SZ). When I get the value of a multi-string value using winreg functions, I get a tuple with tuple being a list, and tuple a number. If I try to write such a tuple back into a multi-string value, I get the following exception: ValueError: Could not convert the data to the...
16
2312
by: Paul Rubin | last post by:
As what must be penance for something or other, I'm needing to release a Python app for use under Windows XP. Please be gentle with me since I'm a Un*x weenie and the only thing I've had much practice with under Windows is rebooting it. My app contains three different programs (say alice.py, bob.py, and carol.py) that need to be independently launchable, and a dozen or so other .py files that get imported into those first three. What...
3
17741
by: Bo | last post by:
I am using RegistryKey.GetValue() method to retrieve values from Windows Registry. I don't know how to read type REG_MULTI_SZ into a string array. I have tried string array = (string) RKey.GetValue(name); But it gave me "Invalid Cast Exception". Please provide C# sample code in your reply. Thank you.
2
9047
by: Steve Bernard | last post by:
Hey there, I was wondering if anyone has been able to write reg_multi_sz multi-string values to the registry from VB.NET. All the registry stuff I find from MS can't differentiate different types of strings. I see some examples of VBScript that use the WMI registry provider to write to the registry. Would this be possible to adapt to VB.NET. I'm looking at this script right now:...
5
5064
by: UJ | last post by:
I have a system that has five programs that all communicate with each other via Message Queues. Works well. One program is a watchdog that will make sure the others are up and going. Currently I have it store info it gets from when the programs check in into a DataSet (XML file). Problem is, that file now has to be used by other programs to find out version information (the file is ALWAYS less that 1K.) The record itself is only five fields...
16
1830
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. I'm looking for a way to programmatically retrieve the following if possible: Windows Installation Key or COA from the registry Windows installed applications, like: MS Office 97-2003 MS FrontPage MS Word MS Works
2
4174
by: =?Utf-8?B?SnJ4dHVzZXIx?= | last post by:
I just started using Windows Live OneCare, I had been using Norton, but was unable to fix the problems I was having. I have yet been unsuccessful with OneCare as well. I keep getting the same warning from OneCare, one is for Adware, the other is for a trojan, I clean both, but almost immediatly, I get the same warning? My Windows Defender is also shut down, not by me as I have no idea how to do this(or to turn it back on), but am still...
2
2774
by: =?Utf-8?B?QmFzIFJpam5pZXJzY2U=?= | last post by:
Hello, I'm trying to write: strMulti = new string { @"c:\pagefile.sys", "512", "512" }; with: keyRead.SetValue(regKey, strMulti, regKind); Where reKind is Multistring Unfortunately it ends up int he registry as c:\pagefile.sys
11
7505
by: Unknown Hero | last post by:
Tim Golden wrote: The first link which points to the Python documentation for the _winreg module I already checked, even before coming here. I am wondering how I should do the loop I need (go through HKEY_LOCAL_MACHINE and read one subkey at a time, if it contains this 'foo' then change it into 'moo'). As I already said, I am by no means an expert in Python (heck, I learned the basics only a month ago). However, I am willing to learn.
0
8045
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7981
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8127
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6803
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5994
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5470
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1315
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.