Results 1 to 7 of 7

Thread: Use REG_DWORD

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    Use REG_DWORD

    How would I read/write a REG_DWORD from the registry? I have a value I want to toggle between 0 and 1. The sample at www.vbapi.com only deals with REG_SZ (strings).
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    Megatron
    Guest
    REG_SZ is a constant for 0, so just change it to 4 (the value of REG_DWORD).

  3. #3
    Junior Member
    Join Date
    Nov 2000
    Location
    Kalpetta,Wayanad,Kerala,india
    Posts
    25

    Wink REG_DWORD

    You can write ,read ,delete REG_DWORD,REG_BINARY etc in the registry
    with out any API calls ,using "WINDOWS SCRIPTING HOST"
    try the following code its very simple
    in aform put three command buttons and add the following code

    Private Sub Command1_Click()
    'WRITE INTO WINDOWS REGISTRY
    '----------------------------
    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("wscript.shell")
    b.RegWrite "HKCU\VBCODE.COM\Value", "HELLO WORLD"
    b.RegWrite "HKCU\VBCODE.COM\Value1", 0, "REG_DWORD"
    b.RegWrite "HKCU\VBCODE.COM\Value2", 0, "REG_SZ"
    b.RegWrite "HKCU\VBCODE.COM\Value3", 0, "REG_BINARY"

    End Sub

    Private Sub Command2_Click()
    'READ FROM WINDOWS REGISTRY
    '.........................
    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("wscript.shell")
    R = b.RegRead("HKCU\VBCODE.COM\Value")
    Form1.Caption = R
    End Sub

    Private Sub Command3_Click()
    'DELETE VALUES FROM WINDOWS REGISTRY
    '-----------------------------------
    Dim b As Object
    On Error Resume Next
    Set b = CreateObject("Wscript.Shell")
    b.RegDelete "HKCU\VBCODE.COM\Value"
    b.RegDelete "HKCU\VBCODE.COM\Value1"
    b.RegDelete "HKCU\VBCODE.COM\Value2"
    b.RegDelete "HKCU\VBCODE.COM\Value3"
    End Sub

    Private Sub Form_Load()
    Command1.Caption = "Write"
    Command2.Caption = "Read"
    Command3.Caption = "Delete"
    End Sub

  4. #4
    Megatron
    Guest
    Yes, but you are still using external dependancies.

  5. #5

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Okay, thanks.

    Would a REG_DWORD be a C integer (VB Long)?
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yes. Here's some more code: http://www.parksie.net/registry.zip
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Thanks, the vbapi.com sample was pretty easy to modify once I figured out to replace the string buffer with a long.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

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