RegDeleteTree is exported from Advapi32.dll only in Windows Vista and higher.OpenKey()
error = RegDeleteTree(hKey) ;<< IMA Error here.
Registry Module (windows only)
Re: Registry Module (windows only)
Re: Registry Module (windows only)
you are right.
RegDeleteKeyEx requires: Windows Vista, Windows XP Professional x64 Edition +
RegDeleteTree requires: Windows Vista +
RegSetValueEx requires: Windows 2000 Professional +
I will add some check and workarounds in the next days.
RegDeleteKeyEx requires: Windows Vista, Windows XP Professional x64 Edition +
RegDeleteTree requires: Windows Vista +
RegSetValueEx requires: Windows 2000 Professional +
I will add some check and workarounds in the next days.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: Registry Module (windows only)
For Windows XP, use this:
Works fine on XP SP3.
Code: Select all
Procedure.l RegDeleteTree(hTopKey.i, sSubKey.s)
Protected hKey.i, RetCode.l, dwSize.l, sBuf.s
RetCode = RegOpenKeyEx_(hTopKey, sSubKey, 0, #KEY_ENUMERATE_SUB_KEYS, @hKey)
If RetCode = #ERROR_SUCCESS
sBuf = Space(#MAX_PATH)
Repeat
dwSize = #MAX_PATH
RetCode = RegEnumKeyEx_(hKey, 0, sBuf, @dwSize, 0, 0, 0, 0)
If RetCode = #ERROR_SUCCESS : RegDeleteTree(hKey, sBuf) : EndIf
Until RetCode
RegCloseKey_(hKey)
RetCode = RegDeleteKey_(hTopKey, sSubKey)
EndIf
ProcedureReturn RetCode
EndProcedure
-
- Enthusiast
- Posts: 789
- Joined: Sat Aug 09, 2003 3:13 am
- Location: 90-61-92 // EU or ASIA
- Contact:
Re: Registry Module (windows only)
@ts-soft
Should you delete the key in example? it's deleted value only
Should you delete the key in example? it's deleted value only
Re: Registry Module (windows only)
This is okay, i won't delete a key with name "ts-soft". It is required in a feature Software by mesec wrote:@ts-soft
Should you delete the key in example? it's deleted value only
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: Registry Module (windows only)
Hi ts-soft,
to get an error while reading recursively is not a problem (therfore the "If Not RegReturn\ERROR" part). It's ok if I am not allowed to read some subkeys (the ways of mircosoft are mysterious).
The only problem is, if I am not allowed to read a particular subkey (and it's not the last like "Properties") all further calls of e.g. CountSubValues have RegValue/ERROR still set to #True!
On my system the subkey "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318}\0021" is protected (-> error access violation).
All following subkeys "...\0022", "...\0023", "...\0024", "...\0025" ... (with exception of "Properties" which is the last) are not protected. But with current Version (1.3.3) I get access violation error for them too.
There are two methods to get correct results are:
* to clear the structure "RegValue" before calling CountSubValues,
or
* to clear the structure "RegValue" in the OpenKey/OpenKeyS Macros as I mentioned.
I just shortened my example a bit for shorter code, but I'm reading through all subkeys of "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class". So if you iterate through all classes and get the first error at "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class\{...}\Properties" you don't get results for the other classes ...
to get an error while reading recursively is not a problem (therfore the "If Not RegReturn\ERROR" part). It's ok if I am not allowed to read some subkeys (the ways of mircosoft are mysterious).
The only problem is, if I am not allowed to read a particular subkey (and it's not the last like "Properties") all further calls of e.g. CountSubValues have RegValue/ERROR still set to #True!
On my system the subkey "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318}\0021" is protected (-> error access violation).
All following subkeys "...\0022", "...\0023", "...\0024", "...\0025" ... (with exception of "Properties" which is the last) are not protected. But with current Version (1.3.3) I get access violation error for them too.
There are two methods to get correct results are:
* to clear the structure "RegValue" before calling CountSubValues,
or
* to clear the structure "RegValue" in the OpenKey/OpenKeyS Macros as I mentioned.
I just shortened my example a bit for shorter code, but I'm reading through all subkeys of "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class". So if you iterate through all classes and get the first error at "#HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\Control\Class\{...}\Properties" you don't get results for the other classes ...
Re: Registry Module (windows only)
-- removed, use ts-soft's --
Last edited by jassing on Mon Sep 02, 2013 7:56 pm, edited 1 time in total.
Re: Registry Module (windows only)
Thx for all you're replies and code
Update:
Greetings - Thomas
Update:
Please test it, special on winxp, i can't test it at the moment.History wrote:; Version 1.4, Sep 02, 2013
; fixed Clear Resultstructure
; + compatibility to WinXP
Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: Registry Module (windows only)
@ts-soft:
Not tested but your XP_DeleteTree can not work, it deletes only one level of subkeys.
My code calls RegDeleteTree recursively.
Not tested but your XP_DeleteTree can not work, it deletes only one level of subkeys.
My code calls RegDeleteTree recursively.
Re: Registry Module (windows only)
fixed
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Re: Registry Module (windows only)
I may be using it wrong, but get an error on line 50: Sinxtax Error
Re: Registry Module (windows only)
You require PB 5.20 and Higher!ClueLess wrote:I may be using it wrong, but get an error on line 50: Sinxtax Error
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: Registry Module (windows only)
in WriteValue, RegSetValueEx requires a pointer to the data to be set, not the actual value;
It will instead try to interpret the value as pointer and result in a 'invalid access to memory location'
Code: Select all
Case #REG_DWORD
Protected lval.l = Val(Value)
error = RegSetValueEx_(hKey, ValueName, 0, #REG_DWORD, @lval, SizeOf(Long))
Case #REG_QWORD
Protected qval.q = Val(Value)
error = RegSetValueEx_(hKey, ValueName, 0, #REG_QWORD, @qval, SizeOf(Quad))
Re: Registry Module (windows only)
Very nice, needed one of those and had just started making one myself, this saves me the time
AMD FX-8350 @ ~4.8GHz | 8GB Corsair DDR3-SDRAM @ 1800Mhz | 7even Ult & Manjaro 0.8.7.1 | PB 5.3
Web: rudz.dk
Web: rudz.dk
Re: Registry Module (windows only)
How to WriteValue as #REG_DWORD with this library? I want to use this because the WOW64 option
I tried with no success
Any help are welcome
I tried with no success
Code: Select all
WriteValue(#HKEY_CURRENT_USER,"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION","WebGadget.exe","10001",#REG_DWORD)
Any help are welcome
ARGENTINA WORLD CHAMPION