Results 1 to 4 of 4

Thread: Few VB Questions

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    13

    Question Few VB Questions

    I've got a few questions - extra points go to anyone who can answer all of them:
    1) Can I call reg.exe with it's arguments from within a VB exe using shell (or something else)?
    2) How do I search for a certain folder name on a Windows system from within VB - I'm looking for the folder names of all the users of a Windows XP system profile folders, so it's not a blind search since I know the folder info up to that point.
    3) Using the Windows registry API (or any other means if you know) how do I search for a registry key - similair to the question above, I'm looking for the key name and not the data values stored in the keys. I know the partial key name, so I can point it to the right place, I just need to know what branches come off that place.
    thanks!!

  2. #2
    Junior Member
    Join Date
    Jan 2002
    Location
    Shrewsbury, Shropshire, UK.
    Posts
    30
    1) Yep. Don't see why not. If you get any grief, dynamically create yourself a batch file, which does the work for you, and then shell to the batch file:

    open "\batch.bat" for output as #1
    print #1,"reg.exe -flags_etc_etc"
    close #1
    shell "\batch.bat"

    2) Use the DIR command.
    Returns a String representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive.
    3) I think you need the Enumerate Registry API function call. Search google with "Enumerate Registry Entries" there is an article on MSDN that gives you the API calls you are looking for. I THINK this is what you need!

    HTH.
    Mark.
    Ouch. My head hurts.

  3. #3
    Junior Member
    Join Date
    Jan 2002
    Location
    Shrewsbury, Shropshire, UK.
    Posts
    30
    Here is some more stuff on the DIR command (from MSDN). Note that you can use wildcards. It's an under-used command that most people overlook. Personally, I think it rocks!


    Code:
    ' Display the names in C:\ that represent directories.
    MyPath = "c:\"   ' Set the path.
    MyName = Dir(MyPath, vbDirectory)   ' Retrieve the first entry.
    Do While MyName <> ""   ' Start the loop.
       ' Ignore the current directory and the encompassing directory.
       If MyName <> "." And MyName <> ".." Then
          ' Use bitwise comparison to make sure MyName is a directory.
          If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
             Debug.Print MyName   ' Display entry only if it
          End If   ' it represents a directory.
       End If
       MyName = Dir   ' Get next entry.
    Loop
    Ouch. My head hurts.

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    13
    Thanks!
    Could you explain how to use the DIR function to do what I asked (or point me to some good documentation of it)? I'm going to play with the RegEnumKeyEx to see if that does what I'm looking for.


    Edited: thanks for psoting the code - that should do it!!

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