CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Dec 2008
    Posts
    18

    checking for a value in the registry

    I have my code it works i get back the registry value but what i want to do is

    check to see if its empty if its empty ok to install program

    if not would you like to remove the registry value?

    here is my code it dosnt work if i put somthing in the reg value and run my program it dosnt check
    if i remove the data from that value same results.

    how can i set this up below is my code

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Win32;
    
    
    namespace regMod
    {
        class Program
        {
            static void Main(string[] args)
            {
                 
    
                    RegistryKey MyReg = Registry.LocalMachine.OpenSubKey
                        ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\setup.exe", true);
    
                    try
                    {
    
                        string IsVal = (string)MyReg.GetValue("Default", "");
    
                        Console.WriteLine(MyReg.GetValue(IsVal).ToString());
    
                        if (IsVal == null)
                        {
    
                            Console.WriteLine("ok to install");
                        }
                        else
                        {
                            Console.WriteLine("Remove key value data?");
    
                        }
                    }



    thank you for your time
    -summey
    Last edited by summey; April 26th, 2009 at 08:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured