|
-
Jan 6th, 2005, 05:15 PM
#1
Thread Starter
Member
Search For All Exe's
How can i search the computer for all the exe files?
So the program returns the path of the file, mabye into a listbox, all a text file, thats not the important bit.
Any Ideas how to search the computer for .exe files?
And would i be able to change exe to any other file type ?
thanks
i ParadoX
Last edited by iParadox; Jan 7th, 2005 at 01:13 PM.
Reason: to resolve the thread
-
Jan 6th, 2005, 05:52 PM
#2
Re: Search For All Exe's
Why would you want to change the file type?
-
Jan 6th, 2005, 06:08 PM
#3
Thread Starter
Member
Re: Search For All Exe's
I dont mean like change the file type of the EXE, i meant like change the search criteria to search for jpg or Wav files.
But its looking for EXE's thats i need to be able to do
Any ideas?
-
Jan 6th, 2005, 06:45 PM
#4
Re: Search For All Exe's
Are you talking about your VB program emulating the Windows Search?
-
Jan 6th, 2005, 07:50 PM
#5
Hyperactive Member
Re: Search For All Exe's
You could use the VB dir function to find a file pattern in a specific directory.
You could use the DOS dir function with the /S option to find files in subdirectories too, and any other option to format the output, and redirect output to a file. Then open the file and have your way with it.
There's also an API call to FindFile or something like that, but I forget. Not much help there, but you could look or someone else might remember what it is.
-
Jan 6th, 2005, 07:55 PM
#6
-
Jan 6th, 2005, 08:00 PM
#7
-
Jan 7th, 2005, 08:21 AM
#8
Thread Starter
Member
Re: Search For All Exe's
Thanks fo the help, the link;
http://www.vbforums.com/showthread.php?t=244915
Really helped, as that program is nearly what i want.
Then only thing that i want to change, and i cant figure out how is:
1 The program wont search sub-directories, can the code be edited to be able to do that.
2 I cant Figure out how to change the Program so it only Searches for Exe Files, can anyone help me on how to change the code?
If you do not want to download the File then the code is below, Thanks!
iParadoX
VB Code:
Private Sub Command1_Click()
Dim strStartPath As String
strStartPath = "C:\" 'ENTER YOUR START FOLDER HERE
ListFolder strStartPath
End Sub
Private Sub ListFolder(sFolderPath As String)
Dim FS As New FileSystemObject
Dim FSfolder As Folder
Dim File As File
Dim i As Integer
Set FSfolder = FS.GetFolder(sFolderPath)
Text1.Text = ""
For Each File In FSfolder.Files
DoEvents
Text1.Text = Text1.Text & File & vbCrLf
Next File
Set FSfolder = Nothing
End Sub
Last edited by iParadox; Jan 7th, 2005 at 09:00 AM.
Reason: made a small mistake
-
Jan 7th, 2005, 11:58 AM
#9
Thread Starter
Member
Re: Search For All Exe's
I can now get a listbox and populate it with the names of the exe files, but this method does not show the whole path of the application, which i desperatly need it to do.
Also also will only search in one directory, and not search the subdirectories, can i edit the code to allow that?
Thanks a lot
the code is
VB Code:
Private Sub ListFiles(strPath As String, Optional Extention As String)
'Leave Extention blank for all files
Dim File As String
If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
If Trim$(Extention) = "" Then
Extention = "*.*"
ElseIf Left$(Extention, 2) <> "*." Then
Extention = "*." & Extention
End If
File = Dir$(strPath & Extention)
Do While Len(File)
List1.AddItem File
File = Dir$
Loop
End Sub
Private Sub Form_Load()
ListFiles "C:\", "txt"
End Sub
-
Jan 7th, 2005, 12:02 PM
#10
Re: Search For All Exe's
Did you try the second (API way) example in that thread? It seems to do what you want.
-
Jan 7th, 2005, 01:09 PM
#11
Thread Starter
Member
Re: Search For All Exe's
thanks For all your Help
iParadoX
-
Jan 7th, 2005, 01:54 PM
#12
Addicted Member
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
|