我欲乘风yecheng.blog.chinaunix.net
yecheng_110
全部博文(78)
2007年(53)
2006年(25)
DT27
jolinok
ylke2007
saintdra
zhxd
大鬼不动
tntcheng
chenkeac
flb_2001
yyfq521
bluesky0
zjq5688
w1818618
168Kill
myoeoo
bolebdms
sxzf168
11qq22ww
分类: C/C++
2007-04-13 14:12:14
BOOL DeleteDirectory(LPCTSTR lpszPath){ WIN32_FIND_DATA FindData; HANDLE hFile; TCHAR szFile[MAX_PATH]; TCHAR szFullName[MAX_PATH]; BOOL bReturn = TRUE; if(IsDirectory(lpszPath)) {
//You can use _sntprintf. sntprintf(szFile,MAX_PATH,_T("%s\\*"),lpszPath); hFile = FindFirstFile(szFile,&FindData); if(hFile == INVALID_HANDLE_VALUE) { bReturn = FALSE; } else { do { if(_tcscmp(FindData.cFileName, _T(".")) == 0 || _tcscmp(FindData.cFileName, _T("..")) == 0 ) { continue; } //absolute path. sntprintf(szFullName,MAX_PATH,_T("%s\\%s"),lpszPath,FindData.cFileName); if(!DeleteDirectory(szFullName)) { bReturn = FALSE; } } while(FindNextFile(hFile,&FindData)); FindClose(hFile); } } //HKLM\SYSTEM\CurrentControlSet\Control\SessionManager\PendingFileRenameOperations if(!MoveFileEx(lpszPath,NULL,MOVEFILE_DELAY_UNTIL_REBOOT)) { bReturn = FALSE; } return bReturn;}BOOL IsDirectory(LPCTSTR lpszPath){ DWORD dwAttribute; dwAttribute = GetFileAttributes(lpszPath); if(dwAttribute == 0xffffffff) { return FALSE; } return (dwAttribute & FILE_ATTRIBUTE_DIRECTORY);}
上一篇:厦门的雨季
下一篇:字符的趣事
登录 注册