惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
罗磊的独立博客
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
博客园 - 聂微东
博客园_首页
爱范儿
爱范儿
量子位
博客园 - 三生石上(FineUI控件)
G
Google Developers Blog
Martin Fowler
Martin Fowler
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Y
Y Combinator Blog
Vercel News
Vercel News
腾讯CDC
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Cloudflare Blog
Engineering at Meta
Engineering at Meta

博客园 - avisnet

枚举浏览器窗口 关闭弹出式IE浏览器窗口编程 iframe自适应高度 - avisnet - 博客园 实现集合类的帮助函数 FormView 在对话框里面使用ON_UPDATE_COMMAND_UI映射工具条 automation服务器不能创建对象 汇率 无题 [转]猪的爱情故事 在新窗口中打开网页,同时关闭原有窗口 低层键盘钩子 C++编译器默认声明的成员函数 使用SqlServer模式的会话状态管理 Session Data Is Lost When You Use ASP.NET InProc Session State Mode [转]LINK : warning LNK4089: all references to "xxx.dll" discarded by /OPT:REF VC++中消除警告 const与typedef的中高级使用 在 ASP.NET 中执行 URL 重写
删除文件至回收站而不是永久删除
avisnet · 2006-09-23 · via 博客园 - avisnet

class CRecycleFile : private SHFILEOPSTRUCT
{
public:

 CRecycleFile()
 {
  memset((SHFILEOPSTRUCT*)this,0,sizeof(SHFILEOPSTRUCT));
  fFlags |= FOF_SILENT;                // don't report progress
  fFlags |= FOF_NOERRORUI;             // don't report errors
  fFlags |= FOF_NOCONFIRMATION;        // don't confirm delete
 }

 ~CRecycleFile()
 {
 }

 //
 // Send a file to the recycle bin. Args:
 //  - full pathname of file.
 //  - bDelete: if TRUE, really delete file (no recycle bin)
 //
 int Recycle(LPCTSTR pszPath, BOOL bDelete=FALSE)
 {
  TCHAR buf[_MAX_PATH + 1]; // allow one more character
  _tcscpy(buf, pszPath);    // copy caller's path name
  buf[_tcslen(buf)+1]=0;    // need two NULLs at end

  // Set SHFILEOPSTRUCT params for delete operation

  wFunc = FO_DELETE;                   // REQUIRED: delete operation
  pFrom = buf;                         // REQUIRED: which file(s)
  pTo = NULL;                          // MUST be NULL
  if(bDelete)
  {                       // if delete requested..
   fFlags &= ~FOF_ALLOWUNDO;         // ..don't use Recycle Bin
  }
  else
  {                             // otherwise..
   fFlags |= FOF_ALLOWUNDO;          // ..send to Recycle Bin
  }
  return SHFileOperation(this);        // do it!
 }