Re: get RegistryKey's parent?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi, thanks for the reminder about config files.
Its funny, I usually write ASP.NET app, and
am really writing my first significant Win app
since moving to the .NET platform.
I use .configs all the time in ASP, but completely
forgot about them for Windows.

Thanks for the "duh" reminder!


"Tiberiu Covaci" <tibi@xxxxxxxxxxxxx> wrote in message
news:e3ZVkHzwFHA.2656@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Arthur,
>
> Beside LocalMachine you, have several other members in the
> Microsoft.Win32.Registry class, which will help you solve your problem...
> If you are considering creating a new application, I advice you though not
> to use registry, but configuration files, as registry is considered
> "obsolete", and only Win32 has it, and will make your application NOT
> "platform independent", even though the only platform that .NET is
> available for is Win32.
>
> Tibi
>
>
> "Arthur Dent" <hitchhikersguideto-news@xxxxxxxxx> wrote in message
> news:O1R729vwFHA.3856@xxxxxxxxxxxxxxxxxxxxxxx
>>I think i just sent an empty reply ... apologies.
>>
>> Thanks for the ideas and info.
>>
>> That would only work for HKLM though, no?
>> The app data info is under HKCU, and it would
>> definitely be preferable to have something that is
>> not tied to any particular hive.
>>
>> I think i should be able to work out something
>> for my immediate needs though along these lines.
>>
>> Thanks.
>>
>> "Nick Hertl" <nhertl@xxxxxxxxx> wrote in message
>> news:1127781925.690450.47900@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>> I'm not sure if this is exposed by the Win32 APIs even, but here is a
>>> little C# app that does it for you:
>>>
>>> using System;
>>> using Microsoft.Win32;
>>>
>>> class MainClass
>>> {
>>> public static void Main()
>>> {
>>> string mainkeyname = @"SOFTWARE\Microsoft";
>>> RegistryKey rk = Registry.LocalMachine.OpenSubKey(mainkeyname);
>>> if(rk != null)
>>> {
>>> try
>>> {
>>> RegistryKey parent = GetParent(rk);
>>> try
>>> {
>>> Console.WriteLine("Got it: {0}", parent.Name);
>>> // do stuff here
>>> }
>>> finally
>>> {
>>> parent.Close();
>>> }
>>> }
>>> finally
>>> {
>>> rk.Close();
>>> }
>>> }
>>> }
>>>
>>> private static RegistryKey GetParent(RegistryKey value)
>>> {
>>> int first = value.Name.IndexOf(@"\");
>>> int last = value.Name.LastIndexOf(@"\");
>>> string parentname = value.Name.Substring(first+1, last-first);
>>> RegistryKey parent = Registry.LocalMachine.OpenSubKey(parentname);
>>> if(parent != null)
>>> {
>>> return parent;
>>> }
>>> return null;
>>> }
>>> }
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: DOS, how long?
    ... >> an app from the OS, and I'm saying that the cwd WHEN THAT APP ... > I thought we were talking about programs finding their config files. ... One is left with the Registry, ... But when I can, in a couple hours, create sophisticated charts and ...
    (comp.programming)
  • Re: Lost window manager and gnome-panel
    ... I never copied my old Gnome config ... what the Gnome config files were. ... if some app prompts you to ... reboot and something goes wrong after you reboot, ...
    (Debian-User)
  • Re: LDAP integration
    ... use separate config files for each and every option it supports. ... What is the logical difference between using a directory structure vs. an LDAP server containing essentially the same information? ... "dozens of config files" just equates to dozens of ldap entries. ... You could write a similarly "friendly" app that managed your conrfiguration files, and you won't need any LDAP expertise to use it. ...
    (freebsd-hackers)
  • Re: LDAP integration
    ... config file to get inetd configured correctly. ... use separate config files for each and every option it supports. ... What is wrong with 1 editable text file per app? ... The nicest thing about FreeBSD is /etc/rc.conf, a single configuration ...
    (freebsd-hackers)
  • Re: no option to "dismiss all" reminders
    ... Clicking this URL should allow the script to be loaded into script Editor: ... and all old non-recurring events should have their reminder turned off. ... Hopefully this will reduce the load on the notifications app and allow you to deal with the recurring events in a more rational manner. ... Both these scripts will only work in Entourage 11.2.x. ...
    (microsoft.public.mac.office.entourage)