#include <stdio.h> #include <windows.h> int main() { int nok; char strsrc[]="D:\\A\0"; char strdst[]="D:\\B\0"; char strtitle[]="File Copying"; DWORD ret; SHFILEOPSTRUCT fileop; fileop.hwnd=NULL; fileop.wFunc=FO_COPY; fileop.pFrom=strsrc; fileop.pTo=strdst; fileop.fFlags=FOF_ALLOWUNDO; fileop.hNameMappings=NULL; fileop.lpszProgressTitle=strtitle; ret=GetFileAttributes(strsrc); if(ret==-1) { printf("\n 文件不存在\n"); } switch(ret) { case FILE_ATTRIBUTE_ARCHIVE: printf("\n 存档文件\n"); break; case FILE_ATTRIBUTE_COMPRESSED: printf("\n 压缩文件\n"); break; case FILE_ATTRIBUTE_DIRECTORY: printf("\n 目录\n"); break; case FILE_ATTRIBUTE_ENCRYPTED: printf("\n 加密文件\n"); break; case FILE_ATTRIBUTE_HIDDEN: printf("\n 隐藏文件\n"); break; case FILE_ATTRIBUTE_NORMAL: printf("\n 没有属性设置\n"); break; case FILE_ATTRIBUTE_READONLY: printf("\n 只读文件\n"); break; case FILE_ATTRIBUTE_SYSTEM: printf("\n 系统文件\n"); break; } nok=SHFileOperation(&fileop); if(nok) { printf("出错: %d\n",nok); } else { printf("操作成功结束!\n"); } if(fileop.fAnyOperationsAborted) { printf("撤销文件操作!\n"); } return 0; }