Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the command to delete registry keys in qbasic ????

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
What is the command to delete registry keys in qbasic ????

I need it for the first serious program i am writing.

plez help

neon
 
If you want to directly access the registry from QB, it's a waste of time. Microsoft does not document the structure of SYSTEM.DAT (registry) files. But if you're willing to let another program do the work, you can do it using the SHELL command.
An easier way is to use .REG files or use the Windows Scripting Host (.vbs files). .VBS files are like souped-up batch files for Windows. Registry editing is a breeze with that program. Unfortunately, the only use I've seen of it was for the Love Letter Virus. What a waste!

 
My C:\WINDOWS\SAMPLES\WSH has lots of examples.
One of them called REGISTRY.VBS does what you want.
WSHShell.Popup "Delete key HKCU\MyRegKey"
WSHShell.RegDelete "HKCU\MyRegKey\"
 

Toshi's right. You can't directly manipulate the registry in QB.

However, you can create a REG file through QB like:

open "c:\RegMe.REG" for output as 10
print #10, "REGEDIT4"
print #10, chr$(10)
print #10, "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]"
print #10, "QBAutoStart""="C:\\MiggyD\\QB45\\Qb.exe"
close #10

'-give system time to write out the file or you'll get an error
'-code pop-up (due to writeback delays)
cls
print "Accessing Registry...please wait."
sleep 10
shell "regedit /s /u \RegMe.REG"
end

[red]NOTE!!!-DON'T MESS AROUND WITH THE REGISTRY IF YOU DON'T KNOW WHAT YOU'RE DOING!!! THERE CAN BE SERIOUS CONSEQUENCES[/red]

The above example will run once (not everytime). It was designed to give you an example of the work-around to access the registry (not to delete it--that's really dangerous if you are a novice. And even some intermediate programmers should not play with it either.

Anyway, the above code will create a Regkey to start QB from the specified directory listed once the computer is started/rebooted. You'll notice the double backslashes, they are required (due to C programming) to address the path to the program(s).

With that said, Happy programming and DO NO HARM!!

--MiggyD [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br>English is too hard to learn, the vowles change too much like come/home, comb/tomb, book/school, high/bye/sty, etc., etc. So should I say Geez or Sheez or Cheeze? hehe.[/sig]
 
PS--There is a way to use REGEDIT to delete regkeys. However, I believe it only works in Win 95 & 98. You have to tell it to remove those keys before windows completely starts up. [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br>English is too hard to learn, the vowles change too much like come/home, comb/tomb, book/school, high/bye/sty, etc., etc. So should I say Geez or Sheez or Cheeze? hehe.[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top