怎么用VB记录当前打开的文件夹路径?
来源:百度知道 编辑:UC知道 时间:2024/06/18 10:26:20
D:\aaa
E:\bbb\ccc
请问要怎么写呀?大家帮忙下,谢谢!
好的~~~
我来回答吧
哈哈~~
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim S As String
S = String(80, 0)
Call GetWindowText(hwnd, S, 80)
S = Left(S, InStr(S, Chr(0)) - 1)
If Len(S) > 0 Then Form1.List1.AddItem S
EnumWindowsProc = True
End Function
窗体代码~如下
Private Sub Command1_Click()
List1.Clear
EnumWindows AddressOf EnumWindowsProc, 0&
For i = 0 To List1.ListCount - 1
a = Dir$(List1.List(i), vbDirectory)
If a = "" Then
Else
Text1 = Text1 & List1.List(i) & vbCrLf
End If
Next i
End Sub
Private Sub Form_Load()