|
-
Jan 2nd, 2002, 11:50 AM
#1
Thread Starter
New Member
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!!
-
Jan 2nd, 2002, 12:47 PM
#2
Junior Member
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.
-
Jan 2nd, 2002, 12:52 PM
#3
Junior Member
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
-
Jan 2nd, 2002, 12:53 PM
#4
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|