Results 1 to 34 of 34

Thread: Searching with a list box instead of a textbox.

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Searching with a list box instead of a textbox.

    Hey guys I have a sub that searches for registry keys I enter in a textbox its caled text1.

    The sub that scans is this ..

    VB Code:
    1. Private Sub SearchRegMachine()
    2.   Dim i As Integer
    3.     Dim lngKeyHandle As Long
    4.     Dim lngResult As Long
    5.     Dim lngCurIdx As Long
    6.     Dim strValue As String
    7.     Dim lngValueLen As Long
    8.     Dim strClass As String
    9.     Dim lngClassLen As Long
    10.     Dim strResult As String
    11.     Dim lngTime As FILETIME
    12.     Dim strSearch As String
    13.     Dim intSearchLen As Integer
    14.     Dim blnMatch As Boolean
    15.    
    16.    
    17.      'PlaySound App.path & "\StartReg.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    18.     i = 0
    19.     ' Clear the current results
    20.    
    21.     ' Assign the new string to search for
    22.     strSearch = Text1.Text
    23.     intSearchLen = Len(strSearch)
    24.    
    25.     ' Open the Root Branch to search
    26.     lngResult = RegOpenKeyEx(strBranch, _
    27.             "", _
    28.              0&, _
    29.              KEY_READ, _
    30.              lngKeyHandle)
    31.    
    32.     If lngResult <> ERROR_SUCCESS Then
    33.         MsgBox "Cannot open key.", , "Search Registry Keys"
    34.     Else
    35.     ' If the Root branch can be opened, disable
    36.     ' the buttons and begin the search
    37.         startscanregbutton.Enabled = False
    38.        ' Command2.Enabled = False
    39.         listreg.Enabled = False
    40.         Reg.MousePointer = 11
    41.        
    42.         lngCurIdx = 0
    43.         Do
    44.             lngValueLen = 2000
    45.             strValue = String(lngValueLen, 0)
    46.             lngClassLen = 2000
    47.             strClass = String(lngClassLen, 0)
    48.        
    49.             ' Enumerate all the sub keys
    50.             lngResult = RegEnumKeyEx(lngKeyHandle, _
    51.                  lngCurIdx, _
    52.                  ByVal strValue, _
    53.                  lngValueLen, _
    54.                  0&, _
    55.                  ByVal strClass, _
    56.                  lngClassLen, _
    57.                  lngTime)
    58.            
    59.             ' Increment the index of found keys
    60.             lngCurIdx = lngCurIdx + 1
    61.        
    62.             If lngResult = ERROR_SUCCESS Then
    63.                 ' Trim the current key to its actual length
    64.                 strResult = Left(strValue, lngValueLen)
    65.                
    66.                 ' Eliminate case if the search is insensitive
    67.                 blnMatch = False
    68.                 strValue = strResult
    69.                 If Check1.Value = 0 Then
    70.                     strResult = LCase(strResult)
    71.                     strSearch = LCase(strSearch)
    72.                 End If
    73.  
    74.                 ' Compare strings based upon search type
    75.                 Select Case Combo2.ListIndex
    76.                     Case 0
    77.                         ' Check if any portion of the search string is found.
    78.                         If InStr(strResult, strSearch) Then blnMatch = True
    79.                     Case 1
    80.                         ' Check if an exact match is found.
    81.                         If strResult = strSearch Then blnMatch = True
    82.                     'Case 2
    83.                         ' Check if the search string matches the
    84.                         ' left portion of the key string.
    85.                        ' If Left(strResult, intSearchLen) = strSearch Then blnMatch = True
    86.                    ' Case Else
    87.                         ' Check if the search string matches the
    88.                         ' right portion of the key string.
    89.                         'If Right(strResult, intSearchLen) = strSearch Then blnMatch = True
    90.                 End Select
    91.                
    92.                 ' Populate the list with keys that match
    93.                 ' the search criteria
    94.                 If blnMatch Then
    95.                     i = i + 1
    96.                     listreg.AddItem strValue
    97.                 End If
    98.             End If
    99.        
    100.         ' Keep looking for more keys
    101.         Loop While lngResult = ERROR_SUCCESS
    102.         ' Close the Root Branch
    103.         lngResult = RegCloseKey(lngKeyHandle)
    104.    
    105.         ' Enable the buttons
    106.         Reg.MousePointer = 0
    107.         listreg.Enabled = True
    108.         startscanregbutton.Enabled = True
    109.       '  Command2.Enabled = True
    110.        
    111.         ' Display the total matches
    112.        
    113.    
    114.         Label3.Caption = Str(i) & " Possible Problematic Registry Keys"
    115.        
    116.         Text4.Text = "Scanning Complete" & Str(i) & " Possible Problematic Registry Keys Detected."
    117.     End If
    118.  End Sub

    Now basically what it does is searches for registry keys that are inputed in text1 and ptus the result in listreg.

    Now is there a way to change it so instead of searching for one at a time in a textbox, it searchs from keys loaded to a listbox one at a time.

    Can anyone tell me how to do that?

    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    a simple change can do it

    Change the sub header to
    Code:
    Private Sub SearchRegMachine(Byval strSearch as String)
    Remove the
    Dim strSearch As String and strSearch = Text1.Text within the sub.

    say you list is list1
    Code:
    Dim i As Long
        
        For i = 0 To list1.ListCount - 1
            SearchRegMachine list1.List(i)
        Next
    would do it

    IIF(Post.Rate > 0 , , )

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Ok, thanks.

    Umm I get an arugment not optional error when I try to call the sub.

    Since the subs name changed, how would I call it now?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Searching with a list box instead of a textbox.

    Quote Originally Posted by Justin M
    Umm I get an arugment not optional error when I try to call the sub.
    Look at the help for the error - it tells you that the sub/function needs more parameters than you passed to it.

    Since the subs name changed,
    erm.. it was SearchRegMachine, and still is.

    how would I call it now?
    See the second half of zeezee's post (from "say" onwards), it contains an example - which would not give the error you got.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    I think I see what you mean, but when I go to scan the registry now I get the arrugment not optional and it highlights the code "Call SearchRegMachine"

    in the block of code

    VB Code:
    1. Private Sub startscanregbutton_Click()
    2. listreg.Clear
    3. Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
    4.  Combo1.ListIndex = 0
    5.  
    6.    Call SearchRegMachine
    7.    
    8.    Combo1.ListIndex = 1
    9.     Call SearchRegMachine
    10.    
    11.     Text3.Text = Text3.Text & vbNewLine & Text4.Text
    12. End Sub

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Searching with a list box instead of a textbox.

    Of course it does - compare that line (in fact, lines 4 to 9) with zeezee's example.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    But his code to switch from text1 to the list was put in the sub - the SearchRegMachine

  8. #8
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Searching with a list box instead of a textbox.

    Quote Originally Posted by Justin M
    But his code to switch from text1 to the list was put in the sub - the SearchRegMachine
    Try this

    Code:
      Private Sub SearchRegMachine()
    
      Dim i As Integer
        Dim lngKeyHandle As Long
        Dim lngResult As Long
        Dim lngCurIdx As Long
        Dim strValue As String
        Dim lngValueLen As Long
        Dim strClass As String
        Dim lngClassLen As Long
        Dim strResult As String
        Dim lngTime As FILETIME
        Dim strSearch As String
        Dim intSearchLen As Integer
        Dim blnMatch As Boolean
        
        
         'PlaySound App.path & "\StartReg.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
        i = 0
        ' Clear the current results
        
        ' Assign the new string to search for
        'strSearch = Text1.Text
        Dim intListCount As Integer
        For intListCount = 0 To List1.ListCount
           strSearch = List1.List(intListCount)
            intSearchLen = Len(strSearch)
        
        ' Open the Root Branch to search
        lngResult = RegOpenKeyEx(strBranch, _
                "", _
                 0&, _
                 KEY_READ, _
                 lngKeyHandle)
        
        If lngResult <> ERROR_SUCCESS Then
            MsgBox "Cannot open key.", , "Search Registry Keys"
        Else
        ' If the Root branch can be opened, disable
        ' the buttons and begin the search
            startscanregbutton.Enabled = False
           ' Command2.Enabled = False
            listreg.Enabled = False
            Reg.MousePointer = 11
            
            lngCurIdx = 0
            Do
                lngValueLen = 2000
                strValue = String(lngValueLen, 0)
                lngClassLen = 2000
                strClass = String(lngClassLen, 0)
            
                ' Enumerate all the sub keys
                lngResult = RegEnumKeyEx(lngKeyHandle, _
                     lngCurIdx, _
                     ByVal strValue, _
                     lngValueLen, _
                     0&, _
                     ByVal strClass, _
                     lngClassLen, _
                     lngTime)
               
                ' Increment the index of found keys
                lngCurIdx = lngCurIdx + 1
            
                If lngResult = ERROR_SUCCESS Then
                    ' Trim the current key to its actual length
                    strResult = Left(strValue, lngValueLen)
                    
                    ' Eliminate case if the search is insensitive
                    blnMatch = False
                    strValue = strResult
                    If Check1.Value = 0 Then
                        strResult = LCase(strResult)
                        strSearch = LCase(strSearch)
                    End If
    
                    ' Compare strings based upon search type
                    Select Case Combo2.ListIndex
                        Case 0
                            ' Check if any portion of the search string is found.
                            If InStr(strResult, strSearch) Then blnMatch = True
                        Case 1
                            ' Check if an exact match is found.
                            If strResult = strSearch Then blnMatch = True
                        'Case 2
                            ' Check if the search string matches the
                            ' left portion of the key string.
                           ' If Left(strResult, intSearchLen) = strSearch Then blnMatch = True
                       ' Case Else
                            ' Check if the search string matches the
                            ' right portion of the key string.
                            'If Right(strResult, intSearchLen) = strSearch Then blnMatch = True
                    End Select
                    
                    ' Populate the list with keys that match
                    ' the search criteria
                    If blnMatch Then
                        i = i + 1
                        listreg.AddItem strValue
                    End If
                End If
            
            ' Keep looking for more keys
            Loop While lngResult = ERROR_SUCCESS
            ' Close the Root Branch
            lngResult = RegCloseKey(lngKeyHandle)
        
            ' Enable the buttons
            Reg.MousePointer = 0
            listreg.Enabled = True
            startscanregbutton.Enabled = True
          '  Command2.Enabled = True
            
            ' Display the total matches
            
        
            Label3.Caption = Str(i) & " Possible Problematic Registry Keys"
           
            Text4.Text = "Scanning Complete" & Str(i) & " Possible Problematic Registry Keys Detected."
        End If
        Next
     End Sub

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Searching with a list box instead of a textbox.

    Quote Originally Posted by Justin M
    But his code to switch from text1 to the list was put in the sub - the SearchRegMachine
    No it wasn't - zeezee's example (from "say" onwards) was example usage, and is the equivalent of lines 4 to 9 of your code in post #5, but without the errors.

    All you needed to do was change list1 to Combo1.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Ok do you mean I add this code then

    Dim ix As Long

    For ix = 0 To Combo1.ListCount - 1
    SearchRegMachine Combo1.List(ix)
    Next


    But I still get an argument not optional error when I call the SearchRegMachine sub

  11. #11
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    Hey Justin, can you post the New SearchRegMachine again.
    At least the sub header ?

    IIF(Post.Rate > 0 , , )

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Absolutely

    VB Code:
    1. Private Sub SearchRegMachine(ByVal strSearch As String)
    2.  
    3.         Dim i As Integer
    4.  
    5.      Dim lngKeyHandle As Long
    6.  
    7.           Dim lngResult As Long
    8.    
    9.           Dim lngCurIdx As Long
    10.  
    11.           Dim strValue As String
    12.  
    13.           Dim lngValueLen As Long
    14.  
    15.           Dim strClass As String
    16.  
    17.           Dim lngClassLen As Long
    18.  
    19.           Dim strResult As String
    20.  
    21.           Dim lngTime As FILETIME
    22.  
    23.           Dim strSearch As String
    24.  
    25.           Dim intSearchLen As Integer
    26.  
    27.           Dim blnMatch As Boolean
    28.  
    29.          
    30.  
    31.          
    32.  
    33.            'PlaySound App.path & "\StartReg.WAV", ByVal 0&, SND_FILENAME Or SND_ASYNC
    34.  
    35.           i = 0
    36.  
    37.           ' Clear the current results
    38.  
    39.          
    40.  
    41.           ' Assign the new string to search for
    42.  
    43.          'strSearch = Text1.Text
    44.          
    45.          Dim ix As Long
    46.    
    47.     For ix = 0 To Combo1.ListCount - 1
    48.         SearchRegMachine Combo1.List(ix)
    49.     Next
    50.  
    51.           intSearchLen = Len(strSearch)
    52.  
    53.  
    54.           ' Open the Root Branch to search
    55.  
    56.           lngResult = RegOpenKeyEx(strBranch, "", 0&, KEY_READ, lngKeyHandle)
    57.  
    58.  
    59.           If lngResult <> ERROR_SUCCESS Then
    60.  
    61.               MsgBox "Cannot open key.", , "Search Registry Keys"
    62.  
    63.           Else
    64.  
    65.           ' If the Root branch can be opened, disable
    66.  
    67.           ' the buttons and begin the search
    68.  
    69.               startscanregbutton.Enabled = False
    70.  
    71.              ' Command2.Enabled = False
    72.  
    73.               listreg.Enabled = False
    74.  
    75.               Reg.MousePointer = 11
    76.  
    77.              
    78.  
    79.               lngCurIdx = 0
    80.  
    81.               Do
    82.  
    83.                   lngValueLen = 2000
    84.  
    85.                   strValue = String(lngValueLen, 0)
    86.  
    87.                   lngClassLen = 2000
    88.  
    89.                   strClass = String(lngClassLen, 0)
    90.  
    91.              
    92.  
    93.                   ' Enumerate all the sub keys
    94.  
    95.                   lngResult = RegEnumKeyEx(lngKeyHandle, lngCurIdx, ByVal strValue, lngValueLen, 0&, ByVal strClass, lngClassLen, lngTimex)
    96.  
    97.                  
    98.  
    99.                   ' Increment the index of found keys
    100.  
    101.                   lngCurIdx = lngCurIdx + 1
    102.  
    103.              
    104.  
    105.                   If lngResult = ERROR_SUCCESS Then
    106.  
    107.                       ' Trim the current key to its actual length
    108.  
    109.                       strResult = Left(strValue, lngValueLen)
    110.  
    111.                      
    112.  
    113.                       ' Eliminate case if the search is insensitive
    114.  
    115.                       blnMatch = False
    116.  
    117.                       strValue = strResult
    118.  
    119.                       If Check1.Value = 0 Then
    120.  
    121.                           strResult = LCase(strResult)
    122.  
    123.                           strSearch = LCase(strSearch)
    124.  
    125.                       End If
    126.  
    127.        
    128.  
    129.                       ' Compare strings based upon search type
    130.  
    131.                       Select Case Combo2.ListIndex
    132.  
    133.                           Case 0
    134.  
    135.                               ' Check if any portion of the search string is found.
    136.  
    137.                               If InStr(strResult, strSearch) Then blnMatch = True
    138.  
    139.                           Case 1
    140.  
    141.                               ' Check if an exact match is found.
    142.  
    143.                               If strResult = strSearch Then blnMatch = True
    144.  
    145.                           'Case 2
    146.  
    147.                               ' Check if the search string matches the
    148.  
    149.                               ' left portion of the key string.
    150.  
    151.                              ' If Left(strResult, intSearchLen) = strSearch Then blnMatch = True
    152.  
    153.                          ' Case Else
    154.  
    155.                               ' Check if the search string matches the
    156.  
    157.                               ' right portion of the key string.
    158.  
    159.                               'If Right(strResult, intSearchLen) = strSearch Then blnMatch = True
    160.  
    161.                       End Select
    162.  
    163.                      
    164.  
    165.                       ' Populate the list with keys that match
    166.  
    167.                       ' the search criteria
    168.  
    169.                       If blnMatch Then
    170.  
    171.                           i = i + 1
    172.  
    173.                           listreg.AddItem strValue
    174.  
    175.                       End If
    176.  
    177.                   End If
    178.  
    179.              
    180.  
    181.               ' Keep looking for more keys
    182.  
    183.               Loop While lngResult = ERROR_SUCCESS
    184.  
    185.               ' Close the Root Branch
    186.               lngResult = RegCloseKey(lngKeyHandle)
    187.  
    188.          
    189.  
    190.               ' Enable the buttons
    191.  
    192.               Reg.MousePointer = 0
    193.  
    194.               listreg.Enabled = True
    195.  
    196.               startscanregbutton.Enabled = True
    197.  
    198.             '  Command2.Enabled = True
    199.  
    200.              
    201.  
    202.               ' Display the total matches
    203.  
    204.              
    205.  
    206.          
    207.  
    208.               Label3.Caption = Str(i) & " Possible Problematic Registry Keys"
    209.  
    210.              
    211.  
    212.               Text4.Text = "Scanning Complete" & Str(i) & " Possible Problematic Registry Keys Detected."
    213.  
    214.           End If
    215.  
    216.        End Sub

  13. #13
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.


    You are doing it in the wrong place.
    See the Loop is inside the sub and calling the same sub. It should make your app in a infinite loop with a stack over flow


    Code:
    Dim ix As Long
        For ix = 0 To Combo1.ListCount - 1
            SearchRegMachine Combo1.List(ix)
        Next
    This should come out of the Sub SearchRegMachine

    was there a place you called this sub earlier changing its header?
    Thats where this should come.
    For an Example, if there is a Command Button to Start the search, that's where this part should come.
    Anyway, even in the place it is now, cant imagine why an Argument not Optional comes

    try and see
    IIF(Post.Rate > 0 , , )

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Ohh, the sub gets called here

    VB Code:
    1. Private Sub startscanregbutton_Click()
    2. listreg.Clear
    3. Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
    4.  Combo1.ListIndex = 0
    5.  
    6.    Call SearchRegMachine
    7.    
    8.    Combo1.ListIndex = 1
    9.     Call SearchRegMachine
    10.    
    11.     Text3.Text = Text3.Text & vbNewLine & Text4.Text
    12. End Sub

  15. #15
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    You see, thats why its not wroking
    Code:
    Call SearchRegMachine
    has no arguments, Thats the reason.

    Ok that event procedure should look like this
    Code:
    Private Sub startscanregbutton_Click()
        Dim ix As Long
        
        listreg.Clear
        Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
        
        For ix = 0 To Combo1.ListCount - 1
            SearchRegMachine Combo1.List(ix)
        Next
        
        
        Text3.Text = Text3.Text & vbNewLine & Text4.Text
    End Sub
    few tips.

    Code:
    Label3.Caption = Str(i) & " Possible Problematic Registry Keys"
    Text4.Text = "Scanning Complete" & Str(i) & " Possible Problematic Registry Keys Detected."
    This part inside the SearchRegMachine should also come out.

    In the Private Sub startscanregbutton_Click() , after the loop, put it like this

    Code:
    Label3.Caption = Str(listreg.ListCount) & " Possible Problematic Registry Keys"
    Text4.Text = "Scanning Complete" & Str(listreg.ListCount) & " Possible 
    
    Problematic Registry Keys Detected."
    Try and see
    IIF(Post.Rate > 0 , , )

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Ok, but I get an error, that variable lngTimex is not defined inthe line of code.

    VB Code:
    1. lngResult = RegEnumKeyEx(lngKeyHandle, lngCurIdx, ByVal strValue, lngValueLen, 0&, ByVal strClass, lngClassLen, lngTimex)

    this is in the searchregmachiensub

  17. #17
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    that variable lngTimex is not defined inthe line of code.
    Hmm. the Error is self explanatory. You haven't defined the variable.
    Check that line against the code in your first post. You will see the difference.

    IIF(Post.Rate > 0 , , )

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Well which sub should I use, the one in my first post or the modified one.

    Cause the one in the first post only scans for reg keys manually enter in text1. I would like to have it search for each item in a list2 lsitbox instead.

  19. #19
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    no no.
    Lets resolve it like this.
    We changed the sub in post #1 to the new one.
    What we changed was, the sub header, and the string to search part.
    Nothing else
    You need the new one to search for multiple keys. right?

    So this last error , is due to a change, which was not mentioned here.
    And as the error says, you haven't declared the variable.
    But if you compare that line with the new one, you should the spot the error.
    Its pretty simple.

    Don't get this wrong, I can tell exactly how to resolve the error, but since this a simple error , and you being unable to resolve that, is not good. Thats why I think its better you understand whats the error and how to resolve it.
    (BTW If you need to resolve it, just say, I ll tell how)

    Cheers!

    IIF(Post.Rate > 0 , , )

  20. #20

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    lol i think I see the prob lngTimex is not real.

    It was a typo its supposed to be lngTime

    So does this mean I still need to enter keys in text1? But now I just click on a item in list2 and it goes to text1?

  21. #21
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    OK.

    What You need is to search multiple entries right?
    So what you should do is , load the required search values to the Combo box (Combo1)
    Then do the search. You can remove the Text Box I think.
    I cant tel this exactly without seeing the full app or at least a screen shot.
    Just a hint

    IIF(Post.Rate > 0 , , )

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    Well what the combo box does is set what you search in.

    Like for one instance I search in the HKEY_LOCAL_MACHINE and another time in the
    HKEY_USERS

    which is why I had the code

    Combo1.ListIndex = 0


    Combo1.ListIndex = 1
    in the button code to search.

  23. #23
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    ok clarification
    Quote Originally Posted by In Post #1
    Now is there a way to change it so instead of searching for one at a time in a textbox, it searchs from keys loaded to a listbox one at a time.
    this asks how to do the search for multiple values in a list box.
    I am assuming that this Combo1 is the list you have mentioned,
    Is that right?

    IIF(Post.Rate > 0 , , )

  24. #24

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    my combo1 is a drop down box.

    list2 is where all the keys I want to search for are.

  25. #25
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    so the values to be searched are in list2?

    so you have some registry keys in List2, and you want to search whether these keys are in the registry?

    If this is true, what is Combo1?

    IIF(Post.Rate > 0 , , )

  26. #26

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    ITs where you can pick between to search in the HKEY_LOCAL_MACHINE OR the

    HKEY_USERS

  27. #27
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    ok next question, if the Combo1 has the starting point and list1 has the keys, where do these values get used in your SearchRegMachine method?
    I believe that the heart of this method is RegOpenKeyEx and RegEnumKeyEx

    If that is so, in which part are these values in Combo1 and List1 are used?

    Can you give an example on how you intend to use them?

    IIF(Post.Rate > 0 , , )

  28. #28

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    list2 has the keys

    see the searchregmachine is currently set up to work with text1 which only holds 1 key at a time. I was wondering how to get it so it would search they keys in list2.

    Or have it so when the scan button is pressed, each key in the list2 is put in the text1.text and each key is scanned for one at a time.

  29. #29
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    ok, i m confused

    This the code for searching the list1
    Code:
    Private Sub startscanregbutton_Click()
        Dim ix As Long
        
        listreg.Clear
        Text3.Text = Text3.Text & vbNewLine & "Scanning in progress...Please Wait.."
        
        For ix = 0 To List1.ListCount - 1
            SearchRegMachine List1.List(ix)
        Next
        
        
        Text3.Text = Text3.Text & vbNewLine & Text4.Text
    End Sub
    but still, i dont know where Combo1 comes to the drama
    Try above code and see if it works.

    IIF(Post.Rate > 0 , , )

  30. #30

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    lol the combo 1 is where you pick what part of the registry to scan, its in the scanregmachine.

    that above code should be list2, i just noticed that now lol

  31. #31
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    lol the combo 1 is where you pick what part of the registry to scan, its in the scanregmachine.
    ok there is a Combo2 there, but not Combo1,
    It was there and we removed it i think.

    ok ok, now does it work correctly with above code changed to list2?

    IIF(Post.Rate > 0 , , )

  32. #32

    Thread Starter
    PowerPoster
    Join Date
    May 2006
    Posts
    2,295

    Re: Searching with a list box instead of a textbox.

    It does scan I can see that.

    The odd thing, which may be in the prog itself since i got this code from the microsoft webiste.

    It does not pick up things.

    Though I am not too sure how to format the items.

    I enter things like this in list2
    HKEY_CURRENT_USER\software\winspykiller mscheduledscan

    or even HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Default_Page_Url

    but it does not pick it up.

  33. #33
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: Searching with a list box instead of a textbox.

    hmm.
    No idea
    Since I haven't done this Reg scan things before, I cant help you on that part.

    Anyway, if thats a problem, may be you can put up another thread for that.

    And If you think your original question has a solution , you may resolve the thread.



    IIF(Post.Rate > 0 , , )

  34. #34
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Searching with a list box instead of a textbox.

    Justin: Have you read and understood the code you obtained?

    I don't think it's doing what you expect and, as it is, will not work.

    This call:
    Code:
        lngResult = RegOpenKeyEx(strBranch, _
                "", _
                 0&, _
                 KEY_READ, _
                 lngKeyHandle)
    will fail with a Type Mismatch since it expects a Long value as opposed to a string for the Root Key,
    eg one of these:
    Code:
    Private Const HKEY_CLASSES_ROOT = &H80000000
    Private Const HKEY_CURRENT_CONFIG = &H80000005
    Private Const HKEY_CURRENT_USER = &H80000001
    Private Const HKEY_LOCAL_MACHINE = &H80000002
    '
    ' and in your code, for example:
    '
        lngKey = HKEY_CURRENT_USER
        lngResult = RegOpenKeyEx(lngKey, _
                "", _
                 0&, _
                 KEY_READ, _
                 lngKeyHandle)
    Also this statement
    Code:
     If InStr(strResult, strSearch) Then blnMatch = True
    '
    ' Should be
    '
     If InStr(strSearch, strResult) Then blnMatch = True
    The code only enumerates keys one level down from the root
    eg
    HKEY_CURRENT_USER\Software
    so if you specified
    HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Default_Page_Url

    as your search, and looked for a partial match (ie Combo2.ListIndex = 0) it would find 'Software' and insert that into the ListBox. If you performed an exact match (Combo2.ListIndex = 1) it would not find anything.

    To eumerate all the way down the structure would need some fairly significant modifications to the existing code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width