Results 1 to 3 of 3

Thread: FYI: using the registry class

  1. #1

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327

    FYI: using the registry class

    This is partially FYI and partially in response to Phil's question in the VB forum...
    Using the registry, if you've looked into it, is largely undocumented. Hopefully the following code will save you some time:
    PHP Code:
    // The instance of the Registry key class is created by the 
    // static method OpenSubKey in the Registry class
    // The second boolean parameter opens the key for editing if true
    RegistryKey RegTest Registry.LocalMachine.OpenSubKey("SOFTWARE\\TESTKEY",true);

    // This results in a DWORD key
    int  testValue1 50 
    // This results in a multi line string entry
    string[] testValue2 = new String[3] {"Eat","my","shorts"};
    // This results in a byte field (a non-array will be a simple byte key)
    byte[] testValue3 = new byte[3] {1,2,3};
    // Almost any other type results in a string, REG_SZ

    // Creates a new key and value under the current subkey
    RegTest.SetValue("TestValue1",testValue1) ;
    RegTest.SetValue("TestValue2",testValue2) ;
    RegTest.SetValue("TestValue3",testValue3) ; 
    -scott
    he he he

  2. #2
    Member
    Join Date
    Nov 2001
    Posts
    52
    I have worked out the REG_SZ and REG_DWORD but I cannot workout how to get REG_BINARY and REG_MULTI_SZ to work. Do you have any code to get this to work for VB.NET?

  3. #3

    Thread Starter
    Hyperactive Member Scott Penner's Avatar
    Join Date
    Dec 2000
    Location
    Mountain View
    Posts
    327
    The sample code I wrote originally works and demonstrates all the major reg types.

    For binary, you are passing a byte array. For reg_multi_sz you just pass in an array of strings.

    -hope that helps
    -scott
    he he he

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