IonicWind Software

IWBasic => General Questions => Topic started by: BumbleBee on February 10, 2009, 07:31:12 AM

Title: Registry commands
Post by: BumbleBee on February 10, 2009, 07:31:12 AM
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.
Title: Re: Registry commands
Post by: Ionic Wind Support Team on February 10, 2009, 08:04:11 AM
Your third choice should work,  have you tried it?
Title: Re: Registry commands
Post by: BumbleBee on February 10, 2009, 08:38:56 AM
Hi ,

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

Bye,
B.
Title: Re: Registry commands
Post by: Ionic Wind Support Team 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.
Title: Re: Registry commands
Post by: BumbleBee on February 10, 2009, 08:55:17 AM

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 :)

Title: Re: Registry commands
Post by: Raid on February 23, 2009, 05:15:37 PM
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.

Title: Re: Registry commands
Post by: newuser on January 16, 2010, 06:39:10 AM
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 :)
Title: Re: Registry commands
Post by: 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.
Title: Re: Registry commands
Post by: newuser on January 16, 2010, 04:50:45 PM
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