|
You can't directly change the type or the name of the key. In order to do this, you will need to create a new key with the correct name and type, copy the data from the old key, and then delete the old key.
|
|
|
|
|
Hi Scott,
Thanks for the reply! My task is not to change/edit the key, but the Name/Type/Data of the key. Its like creating how to create new string value, DWORD value, Binary Value etc.
D
|
|
|
|
|
Dino2Dino wrote: My task is not to change/edit the key, but the Name/Type/Data of the key
Right, I understood that. The problem is that once a key is created, it's data type cannot be changed and, as far as I know, it's name cannot be changed either. In order to make those types of changes, you must create a new key, copy the data, and then delete the old key. There may be some underlying Win32 APIs you could call using P/Invoke, but I don't know of any off hand.
|
|
|
|
|
Thanks a lot Scott! I will check on the APIs.
Thanks again!
D
|
|
|
|
|
Scott is correct. There are not API functions to rename a key or value or change a value type. If you want to rename a key or value, you have to create the new key or value with the correct name and copy the data from the old key/value to the new one, then delete the old one.
The same is true if you want to change the value's type. In this case, though, you can't create a value with the same name, so you have to read the data into a buffer, delete the value, then create the name value with the same name, but different type, then CONVERT THE DATA to the new type and write the new value with it. That conversion is going to give you a headache. Some types just don't convert to others.
|
|
|
|
|
Hello,
Thanks for the answer.
However I am afraid I didnt understand it completely.
If HKEY_CURRENT_CONFIG\Software Has
Key Name Type Data
Font LogPixels REG_DWORD 0X00000
In this case, My task is to edit the Name LogPixels or Type REG_DWORD or Data0X00(This can be done through SetValue).
AFAIU, If I have the Name/Type/Data into some buffer, I can delete the Key(Font) and create it again with new name.
However, I didnt understand, what if I wanted to edit LogPixels? I cannot use DeleteSubKey or CreateSubkey to modify the Name Field. How can I create the new Name?
Please Clarify!!!
D
|
|
|
|
|
In the registry, KEYS are the containers that hold VALUEs. In RegEdit, all the keys are the little yellow folders in the tree on the left. All the values under the selected key show up on the right.
We've described it as simply as possible. There is no such thing as renaming a key or value.
It's no different that if you were creating a new Value from scratch. You cache the data, delete the old value, create the new value with the new name and give it the cached data using SetValue().
|
|
|
|
|
Hii Dave,
Thanks for the clarification!Appreciate your help!
D
|
|
|
|
|
I answered this question last week and gave you the exact same information that the replies in this thread say. Did you even try?
|
|
|
|
|
Hey Chris!!
If you have read my first post on the top, I mentioned I am re-posting as I have used wrong names in my last post. Apparently, my idea was to avoid the confusion.
I wldnt have asked for a clarification, if I havent tried. Please note that I have posted after trying myself and not finding an answer.
Anyways, Thanks for your concern!
D
|
|
|
|
|
Looking to purchase a stable magnifying glass control for a C# winforms app. (I would also like to consider one for web, further along.)
Being able to annotate magnified items would be even better.... :->
|
|
|
|
|
Did you check out this[^]?
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
can somebody please tell me what is wrong with the code below i am trying to conver some single page tif's images to group 4 compression the original format was LZW
string dir = args.Length>1 ? args[0]: System.IO.Directory.GetCurrentDirectory();
dir = @"C:\Documents and Settings\caiena\Desktop\mail out DEQ\form";
string outdir= args.Length>2 ? args[1] : dir+"\\processed";
if(!System.IO.Directory.Exists(outdir))
System.IO.Directory.CreateDirectory(outdir);
string[] files = System.IO.Directory.GetFiles(dir, "*.tif");
System.Console.WriteLine("input dir {0}", dir);
System.Console.WriteLine("Processed dir {0}", outdir);
System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.Compression;
EncoderParameters ep = new EncoderParameters(1);
ImageCodecInfo info = GetEncoderInfo("image/tiff");
ep.Param[0] = new EncoderParameter(enc, (long) System.Drawing.Imaging.EncoderValue.CompressionCCITT4);
foreach (string file in files)
{
System.IO.FileInfo fi = new System.IO.FileInfo(file);
using (System.Drawing.Image img = System.Drawing.Image.FromFile(fi.FullName))
{
System.Console.WriteLine("converting file {0}", outdir + fi.Name);
img.Save(outdir+ fi.Name, info, ep);
}
}
-- modified at 16:53 Monday 8th October, 2007
Thanks,
Chad Aiena
|
|
|
|
|
There is some vital information missing in your post.
Why do you think that there is something wrong with the code? Do you get an error message? Doesn't it do what you expect, and if so, what do you expect, and how does that differ from what you get?
---
single minded; short sighted; long gone;
|
|
|
|
|
i get an error saying invalid parameter on the save line
Thanks,
Chad Aiena
|
|
|
|
|
Can anyone tell me how to compare two objects by testing if they are the same type?
I know this doesn't work but I wish it would work like this:
private bool ActivateForm(Form form)
{
bool formIsOpen = false;
//loop through child forms to see if the form is already open
foreach (Form childForm in this.MdiChildren)
{
//if the childForm is the parameter type, activate it and break the loop
if (childForm.Type == form.Type)
{
childForm.Activate();
formIsOpen = true;
break;
}
}
return formIsOpen;
}
Lester
http://www.lestersconyers.com
|
|
|
|
|
lsconyer wrote: I know this doesn't work but I wish it would work like this:
You know what I wish? I wish it would work like this:
Abbra Kadabra *waving hands*
But I guess since it doesn't I will continue to Read Documentation and study Best Practices and Software Design Patterns etc.
|
|
|
|
|
lsconyer wrote: if (childForm.Type == form.Type)
if (childForm is Form) will succeed when childForm is a Form, which it is due
to the foreach loop.
if (childForm is Form1) will only succeed for those childForms that are also Form1,
derived from Form.
And also have a look at the "as" keyword!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
*cough* use GetType() * cough *. Could I suggest that you also look at converting this to a generic method:
private bool ActivateForm<T>(T form) where T : Form
{
bool isOpen = false;
int i = 0;
do
{
if (MdiChildren[i].GetType() == typeof(T))
{
MdiChildren[i].Activate();
isOpen = true;
}
} while (!isOpen && i++ < this.MdiChildren.Count);
return isOpen
} I you really want to learn some more advanced .NET, you could look at modifying this to use anonymous methods.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Try using the GetType() method
instead of the Type keyword in your code
|
|
|
|
|
Hi guys,
I am totally stuck on this one, please help!!! I just migrated my application from VS2003 to VS2005 and when I try to open a folder browser dialog box it gives me the following message:
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
I have tried adding the stathreadattribute, did research, etc but no luck.
PLEASE HELP!!!!!
Sameer
|
|
|
|
|
Are you calling the FolderBrowseDialog from a different thread? Also, does your Main function look like below?
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
HI,
Is there a way to Wrap a Project i created with setup(or installer)
thnks
kobkob
|
|
|
|
|
If you've got Visual Studio installed, there's an installer project present there.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|