会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > VB文档 > 系统控制
在vb程序中如何获取剪贴板中所复制的文件的路径
发表日期:2003-12-09 00:00:00作者: 出处:  

1. 在Form1上放一个CommandButton和一个ListBox控件。

2. 在Form1中贴入以下代码。它会在ListBox中列出您在Windows Explorer中Copy的文件名。

Option Explicit

Private Const CF_HDROP = 15

Private Type POINT

  x As Long

  y As Long

End Type

Private Type DROPFILES

  pFiles As Long

  pt As POINT

  fNC As Long

  fWide As Long

End Type

Private Declare Function GlobalSize Lib "kernel32" _

  (ByVal hMem As Long) As Long

Private Declare Function GlobalLock Lib "kernel32" _

  (ByVal hMem As Long) As Long

Private Declare Function GlobalUnlock Lib "kernel32" _

  (ByVal hMem As Long) As Long

Private Declare Function OpenClipboard Lib "user32" _

  (ByVal hwnd As Long) As Long

Private Declare Function CloseClipboard Lib "user32" () As Long

Private Declare Function GetClipboardData Lib "user32" _

  (ByVal wFormat As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _

  (Destination As Any, Source As Any, ByVal Length As Long)

Private Sub ShowFilesOnClipboard()

  Dim lHandle As Long

  Dim lpResults As Long

  Dim lRet As Long

  Dim df As DROPFILES

  Dim strDest As String

  Dim lBufferSize As Long

  Dim arBuffer() As Byte

  Dim vNames As Variant

  Dim i As Long

  If OpenClipboard(0) Then

   lHandle = GetClipboardData(CF_HDROP)

   ' If you don't find a CF_HDROP, you don't want to process anything

   If lHandle > 0 Then

     lpResults = GlobalLock(lHandle)

    

     lBufferSize = GlobalSize(lpResults)

     ReDim arBuffer(0 To lBufferSize)

    

     CopyMemory df, ByVal lpResults, Len(df)

     Call CopyMemory(arBuffer(0), ByVal lpResults + df.pFiles, _

             (lBufferSize - Len(df)))

     If df.fWide = 1 Then

      ' it is wide chars--unicode

      strDest = arBuffer

     Else

      strDest = StrConv(arBuffer, vbUnicode)

     End If

     GlobalUnlock lHandle

     vNames = Split(strDest, vbNullChar)

     i = 0

     While Len(vNames(i)) > 0

      List1.AddItem vNames(i)

      i = i + 1

     Wend

   End If

  End If

  CloseClipboard

End Sub

Private Sub Command1_Click()

  Call ShowFilesOnClipboard

End Sub

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00153