October 31, 2025, 11:55:44 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Registry commands

Started by BumbleBee, February 10, 2009, 07:31:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

BumbleBee

Hi Paul,

If I set the folowing registry key and value:


RegSetString("hkey_local_machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","something", "c:\\something.exe")


...how can I delete only the key called "something" with its value, not the whole "Run" tree?
This line:


DeleteRegKey("hkey_local_machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Run","something")


of course drops syntax error, but an extension for DeleteRegKey command, like:


DeleteRegKey("hkey_local_machine\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\something")


would be very useful.

Thanks you,
B.

Ionic Wind Support Team

February 10, 2009, 08:04:11 AM #1 Last Edit: September 30, 2010, 09:35:13 AM by Larry McCaughn
Your third choice should work,  have you tried it?
Ionic Wind Support Team

BumbleBee

February 10, 2009, 08:38:56 AM #2 Last Edit: September 30, 2010, 09:35:27 AM by Larry McCaughn
Hi ,

Yes, I've just tried it again, it doesn't delete the values.

Bye,
B.

Ionic Wind Support Team

I'll look into it.  Pretty sure I've used it before to delete the value.

Also you can't delete keys in HKLM unless your process has the rights to do so, meaning it has to be ran under an administrator account.
Ionic Wind Support Team

BumbleBee


I created the key as admin, and would like to delete them as admin too.
...and the result is the same on my Win98 machine, creation is OK, deleting fails.
DeleteRegKey works fine, but it does more than I want to do :)


Raid

February 23, 2009, 05:15:37 PM #5 Last Edit: September 30, 2010, 09:35:51 AM by Larry McCaughn
Hi Guys...


have you considered copying the functions available in that old registry.inc source code file? It would be offly nice to be able to enumerate keys as well.

Proudly licensed EBASIC owner since Feb 2009. Network library present!

newuser

Quote from: Paul Turley on February 10, 2009, 08:42:24 AM
I'll look into it.  Pretty sure I've used it before to delete the value.

Also you can't delete keys in HKLM unless your process has the rights to do so, meaning it has to be ran under an administrator account.

I know this is an old thread but I problem with using the current version DELETEREGKEY function, and I am using the function to delete to some keys in HKLM.

Example :
-------------
Result=DeleteRegKey("HKEY_LOCAL_MACHINE\SYSTEM\\CurrentControlSet\\Control\\LockKey")
END


The above compiled exe work fine provided the Lockey is the only keyname with no subkey under it.
But if I have some subkeys under LockKey, the compiled exe deletion would failed.

Im running as admin user now.

Any idea why it failed? ???

I know I can use dos command like reg to do it, in ebasic like
SYSTEM "reg.exe" , "DELETE HKLM\SYSTEM\CurrentControlSet\Control\LockKey /f" which work fine but I dislike th black dos prompt that was display in seconds when the this system command is run.

Anyway, I can use DeleteRegKey to do it?  ???

Thanks :)

sapero

Shlwapi.dll implements this function:
Quote from: msdnDeletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.
$use "shlwapi.lib"
declare import, SHDeleteKeyA(int hkey, string pszSubKey),int
SHDeleteKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\LockKey")

Note: HKEY_LOCAL_MACHINE is a constant, defined as 0x80000002.

newuser

Quote from: sapero on January 16, 2010, 11:48:54 AM
Shlwapi.dll implements this function:
Quote from: msdnDeletes a subkey and all its descendants. The function will remove the key and all of the key's values from the registry.
$use "shlwapi.lib"
declare import, SHDeleteKeyA(int hkey, string pszSubKey),int
SHDeleteKeyA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\LockKey")

Note: HKEY_LOCAL_MACHINE is a constant, defined as 0x80000002.

Thanks alot  ;D

It work if I change this to
$use "shlwapi.lib"
declare import, SHDeleteKeyA(int hkey, string pszSubKey),int
SHDeleteKeyA(0x80000002, "SYSTEM\\CurrentControlSet\\Control\\LockKey")



:D