Registry Key Manipulation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie Coder

    Registry Key Manipulation

    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


  • Master Programmer

    #2
    Re: Registry Key Manipulation

    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

    Comment

    • Cor Ligthert [MVP]

      #3
      Re: Registry Key Manipulation

      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.



      I hope this helps,

      Cor


      "Newbie Coder" <newbie_coder@p leasespamme.com schreef in bericht
      news:e%23PnuL$D HHA.3224@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
      >
      >

      Comment

      • Newbie Coder

        #4
        Re: Registry Key Manipulation

        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]" <notmyfirstname @planet.nlwrote in message
        news:eU5NUhHEHH A.572@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" <newbie_coder@p leasespamme.com schreef in bericht
        news:e%23PnuL$D HHA.3224@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
        >
        >

        Comment

        • Cor Ligthert [MVP]

          #5
          Re: Registry Key Manipulation

          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" <newbie_coder@p leasespamme.com schreef in bericht
          news:u$XVACKEHH A.3524@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]" <notmyfirstname @planet.nlwrote in message
          news:eU5NUhHEHH A.572@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" <newbie_coder@p leasespamme.com schreef in bericht
          >news:e%23PnuL$ DHHA.3224@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
          >
          >
          >>
          >>
          >
          >

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: Registry Key Manipulation

            I forgot to tell, you can probably never add so much code to this newsgroup
            as beside me Herfried did.

            Cor

            "Cor Ligthert [MVP]" <notmyfirstname @planet.nlschre ef in bericht
            news:%23zAUXpKE HHA.4280@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" <newbie_coder@p leasespamme.com schreef in bericht
            news:u$XVACKEHH A.3524@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]" <notmyfirstname @planet.nlwrote in message
            >news:eU5NUhHEH HA.572@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" <newbie_coder@p leasespamme.com schreef in bericht
            >>news:e%23PnuL $DHHA.3224@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
            >>
            >>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • Newbie Coder

              #7
              Re: Registry Key Manipulation

              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]" <notmyfirstname @planet.nlwrote in message
              news:uGTIJqKEHH A.1224@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]" <notmyfirstname @planet.nlschre ef in bericht
              news:%23zAUXpKE HHA.4280@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" <newbie_coder@p leasespamme.com schreef in bericht
              news:u$XVACKEHH A.3524@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]" <notmyfirstname @planet.nlwrote in message
              news:eU5NUhHEHH A.572@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" <newbie_coder@p leasespamme.com schreef in bericht
              >news:e%23PnuL$ DHHA.3224@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
              >
              >
              >>
              >>
              >
              >
              >
              >

              Comment

              • Stephany Young

                #8
                Re: Registry Key Manipulation

                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" <newbie_coder@p leasespamme.com wrote in message
                news:u$XVACKEHH A.3524@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]" <notmyfirstname @planet.nlwrote in message
                news:eU5NUhHEHH A.572@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" <newbie_coder@p leasespamme.com schreef in bericht
                >news:e%23PnuL$ DHHA.3224@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
                >
                >
                >>
                >>
                >
                >

                Comment

                • RobinS

                  #9
                  Re: Registry Key Manipulation


                  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" <newbie_coder@p leasespamme.com wrote in message
                  news:uh5OvXNEHH A.4808@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]" <notmyfirstname @planet.nlwrote in message
                  news:uGTIJqKEHH A.1224@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]" <notmyfirstname @planet.nlschre ef in bericht
                  >news:%23zAUXpK EHHA.4280@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" <newbie_coder@p leasespamme.com schreef in bericht
                  news:u$XVACKEHH A.3524@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]" <notmyfirstname @planet.nlwrote in message
                  >news:eU5NUhHEH HA.572@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" <newbie_coder@p leasespamme.com schreef in bericht
                  >>news:e%23PnuL $DHHA.3224@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
                  >>
                  >>
                  >>>
                  >>>
                  >>
                  >>
                  >
                  >
                  >>
                  >>
                  >
                  >

                  Comment

                  • Newbie Coder

                    #10
                    Re: Registry Key Manipulation

                    This was completed a few weeks ago


                    "Master Programmer" <master_program mer@outgun.comw rote in message
                    news:1164447947 .788347.312310@ 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
                    >

                    Comment

                    Working...