AutoHotkey Community

It is currently May 27th, 2012, 7:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: RegDelete from ListView
PostPosted: March 6th, 2006, 10:34 pm 
Offline

Joined: September 28th, 2005, 2:10 pm
Posts: 39
Location: Pirot
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2006, 10:44 am 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2006, 9:38 pm 
Offline

Joined: September 28th, 2005, 2:10 pm
Posts: 39
Location: Pirot
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2006, 11:41 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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...

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2006, 2:17 pm 
Offline

Joined: February 7th, 2005, 11:11 am
Posts: 192
Location: Munich, Germany
RegDelete *.*
8) 8) :lol:

_________________
Peter

Wisenheiming for beginners: KaPeGe (German only, sorry)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2006, 2:53 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
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! 8)

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2006, 10:25 pm 
Offline

Joined: September 28th, 2005, 2:10 pm
Posts: 39
Location: Pirot
Thanks a lot, PhiLho.
I did a quick test with a dummy value inside the registry key and it worked.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: completed code
PostPosted: October 17th, 2006, 9:49 am 
can the completed code be posted


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Exabot [Bot], migz99, sjc1000, Yahoo [Bot] and 74 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group