Results 1 to 13 of 13

Thread: Urgent! Registry update!

  1. #1

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Exclamation Urgent! Registry update!

    Hy i have a litle problem. I want to make a program for a game to modify some options from registry. I have a text box for User Id(when i type the user name and press save; its update the registry). In the registry its stored in : HKEY_CURRENT_USER\Software\game\play\Config with string value ID with value data the name of user. For the sound and music its on/off and the registry is HKEY_CURRENT_USER\Software\game\play\Config with DWORD value with data value 0 or 1 (on/off). how can i do this ? Thenx
    Attached Files Attached Files

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Urgent! Registry update!

    VB Code:
    1. Private Function Registry_Read(Key_Path, Key_Name) As Variant
    2.    
    3.     On Error Resume Next
    4.    
    5.     Dim Registry As Object
    6.    
    7.     Set Registry = CreateObject("WScript.Shell")
    8.    
    9.     Registry_Read = Registry.RegRead(Key_Path & Key_Name)
    10.    
    11. End Function
    12.  
    13.  
    14. Private Sub Registry_Write(Key_Path As String, Key_Name As String, Key_Value As Variant, Optional Key_Type As String)
    15.    
    16.     On Error Resume Next
    17.    
    18.     'Key Type list (Use within string, ex. "
    19.     '     REG_DWORD")
    20.     '----------------
    21.    
    22.     'REG_BINARY - This type stores the value
    23.     '     as raw binary data. Most hardware compon
    24.     '     ent information is stored as binary data
    25.     '     , and can be displayed in an editor in h
    26.     '     exadecimal format.
    27.     'REG_DWORD - This type represents the da
    28.     '     ta by a four byte number and is commonly
    29.     '     used for boolean values, such as "0" is
    30.     '     disabled and "1" is enabled. Additionall
    31.     '     y many parameters for device driver and
    32.     '     services are this type, and can be displ
    33.     '     ayed in REGEDT32 in binary, hexadecimal
    34.     '     and decimal format, or in REGEDIT in hex
    35.     '     adecimal and decimal format.
    36.     'REG_EXPAND_SZ - This type is an expanda
    37.     '     ble data string that is string containin
    38.     '     g a variable to be replaced when called
    39.     '     by an application. For example, for the
    40.     '     following value, the string "%SystemRoot
    41.     '     %" will replaced by the actual location
    42.     '     of the directory containing the Windows
    43.     '     NT system files. (This type is only avai
    44.     '     lable using an advanced registry editor
    45.     '     such as REGEDT32)
    46.     'REG_MULTI_SZ - This type is a multiple
    47.     '     string used to represent values that con
    48.     '     tain lists or multiple values, each entr
    49.     '     y is separated by a NULL character. (Thi
    50.     '     s type is only available using an advanc
    51.     '     ed registry editor such as REGEDT32)
    52.     'REG_SZ - This type is a standard string
    53.     '     , used to represent human readable text
    54.     '     values.
    55.    
    56.     'Other data types not available through
    57.     '     the standard registry editors include:
    58.    
    59.     'REG_DWORD_LITTLE_ENDIAN - A 32-bit numb
    60.     '     er in little-endian format.
    61.     'REG_DWORD_BIG_ENDIAN - A 32-bit number
    62.     '     in big-endian format.
    63.     'REG_LINK - A Unicode symbolic link. Use
    64.     '     d internally; applications should not us
    65.     '     e this type.
    66.     'REG_NONE - No defined value type.
    67.     'REG_QWORD - A 64-bit number.
    68.     'REG_QWORD_LITTLE_ENDIAN - A 64-bit numb
    69.     '     er in little-endian format.
    70.     'REG_RESOURCE_LIST - A device-driver res
    71.     '     ource list.
    72.     Dim Registry As Object
    73.    
    74.     Dim Registry_Value As Variant
    75.    
    76.     Set Registry = CreateObject("WScript.Shell")
    77.    
    78.     Registry_Value = Registry_Read(Key_Path, Key_Name)
    79.    
    80.    
    81.    
    82.     If Key_Type = "" Then
    83.        
    84.         'REG_SZ is the default.
    85.        
    86.         Registry.RegWrite Key_Path & Key_Name, Key_Value
    87.        
    88.     Else
    89.        
    90.         Registry.RegWrite Key_Path & Key_Name, Key_Value, Key_Type
    91.        
    92.     End If
    93.    
    94. End Sub
    95.  
    96.  
    97. Private Sub Form_Activate()
    98.     'This is only an example of a registry entry.
    99.     MsgBox Registry_Read("HKEY_LOCAL_MACHINEMsgBox Registry_Read("HKEY_Local_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")\Software\Microsoft\Internet Explorer\", "W2kVersion")
    100.     Registry_Write "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\", "Test", 1, "REG_DWORD"
    101. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    ok i learn some things from your code .. but how to do theat my text box display a value data from a value string?

  4. #4

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    anyoane?

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Urgent! Registry update!

    Do display this key, use this:

    VB Code:
    1. Text1.text = Registry_Read("HKEY_LOCAL_MACHINEMsgBox Registry_Read("HKEY_Local_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")\Software\Microsoft\Internet Explorer\", "W2kVersion")

  6. #6

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    it give an error "Syntax error"

  7. #7

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    ok i resolve theat but now i dont know how to write from text box to registry ? Thenx

  8. #8
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Urgent! Registry update!

    Oh. Textboxes don't like variants. The read is too generic. Try this:
    VB Code:
    1. Text1.text = Cstr(Registry_Read("HKEY_Local_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion"))

    This is the correct code:
    Registry_Read("HKEY_Local_MACHINE\Software\Microsoft\Internet Explorer\", "W2kVersion")
    The result will be converted into a string. That should work. Otherwise, you'd have to change the read to return a string, which might not work in all cases.

    EDIT: Oops just notice that it got copied wrong. It should work right the first way, if you remove the duplicate info.
    Last edited by dglienna; Jan 24th, 2006 at 03:30 PM.

  9. #9

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    ok i see but now i dont know how to write from text box to registry ? if you can tell me pls.. Thenx

  10. #10
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Urgent! Registry update!

    You would need three textboxes. One for the Hive, one for the section, and one for the actual value that you wanted to write.

    Edit: Hive is more appropriate.
    Last edited by dglienna; Jan 24th, 2006 at 05:08 PM.

  11. #11

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    ok say me only how to use the text box to write in registry for one of that value key

  12. #12
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Urgent! Registry update!

    The last line explains it perfectly..

    Registry_Write "HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\RUN\", "Test", text1.text, "REG_DWORD"

  13. #13

    Thread Starter
    Addicted Member RoYeti's Avatar
    Join Date
    Dec 2005
    Posts
    165

    Re: Urgent! Registry update!

    Yes it was but i didnt know where to put the text1.text .Now i know Thenx

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