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 & amp; "\ *. JPG")
Do
List2. AddItem FileName
FileName=Dir
Loop Until FileName=""
The Else
End the If
End the If
End Sub
CodePudding user response:
Fyi: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 the SYNCHRONIZE=& amp; H100000
Private Const INFINITE=& amp; 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 (the SYNCHRONIZE, 0, pId)
If pHnd & lt;> 0 Then
Do
R=WaitForSingleObject (pHnd, 1000) ', etc.
1 SECDoEvents
Loop While r & lt;> 0 And terminateFlag=False
Call the CloseHandle (pHnd)
End the If
End Sub
ShellWait "CMD. Exe dir/b/c/a, d/o - d d: \ mydir \ * JPG & gt; D: \ jpgfiles. TXT "
'd read file: \ jpgfiles. TXT content
CodePudding user response:
There is something wrong with the logic,If Dir (sBuffer)="" Then
FileName=Dir (sBuffer & amp; "\ *. JPG")
Do
......
When "If Dir (sBuffer)=" "Then" the conditions "set up", it means that "select directory" null and void, inaccessible,
Then how can you to execute the FileName=Dir (sBuffer & amp; Operations such as "\ *. JPG")?
CodePudding user response:
If Dir (sBuffer) & gt; "" Then