Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder 9 2087
Use the function below in Visual Basic 6.0, put it in a module.
If you do not have VB 6.0 then I recomend that you upgrade VB.NET 2003
to Visual Basic 6.0 (classic).
Hope this helps
The Grand Master
Public Const HKEY_CLASSES_RO OT = &H80000000
Public Const HKEY_CURRENT_US ER = &H80000001
Public Const HKEY_LOCAL_MACH INE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANC E_DATA = &H80000004
Public Const ERROR_SUCCESS = 0&
Declare Function RegCloseKey Lib "advapi32.d ll" (ByVal Hkey As Long) As
Long
Declare Function RegCreateKey Lib "advapi32.d ll" Alias "RegCreateK eyA"
(ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As
Long
Declare Function RegDeleteKey Lib "advapi32.d ll" Alias "RegDeleteK eyA"
(ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Declare Function RegDeleteValue Lib "advapi32.d ll" Alias
"RegDeleteValue A" (ByVal Hkey As Long, ByVal lpValueName As String) As
Long
Declare Function RegOpenKey Lib "advapi32.d ll" Alias "RegOpenKey A"
(ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As
Long
Declare Function RegQueryValueEx Lib "advapi32.d ll" Alias
"RegQueryValueE xA" (ByVal Hkey As Long, ByVal lpValueName As String,
ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As
Long) As Long
Declare Function RegSetValueEx Lib "advapi32.d ll" Alias
"RegSetValueExA " (ByVal Hkey As Long, ByVal lpValueName As String,
ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal
cbData As Long) As Long
Public Const REG_SZ = 1 ' Unicode nul terminated String
Public Const REG_DWORD = 4 ' 32-bit number
Public Sub savekey(Hkey As Long, strPath As String)
Dim keyhand&
r = RegCreateKey(Hk ey, strPath, keyhand&)
r = RegCloseKey(key hand&)
End Sub
Public Function getstring(Hkey As Long, strPath As String, strValue As
String)
'EXAMPLE:
'
'text1.text = getstring(HKEY_ CURRENT_USE
' R, "Software\VBW\R egistry", "String")
'
Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim intZeroPos As Integer
r = RegOpenKey(Hkey , strPath, keyhand)
lResult = RegQueryValueEx (keyhand, strValue, 0&, lValueType, ByVal
0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBuf Size, " ")
lResult = RegQueryValueEx (keyhand, strValue, 0&, 0&, ByVal
strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos 0 Then
getstring = Left$(strBuf, intZeroPos - 1)
Else
getstring = strBuf
End If
End If
End If
End Function
Public Sub savestring(Hkey As Long, strPath As String, strValue As
String, strdata As String)
'EXAMPLE:
'
'Call savestring(HKEY _CURRENT_USER, "Sof
' tware\VBW\Regis try", "String", text1.tex
' t)
'
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hk ey, strPath, keyhand)
r = RegSetValueEx(k eyhand, strValue, 0, REG_SZ, ByVal strdata,
Len(strdata))
r = RegCloseKey(key hand)
End Sub
Function getdword(ByVal Hkey As Long, ByVal strPath As String, ByVal
strValueName As String) As Long
'EXAMPLE:
'
'text1.text = getdword(HKEY_C URRENT_USER
' , "Software\VBW\R egistry", "Dword")
'
Dim lResult As Long
Dim lValueType As Long
Dim lBuf As Long
Dim lDataBufSize As Long
Dim r As Long
Dim keyhand As Long
r = RegOpenKey(Hkey , strPath, keyhand)
' Get length/data type
lDataBufSize = 4
lResult = RegQueryValueEx (keyhand, strValueName, 0&, lValueType,
lBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
If lValueType = REG_DWORD Then
getdword = lBuf
End If
'Else
'Call errlog("GetDWOR D-" & strPath, Fals
' e)
End If
r = RegCloseKey(key hand)
End Function
Function SaveDword(ByVal Hkey As Long, ByVal strPath As String, ByVal
strValueName As String, ByVal lData As Long)
'EXAMPLE"
'
'Call SaveDword(HKEY_ CURRENT_USER, "Soft
' ware\VBW\Regist ry", "Dword", text1.text)
'
'
Dim lResult As Long
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hk ey, strPath, keyhand)
lResult = RegSetValueEx(k eyhand, strValueName, 0&, REG_DWORD,
lData, 4)
'If lResult <error_succes s Then
' Call errlog("SetDWOR D", False)
r = RegCloseKey(key hand)
End Function
Public Function DeleteKey(ByVal Hkey As Long, ByVal strKey As String)
'EXAMPLE:
'
'Call DeleteKey(HKEY_ CURRENT_USER, "Soft
' ware\VBW")
'
Dim r As Long
r = RegDeleteKey(Hk ey, strKey)
End Function
Public Function DeleteValue(ByV al Hkey As Long, ByVal strPath As
String, ByVal strValue As String)
'EXAMPLE:
'
'Call DeleteValue(HKE Y_CURRENT_USER, "So
' ftware\VBW\Regi stry", "Dword")
'
Dim keyhand As Long
r = RegOpenKey(Hkey , strPath, keyhand)
r = RegDeleteValue( keyhand, strValue)
r = RegCloseKey(key hand)
End Function
Newbie Coder wrote:
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion.
If you cannot get it, just create a existing registry enting, that does the
same. http://msdn.microsoft.com/library/de...classtopic.asp
I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:e%******** ********@TK2MSF TNGP04.phx.gbl. ..
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I
originally asked for
That link just outputs keys to the console window & just gets the valsues.
So, if I deleted Key2 that page code would just miss it out getting Key1
then Key3, ehich is NOT what I asked about. I need to rename all the keys so
they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people to
pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are
absolutely wrong are of no use to anyone. Herfried is another perfect
example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:eU******** *****@TK2MSFTNG P03.phx.gbl...
Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion.
If you cannot get it, just create a existing registry enting, that does
the
same.
http://msdn.microsoft.com/library/de...classtopic.asp
>
I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:e%******** ********@TK2MSF TNGP04.phx.gbl. ..
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with
the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
Newbie,
That is your opininion, I can assure you that I have written a lot of code
in this newsgroup. Repeating it every time new is not so interesting you
know.
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:u$******** ******@TK2MSFTN GP06.phx.gbl...
Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I
originally asked for
That link just outputs keys to the console window & just gets the valsues.
So, if I deleted Key2 that page code would just miss it out getting Key1
then Key3, ehich is NOT what I asked about. I need to rename all the keys
so
they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people to
pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are
absolutely wrong are of no use to anyone. Herfried is another perfect
example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:eU******** *****@TK2MSFTNG P03.phx.gbl...
>Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion. If you cannot get it, just create a existing registry enting, that does
the
>same.
http://msdn.microsoft.com/library/de...classtopic.asp
>> I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht news:e%******* *********@TK2MS FTNGP04.phx.gbl ...
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with
the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
I forgot to tell, you can probably never add so much code to this newsgroup
as beside me Herfried did.
Cor
"Cor Ligthert [MVP]" <no************ @planet.nlschre ef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Newbie,
That is your opininion, I can assure you that I have written a lot of code
in this newsgroup. Repeating it every time new is not so interesting you
know.
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:u$******** ******@TK2MSFTN GP06.phx.gbl...
>Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I originally asked for
That link just outputs keys to the console window & just gets the valsues. So, if I deleted Key2 that page code would just miss it out getting Key1 then Key3, ehich is NOT what I asked about. I need to rename all the keys so they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people to pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are absolutely wrong are of no use to anyone. Herfried is another perfect example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:eU******* ******@TK2MSFTN GP03.phx.gbl...
>>Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion. If you cannot get it, just create a existing registry enting, that does
the
>>same.
http://msdn.microsoft.com/library/de...classtopic.asp
>>> I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht news:e%****** **********@TK2M SFTNGP04.phx.gb l... Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com Key2 http://www.sarc.com Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with
the
>same values they have
There could say 40 or more in the list. So, if there are 40 & I delete Key38 then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
I go under a diffferent name now because I am restarting coding again after
a long break from it, but I have for years written my own code for this
newsgroup & many other programming forums & have for 9 years
If an answer takes 300 lines of code to complete & I have time to do it then
I will
So, you cannot tell me that you have written more code than I
I am sure we have crossed in gotdotnet etc. & I am sure you haven't been
programming as long as I have either
But due to time restrictions (& out of coding for 1.5 years) these day I am
unable to spend 6 hours a day in the forums answering coding/Windows
questions like I did
I've seen Herfried point people to Google, copy someones code & put it on
his site & I have also seen your website that is badly coded because it used
to repeat the frames when you refreshed the pages. So, you & the other MVP
who wrote that site should learn ASP.NET
After spending so much time answering questions & not getting any reward
like an MVP I decided to stop. People like myself deserve it, but never get
the recognition
Newbie Coder
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:uG******** ******@TK2MSFTN GP04.phx.gbl...
I forgot to tell, you can probably never add so much code to this
newsgroup
as beside me Herfried did.
Cor
"Cor Ligthert [MVP]" <no************ @planet.nlschre ef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Newbie,
That is your opininion, I can assure you that I have written a lot of
code
in this newsgroup. Repeating it every time new is not so interesting you
know.
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:u$******** ******@TK2MSFTN GP06.phx.gbl...
Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I
originally asked for
That link just outputs keys to the console window & just gets the
valsues.
So, if I deleted Key2 that page code would just miss it out getting
Key1
then Key3, ehich is NOT what I asked about. I need to rename all the
keys
so
they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people
to
pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are
absolutely wrong are of no use to anyone. Herfried is another perfect
example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:eU******** *****@TK2MSFTNG P03.phx.gbl... Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion. If you cannot get it, just create a existing registry enting, that
does
the same. http://msdn.microsoft.com/library/de...classtopic.asp
>> I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht news:e%******* *********@TK2MS FTNGP04.phx.gbl ...
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2
with
the
same values they have
There could say 40 or more in the list. So, if there are 40 & I
delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in
the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
I think that the point here is that a value in the registry is really
nothing more than a name/value pair, and it is fancy in the way the value
part is interpreted (REG_SZ, REG_DWORD etc.), and there is no 'inbuilt'
functionality for manipulating a 'collection' of values as a single entity.
In my view the best course of action is to read all the values into an array
of some description, sort the array by the name, delete the elements that
need to be deleted, delete all the existing values from the registry key
then write the content of the array back to the registry at the same time
renaming the values according to the position in the array.
"Newbie Coder" <ne**********@p leasespamme.com wrote in message
news:u$******** ******@TK2MSFTN GP06.phx.gbl...
Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I
originally asked for
That link just outputs keys to the console window & just gets the valsues.
So, if I deleted Key2 that page code would just miss it out getting Key1
then Key3, ehich is NOT what I asked about. I need to rename all the keys
so
they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people to
pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are
absolutely wrong are of no use to anyone. Herfried is another perfect
example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:eU******** *****@TK2MSFTNG P03.phx.gbl...
>Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion. If you cannot get it, just create a existing registry enting, that does
the
>same.
http://msdn.microsoft.com/library/de...classtopic.asp
>> I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht news:e%******* *********@TK2MS FTNGP04.phx.gbl ...
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with
the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
Most of us fully appreciate the time and effort that
Cor and Herfried put in here helping people.
I can understand how they could get tired of posting
the same answers to the same questions -- answers that
can be found by searching Google.
I've only been hanging out here a couple of weeks.
I don't know as much as Cor or Herfried, so my ability
to help is not as expansive as theirs, but I've already
posted the same answer to the same question at least 3
times.
Just because someone refers you to Google doesn't mean you
have to be insulting to them. Receiving help here is a
*privilege*, not a *right*.
And if you have so many years of experience, why do you
call yourself a newbie?
Robin S.
------------------------------------------------------
"Newbie Coder" <ne**********@p leasespamme.com wrote in message
news:uh******** ******@TK2MSFTN GP03.phx.gbl...
>I go under a diffferent name now because I am restarting coding again after
a long break from it, but I have for years written my own code for this
newsgroup & many other programming forums & have for 9 years
If an answer takes 300 lines of code to complete & I have time to do it
then
I will
So, you cannot tell me that you have written more code than I
I am sure we have crossed in gotdotnet etc. & I am sure you haven't been
programming as long as I have either
But due to time restrictions (& out of coding for 1.5 years) these day I
am
unable to spend 6 hours a day in the forums answering coding/Windows
questions like I did
I've seen Herfried point people to Google, copy someones code & put it on
his site & I have also seen your website that is badly coded because it
used
to repeat the frames when you refreshed the pages. So, you & the other MVP
who wrote that site should learn ASP.NET
After spending so much time answering questions & not getting any reward
like an MVP I decided to stop. People like myself deserve it, but never
get
the recognition
Newbie Coder
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message
news:uG******** ******@TK2MSFTN GP04.phx.gbl...
>I forgot to tell, you can probably never add so much code to this
newsgroup
>as beside me Herfried did.
Cor
"Cor Ligthert [MVP]" <no************ @planet.nlschre ef in bericht news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
Newbie,
That is your opininion, I can assure you that I have written a lot of
code
in this newsgroup. Repeating it every time new is not so interesting
you
know.
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht
news:u$******** ******@TK2MSFTN GP06.phx.gbl... Cor
I am using the registry class already to get the values, delete them...
What I actually need is VB.NET 2003 code which actually does what I originally asked for
That link just outputs keys to the console window & just gets the valsues. So, if I deleted Key2 that page code would just miss it out getting
Key1
>then Key3, ehich is NOT what I asked about. I need to rename all the
keys
>so they count from Key1 to whatever the longest is in the list
Not being funny, but so-called MVP's don't write code, but point people to pointless links. Hence I wrote no Google links
Yes, we are all here to help each other, but pointless links that are absolutely wrong are of no use to anyone. Herfried is another perfect example of this
"Cor Ligthert [MVP]" <no************ @planet.nlwrote in message news:eU******* ******@TK2MSFTN GP03.phx.gbl... Newbie,
Just use the registry class it was already there in version 2002.
It is very nice written in MSDN in my opinion. If you cannot get it, just create a existing registry enting, that
does
>the same. http://msdn.microsoft.com/library/de...classtopic.asp
>>> I hope this helps,
Cor
"Newbie Coder" <ne**********@p leasespamme.com schreef in bericht news:e%****** **********@TK2M SFTNGP04.phx.gb l... Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com Key2 http://www.sarc.com Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2
with
>the same values they have
There could say 40 or more in the list. So, if there are 40 & I
delete
>Key38 then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in
the
>spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
This was completed a few weeks ago
"Master Programmer" <ma************ ***@outgun.comw rote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
Use the function below in Visual Basic 6.0, put it in a module.
If you do not have VB 6.0 then I recomend that you upgrade VB.NET 2003
to Visual Basic 6.0 (classic).
Hope this helps
The Grand Master
Public Const HKEY_CLASSES_RO OT = &H80000000
Public Const HKEY_CURRENT_US ER = &H80000001
Public Const HKEY_LOCAL_MACH INE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_PERFORMANC E_DATA = &H80000004
Public Const ERROR_SUCCESS = 0&
Declare Function RegCloseKey Lib "advapi32.d ll" (ByVal Hkey As Long) As
Long
Declare Function RegCreateKey Lib "advapi32.d ll" Alias "RegCreateK eyA"
(ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As
Long
Declare Function RegDeleteKey Lib "advapi32.d ll" Alias "RegDeleteK eyA"
(ByVal Hkey As Long, ByVal lpSubKey As String) As Long
Declare Function RegDeleteValue Lib "advapi32.d ll" Alias
"RegDeleteValue A" (ByVal Hkey As Long, ByVal lpValueName As String) As
Long
Declare Function RegOpenKey Lib "advapi32.d ll" Alias "RegOpenKey A"
(ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As
Long
Declare Function RegQueryValueEx Lib "advapi32.d ll" Alias
"RegQueryValueE xA" (ByVal Hkey As Long, ByVal lpValueName As String,
ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As
Long) As Long
Declare Function RegSetValueEx Lib "advapi32.d ll" Alias
"RegSetValueExA " (ByVal Hkey As Long, ByVal lpValueName As String,
ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal
cbData As Long) As Long
Public Const REG_SZ = 1 ' Unicode nul terminated String
Public Const REG_DWORD = 4 ' 32-bit number
Public Sub savekey(Hkey As Long, strPath As String)
Dim keyhand&
r = RegCreateKey(Hk ey, strPath, keyhand&)
r = RegCloseKey(key hand&)
End Sub
Public Function getstring(Hkey As Long, strPath As String, strValue As
String)
'EXAMPLE:
'
'text1.text = getstring(HKEY_ CURRENT_USE
' R, "Software\VBW\R egistry", "String")
'
Dim keyhand As Long
Dim datatype As Long
Dim lResult As Long
Dim strBuf As String
Dim lDataBufSize As Long
Dim intZeroPos As Integer
r = RegOpenKey(Hkey , strPath, keyhand)
lResult = RegQueryValueEx (keyhand, strValue, 0&, lValueType, ByVal
0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBuf Size, " ")
lResult = RegQueryValueEx (keyhand, strValue, 0&, 0&, ByVal
strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos 0 Then
getstring = Left$(strBuf, intZeroPos - 1)
Else
getstring = strBuf
End If
End If
End If
End Function
Public Sub savestring(Hkey As Long, strPath As String, strValue As
String, strdata As String)
'EXAMPLE:
'
'Call savestring(HKEY _CURRENT_USER, "Sof
' tware\VBW\Regis try", "String", text1.tex
' t)
'
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hk ey, strPath, keyhand)
r = RegSetValueEx(k eyhand, strValue, 0, REG_SZ, ByVal strdata,
Len(strdata))
r = RegCloseKey(key hand)
End Sub
Function getdword(ByVal Hkey As Long, ByVal strPath As String, ByVal
strValueName As String) As Long
'EXAMPLE:
'
'text1.text = getdword(HKEY_C URRENT_USER
' , "Software\VBW\R egistry", "Dword")
'
Dim lResult As Long
Dim lValueType As Long
Dim lBuf As Long
Dim lDataBufSize As Long
Dim r As Long
Dim keyhand As Long
r = RegOpenKey(Hkey , strPath, keyhand)
' Get length/data type
lDataBufSize = 4
lResult = RegQueryValueEx (keyhand, strValueName, 0&, lValueType,
lBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
If lValueType = REG_DWORD Then
getdword = lBuf
End If
'Else
'Call errlog("GetDWOR D-" & strPath, Fals
' e)
End If
r = RegCloseKey(key hand)
End Function
Function SaveDword(ByVal Hkey As Long, ByVal strPath As String, ByVal
strValueName As String, ByVal lData As Long)
'EXAMPLE"
'
'Call SaveDword(HKEY_ CURRENT_USER, "Soft
' ware\VBW\Regist ry", "Dword", text1.text)
'
'
Dim lResult As Long
Dim keyhand As Long
Dim r As Long
r = RegCreateKey(Hk ey, strPath, keyhand)
lResult = RegSetValueEx(k eyhand, strValueName, 0&, REG_DWORD,
lData, 4)
'If lResult <error_succes s Then
' Call errlog("SetDWOR D", False)
r = RegCloseKey(key hand)
End Function
Public Function DeleteKey(ByVal Hkey As Long, ByVal strKey As String)
'EXAMPLE:
'
'Call DeleteKey(HKEY_ CURRENT_USER, "Soft
' ware\VBW")
'
Dim r As Long
r = RegDeleteKey(Hk ey, strKey)
End Function
Public Function DeleteValue(ByV al Hkey As Long, ByVal strPath As
String, ByVal strValue As String)
'EXAMPLE:
'
'Call DeleteValue(HKE Y_CURRENT_USER, "So
' ftware\VBW\Regi stry", "Dword")
'
Dim keyhand As Long
r = RegOpenKey(Hkey , strPath, keyhand)
r = RegDeleteValue( keyhand, strValue)
r = RegCloseKey(key hand)
End Function
Newbie Coder wrote:
Hello Newsgroup Readers
I would like to know how to go & do the following:
I have a certain registry key that has sub values
Example:
Key1 http://www.microsoft.com
Key2 http://www.sarc.com
Key3 http://www.someurl.com
Say, I deleted Key1 I need to rename Key2 to Key1 & Key3 to Key2 with
the
same values they have
There could say 40 or more in the list. So, if there are 40 & I delete
Key38
then I will need to rename Key 39 to Key38 & Key40 to Key 39...
I could delete 1 or more of those Key values. So, how do I fill in the
spaces of the Keys deleted?
Please - no Google links etc, but some real code
I am using VB.NET 2003
Any help would be wonderful!
TIA
Newbie Coder
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ForestDemon |
last post by:
i'm able to use the GetValue() function for string usage/manipulation,
but i can't figure out how to read/write a binary value to/from a key.
any help is greatly appreciated...thanks folks!
|
by: Kevin Swanson |
last post by:
I'm attempting some remote registry manipulation via C#. I've written a test
app to simply grab a specified key from a specified hive on a specified
machine. The call to OpenSubKey is throwing System.SecurityException.
Also of note: Sitting at my local box, I can open regedit and connect to the
remote registry. I see three hives: _CLASSES_ROOT, _LOCAL_MACHINE, and
_USERS. I can open all but HKEY_LOCAL_MACHINE. When I try to expand that...
|
by: Andrew |
last post by:
Apologies for the double-post.. I'm new, just getting used to this.. and
should have posted this way in the first place..
How does one go about taking ownership of a registry key using C# & .NET 2.0
*IF* one has _only_ TakeOwnership privilege?
The problem is exactly as specified in MS KB Article ID: 111546 at:
http://support.microsoft.com/kb/111546/EN-US/
...except that I would like to know how to do it in C#
|
by: Bry |
last post by:
Having mastered reading a multi_sz from the registry into an array
using:
// Max of 999 is fine in this instance
string myArray = new string;
myArray = (string) (myRegKey.GetValue("RegValue"));
// myArray will now contain a small number of elements with data in
them
I'm trying to do the opposite and write it back to the registry using:
|
by: Newbie Coder |
last post by:
Hi all,
VB.NET 2003 ONLY PLEASE
I have a registry key (HKCU\Software\Newbie\SomeKey) of type string which
holds an XML string as follows:
<root formID="preferencesform" lang="english" ><global welcome="0"
lang="british" soundEffects="0" soundTheme="default" stayOnTop="0"
autoStart="0" /><main ><pos x="761" y="277" /><size width="240"
| |
by: ross m. greenberg |
last post by:
I'm trying to emulate the look and feel of "RegEdit" under Visual Basic/VB.Net using Visual Studio 2005.
Can anybody give me a pointer in the right direction: for example, what name spaces must I import, and what methods are available to me?
Thanks!
Ross
|
by: David Schrader |
last post by:
Hello all,
Let me start by saying that I'm not certain whether this belongs
here, in this notes group, or another more developmentally
oriented one. I'll try starting here then go elsewhere if you
decide otherwise. (Already forwarded here, sort-of, from:
microsoft.public.windowsnt.registry.)
I'm writing a Visual Basic program which stores and retrieves
data in the registry - no big thing, I've got all that code written
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |