How to registry key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'd like to know how to remove registry keys which contain a value of
'appkeyA' or
'appkeyB' or
'appkeyC' ...?

thanks in advance
 
Do you mean recursively searching the registry looking for those keys or are
they under a certain path? Are there any subkeys to those keys?

Awaiting your response
 
Li Pang said:
I'd like to know how to remove registry keys which contain a value of
'appkeyA' or
'appkeyB' or
'appkeyC' ...?

Take a look at the 'Microsoft.Win32.Registry' class.
 
Looking at the Registry Key class will only help in some instances. What if
the user is looking for a recursive seach & then delete answer to his/her
question then your reply hasn't helped at all?
 
Crouchie,

Crouchie1998 said:
Looking at the Registry Key class will only help in some instances. What
if
the user is looking for a recursive seach & then delete answer to his/her
question then your reply hasn't helped at all?

Well, who knows if the OP is able to implement a recursive search? I don't
know, and thus I don't spend the time to write a complete solution if the OP
is able to do that himself. If the OP has problems to do that, and asks how
to do that, I'll maybe spend this time.

Just my 2 Euro cents...
 
I wrote a recursive registry search function around 4 months ago, but that
only lists the results in a listview. However, its on a CD I have created for
sale & don't want the code to be posted here because it seems that I am the
first person to do this in VB.NET, as there isn't anything on the Internet
about it. Its not complicated code though, but that's my opinion.

Sorry, but I am not prepared to compromise future sales of my CD to answer
this question. I made the mistake of uploading a shutdown/restart/logoff/lock
solution in VB.NET & now everyone has copied my code.
 
First, if your post really is just saying "I know how to do it but I'm
not sharing", which is how I'm reading it, then what are you doing
here? If that's your attitude about learing to write software and
helping others then you don't belong here.

Second, you can't really sell code that is so generic and easily
reproducible that it's a basic concept anyone working with the
registry in .net can do (see below).

Good bye,

Sam


Imports Microsoft.Win32

Public Class RegSearch

Public Shared Sub Search(ByVal text As String)
For Each key As RegistryKey In New RegistryKey() { _
Registry.ClassesRoot, _
Registry.CurrentConfig, _
Registry.CurrentUser, _
Registry.LocalMachine, _
Registry.Users _
}
SearchKey(text, key)
Next

Console.WriteLine("Done")
End Sub


Private Shared Sub SearchKey(ByVal text As String, ByVal key As
RegistryKey)

If key Is Nothing Then
Return
End If

If key.Name.IndexOf(text) > -1 Then
Console.WriteLine("Found in " + key.ToString())
End If

For Each valueName As String In key.GetValueNames()
If valueName.IndexOf(text) > -1 Then
Console.WriteLine("Found in " + key.ToString() + ", " +
valueName)
End If

Dim value As Object = key.GetValue(valueName)
If Not value Is Nothing AndAlso _
value.ToString().IndexOf(text) > -1 Then
Console.WriteLine("Found in " + key.ToString() + ", " +
valueName + ": " + value.ToString())
End If
Next

For Each subKeyName As String In key.GetSubKeyNames()
Try
SearchKey(text, key.OpenSubKey(subKeyName))
Catch ex As Security.SecurityException
' can't search this one, just skip it
End Try
Next
End Sub

End Class
 
If you see my first post to this thread you will see that I asked the user if
he/she wanted to delete a certain key or recursively search.

So, what you are telling me is that if I write code/programs that are 100%
of my work then I cannot copyright the code/program? So, what you are saying
is that no program ever written should be sold. GIVE ME A BREAK.

Take the VB.NET/C# convertors for example: If you download the VB.NET
Resource Kit then it is included FREE, but others have create simular
programs & sell them for $200. Are you saying they shouldn't sell them?

The CD I have created to sell is 100% my own work. There are language
tutorials, sample applications as well as demo applications because I want to
keep the source code for that.

Anyway, I have 9 tutorial/applications on the Internet for download
including full source code.

I don't mind coding certain solutions for people at all, but my recursive
search registry is an application. Would you go to a software house and ask
them for the source code because you don't know how to do it? You know they
wouldn't give it to you.
 
Of course not. But I also wouldn't expect someone from a commercial
vendor to respond to a question on how to do something by saying "we
do it in our software" and not sharing how.

If you don't want to share your code, fine, that's your right. If you
want to try to sell it, fine, that's your right. But posting a
response here saying basically "I know how to do it but I'm not
tellin', nah nah nah" is not really appropriate.

Sam
 
I code around 18 hours a day & help people in many different forums & have
done for around 7 years (or just over). Some code has to be kept to oneself,
but 98% of my code I share or code especially for the people asking the
questions.

If the original user of this thread wanted to just delete a key then I would
have been happy to give a solution, but when it requires something that took
me a lot of hassle then I decline. A lot of frustration went into the program
I am talking about & I almost give it up.
 
Crouchie,

Crouchie1998 said:
If the original user of this thread wanted to just delete a key then I
would
have been happy to give a solution, but when it requires something that
took
me a lot of hassle then I decline. A lot of frustration went into the
program
I am talking about & I almost give it up.

So, wouldn't it be great if you could prevent somebody from getting as
frustrated as you were? I understand that it's not right to post code from
commercial projects here if the client you wrote the application for doesn't
want you to do that. Nevertheless, there is always the option of modifying
the code, removing parts not being relevant for the reply, and posting this
strongly adapted code.

Just my thoughts...
 
Crouchie1998,

If you couldn't post your codes, I appreciate if you can provide some ideals
about how to do such tasks. Acturally, we can't do any business within this
newsgroup. I believe you are an expert and might be the first person to do
such job, but certainly not the last one. Writting the below email instead of
give a help can't give any benefice to nobody and is useless.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top