473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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*********@python.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 PendingFileRenameOperations key

def getCurrentValue():

aReg = ConnectRegistry(

None,

HKEY_LOCAL_MACHINE)

aKey = OpenKey(aReg, r"SYSTEM\CurrentControlSet\Control\Session
Manager")

value = QueryValueEx(aKey, "PendingFileRenameOperations")

CloseKey(aKey)

return value

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

def setNewValue(value):

aReg = ConnectRegistry(

None,

HKEY_LOCAL_MACHINE)

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

SetValueEx(

aKey,

"PendingFileRenameOperations",

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_delete.txt"

tuple = getCurrentValue()

print tuple

list = tuple[0]

list.append(unicode(renamedTarget))

newtuple = (list, tuple[1])

setNewValue(tuple)
Jul 18 '05 #1
0 1954

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

Similar topics

1
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...
16
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...
3
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)...
2
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...
5
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...
16
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...
2
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...
2
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...
11
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
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...

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.