Delphi -- 从剪贴板拷贝文件示例代码
2011-03-09 23:57
411 查看
uses Windows, Clipbrd, ShellAPI ....;
var
DropHandle, DropEffect, Effect : HDROP;
FileCount:Integer;
Counter:Integer;
FileName:array [0..MAX_PATH] of char;
const
DROPEFFECT_NONE = 0;
DROPEFFECT_COPY = 1;
DROPEFFECT_MOVE = 2;
DROPEFFECT_LINK = 4;
DROPEFFECT_SCROLL = $80000000;
begin
OpenClipboard(0);
DropEffect := RegisterClipboardFormat('Preferred DropEffect');
DropHandle := GetClipboardData(CF_HDROP);
if DropHandle>0 then
begin
Effect := GetClipboardData(DropEffect);
if Effect=0 then Effect := DROPEFFECT_COPY
else Effect := PDWORD(Effect)^;
case Effect of
DROPEFFECT_COPY + DROPEFFECT_LINK:ShowMessage('Copy');
DROPEFFECT_MOVE:ShowMessage('Move');
end;
FileCount:=DragQueryFile(DropHandle,Cardinal(-1),nil,0);
for Counter := 0 to FileCount-1 do
begin
DragQueryFile(DropHandle, Counter, FileName, sizeof(FileName));
ShowMessage(FileName);
end;
end;
CloseClipboard;
end;
var
DropHandle, DropEffect, Effect : HDROP;
FileCount:Integer;
Counter:Integer;
FileName:array [0..MAX_PATH] of char;
const
DROPEFFECT_NONE = 0;
DROPEFFECT_COPY = 1;
DROPEFFECT_MOVE = 2;
DROPEFFECT_LINK = 4;
DROPEFFECT_SCROLL = $80000000;
begin
OpenClipboard(0);
DropEffect := RegisterClipboardFormat('Preferred DropEffect');
DropHandle := GetClipboardData(CF_HDROP);
if DropHandle>0 then
begin
Effect := GetClipboardData(DropEffect);
if Effect=0 then Effect := DROPEFFECT_COPY
else Effect := PDWORD(Effect)^;
case Effect of
DROPEFFECT_COPY + DROPEFFECT_LINK:ShowMessage('Copy');
DROPEFFECT_MOVE:ShowMessage('Move');
end;
FileCount:=DragQueryFile(DropHandle,Cardinal(-1),nil,0);
for Counter := 0 to FileCount-1 do
begin
DragQueryFile(DropHandle, Counter, FileName, sizeof(FileName));
ShowMessage(FileName);
end;
end;
CloseClipboard;
end;
相关文章推荐
- delphi 拷贝网络共享文件 代码
- 导出csv文件代码示例
- Java实现拷贝文件详细代码
- 统计Linux 中文件和文件夹/目录的数量(示例代码)
- php示例代码之读取文件
- asp.net上传execl文件后,在页面上加载显示(示例代码)
- Asp.net 2.0 文件下载[支持多线程, 断点续传功能](示例代码下载)
- js 实现 input type="file" 文件上传示例代码
- python 文件读写模式r,r+,w,w+,a,a+的区别(附代码示例)
- JS获取浏览器语言动态加载JS文件示例代码
- 通过Javascript读取本地Excel文件内容的代码示例
- JS获取浏览器语言动态加载JS文件示例代码
- [导入]Asp.net 2.0 用C# 创建 PDF文件[引用] (示例代码下载)
- PHP上传Excel文件导入数据到MySQL数据库(详细示例代码)【原创】
- 《GOF设计模式》—代理(PROXY)—Delphi源码示例:更新前拷贝机制(copy-on-write)
- C#实现文件上传下载Excel文档示例代码
- vbs拷贝文件夹obj中和文件夹jpg下文件名相同的文件到model目录下代码
- php 生成自动创建文件夹并上传文件的示例代码
- ASP.NET 2.0 HttpHandler实现对某种文件类型权限保护(示例代码下载)
- Asp.net 2.0 用 FileUpload 控件实现多文件上传 用户控件(示例代码下载)