AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RegDelete from ListView

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
dinkosta



Joined: 28 Sep 2005
Posts: 37
Location: Pirot

PostPosted: Mon Mar 06, 2006 10:34 pm    Post subject: RegDelete from ListView Reply with quote

The script I'm trying to make should retrieve the values from specified registry keys and when I check a row the value from that row should be removed from the registry. Retrieving the values works OK, but the problem I have is how to delete a certain value from the registry. I have the following script that doesn't delete anything:

Code:

Gui, Add, ListView, vlvo x10 y40 w680 h500 checked, Path|Name|Data
Gui,add,button,grem,Remove
 Loop,HKCU, Software\Microsoft\Internet Explorer\Main
  {
   RegRead, rvalmain
   LV_Add("","HKCU\Software\Microsoft\Internet Explorer\Main",a_loopregname,rvalmain)
  }
  Loop,HKLM, Software\Microsoft\Internet Explorer\Main
   {
    if a_loopregname = Start Page
     {
      RegRead, rvalmsp
      LV_Add("","HKLM\Software\Microsoft\Internet Explorer\Main",a_loopregname,rvalmsp)
     }
    }
LV_ModifyCol(1,"200")
LV_ModifyCol(2,"180")
LV_ModifyCol(3,"Autohdr")
Gui, Show
return

rem:
ControlGet,outv,list,checked,lvo
FokRed := LV_GetNext("c")
LV_GetText(DeleteLine, FokRed)
MsgBox, 8244, Delete Entry, Are you sure you want to delete `n%DeleteLine%?
IfMsgBox,Yes
{
LV_Delete(FokRed)
RegDelete, %a_loopregkey%,%a_loopregsubkey%,%DeleteLine%
}
Return
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Mar 07, 2006 10:44 am    Post subject: Reply with quote

I didn't analyzed closely the last part of your code, but I see that in the rem part, you use %a_loopregkey% and %a_loopregsubkey%. These variables are not available outside the registry loop...
You should use the values put in the ListView to know to path to the value to delete.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
dinkosta



Joined: 28 Sep 2005
Posts: 37
Location: Pirot

PostPosted: Tue Mar 07, 2006 9:38 pm    Post subject: Reply with quote

First of all, thank you for your reply PhiLho.
The script I posted is one of the many variations I tried, and I did try to use only %DeleteLine% with 'RegDelete' but that didn't work neither.
I also tried it with a context menu, but I had the same problem - deleting the selected entry from the registry.
Any further suggestions?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Mar 07, 2006 11:41 pm    Post subject: Reply with quote

If I read correctly the manual on RegDelete (didn't tried it yet), it wants the RootKey (HKCU, HKLM), the SubKey (remainder of path) and the ValueName.
So you should do something like:

LV_GetText(DeleteLine, FokRed, 1)
LV_GetText(valueName, FokRed, 2)
StringLeft rootKey, DeleteLine, 4
StringTrimLeft DeleteLine, DeleteLine, 5
RegDelete %rootKey%, %DeleteLine%, %valueName%

Warning: this is untested! Replace the RegDelete command by a MsgBox (escape commas) to be sure this is the right stuff you are about to delete...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
kapege.de



Joined: 07 Feb 2005
Posts: 186
Location: Munich, Germany

PostPosted: Wed Mar 08, 2006 2:17 pm    Post subject: Reply with quote

RegDelete *.*
Cool Cool Laughing
_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Mar 08, 2006 2:53 pm    Post subject: Reply with quote

Too easy...
And what is this dot anyway?
Naaah, make a recursive exploration of the registry, and if a random number is above a thresold, just delete the current key/value...
That's is annoying! Cool
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
dinkosta



Joined: 28 Sep 2005
Posts: 37
Location: Pirot

PostPosted: Wed Mar 08, 2006 10:25 pm    Post subject: Reply with quote

Thanks a lot, PhiLho.
I did a quick test with a dummy value inside the registry key and it worked.
Back to top
View user's profile Send private message
nodswal
Guest





PostPosted: Tue Oct 17, 2006 9:49 am    Post subject: completed code Reply with quote

can the completed code be posted
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group