1,486
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command9_Click()
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
Dim FileName As String, mypath As String
szTitle = App.Path
With tBrowseInfo
.hWndOwner = Me.hWnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
If Dir(sBuffer) = "" Then
FileName = Dir(sBuffer & "\*.jpg")
Do
List2.AddItem FileName
FileName = Dir
Loop Until FileName = ""
Else
End If
End If
End Sub
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = &HFFFFFFFF
Private Sub ShellWait(cmd As String)
Dim pId As Long, pHnd As Long, r As Long
Form1.Refresh
pId = Shell(cmd, vbHide)
pHnd = OpenProcess(SYNCHRONIZE, 0, pId)
If pHnd <> 0 Then
Do
r = WaitForSingleObject(pHnd, 1000) '等1秒
DoEvents
Loop While r <> 0 And terminateFlag = False
Call CloseHandle(pHnd)
End If
End Sub
ShellWait "cmd.exe /c dir /b /a-d /o-d d:\mydir\*.jpg >d:\jpgfiles.txt"
'读文件d:\jpgfiles.txt的内容