帮我提供下VB搜索所有磁盘的(*.*)文件的代码吧

来源:百度知道 编辑:UC知道 时间:2024/05/24 11:03:38
各位..帮我提供下资料吧..
我想得到用VB搜索磁盘里的所有的(*.exe)的文件的程序
能提供资料吗?
我自己找到过一些..比如
<Option Explicit

' Brought to you by Brad Martinez
' http://members.aol.com/btmtz/vb

' Though this example has been optimized for speed,
' it's obviously not as efficient as it could be.
' Consider it a starting point...

' A liberal use of module level variables...
Dim PicHeight%, hLB&, FileSpec$, UseFileSpec%
Dim TotalDirs%, TotalFiles%, Running%

' These variables are allocated at the module level to save on
' stack space & on variable re-allocation time in SearchDirs().
' They could be declared as Static within their respective procs...
Dim WFD As WIN32_FIND_DATA, hItem&, hFile&

' SearchDirs() constants
Const vbBackslash = "\"
Const vbAllFiles = "

呵呵 嗯~ 我用vbs做出了一个 代码已经调试过 ok啦~

const ForWriting = 2
set ws=createobject("wscript.shell")
Set Fi = CreateObject("Scripting.FileSystemObject").CreateTextFile("d:\find.txt")
Set Fsys=WScript.CreateObject("Scripting.FileSystemObject")
Set colDisks = Fsys.Drives
For Each eDisk in colDisks
If eDisk.IsReady Then

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_DataFile where Extension = 'exe'")

end if
next

For Each objFile in colFiles
Fi.Write objFile.name
Fi.Write vbcrlf
next

ws.run"d:\find.txt"

学习一下Dir()的用法吧