如何使用VB建立一组资源管理器

如何使用VB建立一组资源管理器... 如何使用VB建立一组资源管理器 展开
 我来答
nurap82
2010-11-27 · TA获得超过268个赞
知道答主
回答量:368
采纳率:0%
帮助的人:252万
展开全部
'一、新建一个模块,复制下面代码到模块中
Option Explicit
Private Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "User32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetParent Lib "User32" (ByVal hWnd As Long) As Long

Private Type POINTAPI
X As Long
Y As Long
End Type

Function GetPath() As String
Dim lu_POINT As POINTAPI, Curwindow As Long, parentWnd As Long
Dim S As String, Hwd As Long, i As Integer
Dim oShellApp, oShellAppWindows, oWin

Call GetCursorPos(lu_POINT)
Curwindow = WindowFromPoint(lu_POINT.X, lu_POINT.Y)
parentWnd = GetParent(Curwindow)
Do While parentWnd <> 0
Curwindow = GetParent(parentWnd)
If Curwindow = 0 Then Exit Do
parentWnd = Curwindow
Loop
Hwd = parentWnd

Set oShellApp = CreateObject("Shell.Application")
Set oShellAppWindows = oShellApp.Windows
For Each oWin In oShellAppWindows
Debug.Print TypeName(oWin.Document)
If TypeName(oWin.Document) = "IShellFolderViewDual2" Then
If oWin.hWnd = Hwd Then
S = oWin.LocationURL
S = Replace(S, "file:///", "", , , vbTextCompare)
S = Replace(S, "/", "\")
S = Replace(S, "%20", " ")
GetPath = S
Exit Function
End If
End If
Next
Set oWin = Nothing
Set oShellApp = Nothing
Set oShellAppWindows = Nothing
End Function

'二、当一个对象拖动到资源管理器后 ,调用下面函数即可完成复制文件工作:

Private Sub List1_OLECompleteDrag(Effect As Long)
Dim i As Integer, S As String
Dim Path As String
Path = GetPath
With List1
For i = 0 To .ListCount - 1
If .Selected(i) = True Then
S = .List(i)
FileCopy S, Path & Path & Mid(S, InStrRev(S, "\"))
End If
DoEvents
Next
End With
MsgBox "文件复制完毕!"
End Sub
深圳云诺科技
2024-11-11 广告
作为深圳云诺互联科技有限公司的一员,我们推荐使用先进的项目进度管理工具Project来高效管理项目。该工具集计划、跟踪与调整功能于一体,助力团队明确各阶段任务,合理分配资源,实时监控进度。通过直观的甘特图展示,项目延期风险一目了然,便于及时... 点击进入详情页
本回答由深圳云诺科技提供
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式