|
-
May 4th, 2001, 01:31 PM
#1
Thread Starter
Black Cat
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.
-
May 4th, 2001, 02:33 PM
#2
REG_SZ is a constant for 0, so just change it to 4 (the value of REG_DWORD).
-
May 5th, 2001, 12:23 AM
#3
Junior Member
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
-
May 5th, 2001, 12:05 PM
#4
Yes, but you are still using external dependancies.
-
May 7th, 2001, 06:06 AM
#5
Thread Starter
Black Cat
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.
-
May 7th, 2001, 12:58 PM
#6
Monday Morning Lunatic
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
-
May 7th, 2001, 01:24 PM
#7
Thread Starter
Black Cat
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|