自己比较喜欢的CCommon类

本文介绍了CCommon类的功能及使用方法,包括删除文件夹、广播消息、创建目录序列等功能。此外,还提供了多字节与宽字节字符转换、窗口居中、获取屏幕尺寸等实用操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//========================================================================
//TITLE:
// 自己比较喜欢的CCommon类
//AUTHOR:
// norains
//DATE:
// Monday 4-June-2007
//Environment:
// EVC4.0 + Standard SDK 4.2
// EVC4.0 + Standard SDK 5.0
//========================================================================

CCommon包含了一小部分编程时所需的操作,小巧精悍,主要是自己比较喜欢.CCommon类的完整源代码附录于本文之后,之前先让我们看看该类的函数具体用法.


1. DeleteDirectory(const TCHAR *pszPath)

和系统函数RemoveDirectory不同,该函数可以删除非空文件夹.

例:
CCommon::DeleteDirectory(TEXT("My Documents//Photo"));



2.BroadcastMessage(BroadcastType bcType, UINT wMsg, WPARAM wParam,LPARAM lParam)

广播消息.当bcType为BC_ALL时,向所有的窗口发送消息;BC_VISIBLE是发送给所有的可见窗口;BC_VISIBLE_NOBASEEXPLORER则是除了explorer以外的其它可视窗口.

例,关闭所有的除了explorer以外的所有可视窗口:
CCommon::BroadMessage(BC_VISIBLE_NOBASEEXPLORER,WM_CLOSE,NULL,NULL);



3.CreateDirectorySerial(TCHAR *pszPath)

创建文件夹序列.

例:
CCommon::CreateDirectorySerial(TEXT("Document//abc//d"));
该代码将依次建立如下文件夹:document,abc,d.



4.CompareSystime(const LPSYSTEMTIME lpTimeA,const LPSYSTEMTIME lpTimeB,LPSYSTEMTIME lpTimeResult)

比较系统时间,时间的差值存储在lpTimeResult结构体中.返回值 == 1 则两者相等;返回值 > 1, 则lpTimeA时间比lpTimeB在后;返回值 < 1, 则lpTimeB时间比lpTimeA在后.

例:
SYSTEMTIME ta,tb,tr;
GetSystemTime(&ta);
Sleep(1000);
GetSystemTime(&tb);
CompareSystime(&ta,&tb,&tr);



5.WCharToMByte(LPCWSTR lpcwszStr, LPSTR lpszStr, DWORD dwSize),MByteToWChar(LPCSTR lpcszStr, LPWSTR lpwszStr, DWORD dwSize)

多字节字符和宽字节字符的相互转换,具体原理和细节请参考:《MultiByteToWideChar和WideCharToMultiByte用法详解 》http://blog.youkuaiyun.com/norains/archive/2006/12/25/1461174.aspx




6.CenterWindow(HWND hWnd)

移动窗口到居中位置.

例:
CCommon::CenterWindow(hWnd);



7.GetScreenHeight(),GetScreenWidth()

获取屏幕的高度和宽度,以像素点为单位

例:
int iHeight = CCommon::GetScreenHeight();
int iWidth = CCommon::GetScreenWidth();



8.GetCurrentDirectory(TCHAR *pszPath, ULONG ulSize)

获取当前程序运行的路径,其后附带'/'.

例:
TCHAR szCurPath[MAX_PATH];
CCommon::GetCurrentPath(szCurPath,MAX_PATH);



9.FindString(const TCHAR *szSource, const TCHAR *szFind,const int iBeginPos)

查找某段字符串.

例:
int iPos1 = CCommon(TEXT("ABCEF"),TEXT("BC")); //iPos1 == 1
int iPos2 = CCommon(TEXT("ABCEF"),TEXT("BC"),1); //iPos1 == 0



10.Execute(TCHAR *pszPath,TCHAR *pParameters = NULL)

运行指定程序.

例:
CCommon::Execute(TEXT("windows//pmail.exe"))



11.ShowTaskBar(BOOL bShow)

隐藏或显示任务栏.

例:
CCommon::ShowTaskBar(TRUE);//显示任务栏



至此,CCommon的函数用法已经基本介绍完毕,更详细的用法请参加其后的完整代码.

/**//////////////////////////////////////////////////////////////////////
//Common.h:interfacefortheCCommonclass.
//
//Version:
//2.2.1
//Date:
//2007.06.02
/**///////////////////////////////////////////////////////////////////////

#ifndefCOMMON_H
#defineCOMMON_H

//--------------------------------------------------------------------
enumBroadcastType
...{
BC_VISIBLE,
//Broadcastthevisiblewindow
BC_ALL,//Broadcastallthewindow
BC_VISIBLE_NOBASEEXPLORER//Broadcastallthevisiblewindow,butnobaseexplorerwindowas"DesktopExplorerWnd"and"HHTaskBar"
}
;
//--------------------------------------------------------------------
classCCommon
...{
public:
staticvoidDeleteDirectory(constTCHAR*pszPath);
staticvoidBroadcastMessage(BroadcastTypebcType,UINTwMsg,WPARAMwParam,LPARAMlParam);
staticvoidCreateDirectorySerial(TCHAR*pszPath);
staticintCompareSystime(constLPSYSTEMTIMElpTimeA,constLPSYSTEMTIMElpTimeB,LPSYSTEMTIMElpTimeResult);
staticBOOLWCharToMByte(LPCWSTRlpcwszStr,LPSTRlpszStr,DWORDdwSize);
staticBOOLMByteToWChar(LPCSTRlpcszStr,LPWSTRlpwszStr,DWORDdwSize);
staticBOOLCenterWindow(HWNDhWnd);
staticintGetScreenHeight();
staticintGetScreenWidth();
staticTCHAR*GetCurrentDirectory(TCHAR*pszPath,ULONGulSize);
staticintFindString(constTCHAR*szSource,constTCHAR*szFind,constintiBeginPos);
staticBOOLExecute(TCHAR*pszPath,TCHAR*pParameters=NULL);
staticBOOLShowTaskBar(BOOLbShow);
virtual~CCommon();

protected:
staticBOOLEnumWindowsProcForBroadcast(HWNDhWnd,LPARAMlParam);
CCommon();

//It'sfortheBroadcastMessagefunction
staticHWNDm_hWndBc;
staticUINTm_wMsgBc;
staticWPARAMm_wParamBc;
staticLPARAMm_lParamBc;
staticBroadcastTypem_BcType;
}
;

#endif//!defined(AFX_COMMON_H__BCB17199_0561_47B0_943C_8921D6CC42D7__INCLUDED_)




/**///////////////////////////////////////////////////////////////////////
//Common.cpp:implementationoftheCCommonclass.
//
/**///////////////////////////////////////////////////////////////////////

#include
"stdafx.h"
#include
"Common.h"


//--------------------------------------------------------------------
//staticmemberinitialize
HWNDCCommon::m_hWndBc=NULL;
UINTCCommon::m_wMsgBc
=NULL;
WPARAMCCommon::m_wParamBc
=NULL;
LPARAMCCommon::m_lParamBc
=NULL;
BroadcastTypeCCommon::m_BcType
=BC_VISIBLE;
//--------------------------------------------------------------------
/**///////////////////////////////////////////////////////////////////////
//Construction/Destruction
/**///////////////////////////////////////////////////////////////////////

CCommon::CCommon()
...{

}


CCommon::
~CCommon()
...{

}



//---------------------------------------------------------------------
//Description:
//Showorhidethetaskbar
//
//Parameters:
//bShow:[in]
//TRUE--Showthetaskbar
//FALSE--Hidethetaskbar
//---------------------------------------------------------------------
BOOLCCommon::ShowTaskBar(BOOLbShow)
...{
HWNDhWndTask
=FindWindow(TEXT("HHTaskBar"),NULL);
if(hWndTask==NULL)
...{
returnFALSE;
}


if(bShow==TRUE)
...{
ShowWindow(hWndTask,SW_SHOW);
}

else
...{
ShowWindow(hWndTask,SW_HIDE);
}


returnTRUE;
}



//---------------------------------------------------------------------
//Description:
//Executetheapplication
//
//Parameters:
//pszPath:[in]Longpointertoanull-terminatedstringthatspecifiestheabsolutenameofthefiletorun
//pParameters:[in]Longpointertoanull-terminatedstringthatcontainstheapplicationparameters.
//Theparametersmustbeseparatedbyspaces.Toincludedoublequotationmarks,
//youmustenclosethemarksindoublequotationmarks,asinthefollowingexample.
//TCHAR*pParameters="Anexample:"""quotedtext"""";
//Inthiscase,theapplicationreceivesthreeparameters:An,example:,and"quotedtext".
//IfthepszPathspecifiesadocumentfile,thismembershouldbeNULL.
//
//---------------------------------------------------------------------
BOOLCCommon::Execute(TCHAR*pszPath,TCHAR*pParameters)
...{
SHELLEXECUTEINFOinfo;
memset(
&info,0,sizeof(info));
info.fMask
=SEE_MASK_NOCLOSEPROCESS|SEE_MASK_FLAG_NO_UI;
info.lpVerb
=NULL;
info.lpFile
=pszPath;
info.lpParameters
=pParameters;
info.lpDirectory
=NULL;
info.nShow
=SW_SHOW;
info.hInstApp
=NULL;
info.cbSize
=sizeof(info);

BOOLbResult
=ShellExecuteEx(&info);

returnbResult;
}



//---------------------------------------------------------------------------
//Description:
//Findthestringinthesourcestring,andreturntheposition.
//
//Parameter:
//szSource:[in]
//Thesourcestring
//szFind:[in]
//Thefindstring
//iBeginPos:[in]
//Thebeginfindingposition
//
//ReturnValues:
//Ifit-1,couldn'tfindthestring.
//Others,it'sthepositionofthefirstcharacterofszFindinthesourcestring
//
//---------------------------------------------------------------------------
intCCommon::FindString(constTCHAR*szSource,constTCHAR*szFind,constintiBeginPos)
...{
intiLenSource=_tcslen(szSource);
intiLenFind=_tcslen(szFind);

if(iLenSource-1<iBeginPos)
...{
return-1;
}


intiCount=0;
intiFindCount=0;
BOOLbPair
=FALSE;
for(iCount=0;iCount<iLenSource-iBeginPos;iCount++)
...{
if(szSource[iCount+iBeginPos]==szFind[iFindCount])
...{
if(iFindCount==iLenFind-1)
...{
bPair
=TRUE;
break;
}

iFindCount
++;
}

else
...{
iFindCount
=0;
}

}


intiFindPos;

if(bPair==FALSE)
...{
iFindPos
=-1;
}

else
...{
iFindPos
=iCount+iBeginPos-iLenFind+1;
}

returniFindPos;
}



//-------------------------------------------------------------------------------------
//Description:
//Getthecurrentruningpathincluding''inlast
//
//Parameters:
//pszPath:[out]Getthecurrentpath
//ulSize:[in]Thesizeofthebuffer.Forexample:szPath[MAX_NUMBER],thesizeifMAX_NUMBER.
//
//-------------------------------------------------------------------------------------
TCHAR*CCommon::GetCurrentDirectory(TCHAR*pszPath,ULONGulSize)
...{
memset(pszPath,
0,sizeof(TCHAR)*ulSize);

TCHARszBuf[MAX_PATH]
=...{0};
GetModuleFileName(NULL,szBuf,
sizeof(szBuf)/sizeof(TCHAR));

ULONGulCount
=_tcslen(szBuf);
while(--ulCount>=0)
...{
if(szBuf[ulCount]=='/')
...{
break;
}

else
...{
continue;
}

}


if(ulSize>(DWORD)ulCount)
...{
_tcsncpy(pszPath,szBuf,(ulCount
+1));
}


returnpszPath;
}



//-------------------------------------------------------------------------------------
//Description:
//Getscreenwidthinpixels
//------------------------------------------------------------------------------------
intCCommon::GetScreenWidth()
...{
returnGetSystemMetrics(SM_CXSCREEN);
}



//-------------------------------------------------------------------------------------
//Description:
//Getscreenheightinpixels
//------------------------------------------------------------------------------------
intCCommon::GetScreenHeight()
...{
returnGetSystemMetrics(SM_CYSCREEN);
}




//-------------------------------------------------------------------------------------
//Description:
//Centerthewindow.
//
//Parameters:
//hWnd:[in]Thewindowtobemoved
//------------------------------------------------------------------------------------
BOOLCCommon::CenterWindow(HWNDhWnd)
...{
if(hWnd==NULL)
...{
returnFALSE;
}


RECTrcWnd
=...{0};
if(GetWindowRect(hWnd,&rcWnd)==FALSE)
...{
returnFALSE;
}


intiWidth=rcWnd.right-rcWnd.left;
intiHeight=rcWnd.bottom-rcWnd.top;
intiX=(GetScreenWidth()-iWidth)/2;
intiY=(GetScreenHeight()-iHeight)/2;

returnMoveWindow(hWnd,iX,iY,iWidth,iHeight,TRUE);


}



//-------------------------------------------------------------------------------------
//Description:
//Thisfunctionmapsacharacterstringtoawide-character(Unicode)string
//
//Parameters:
//lpcszStr:[in]Pointertothecharacterstringtobeconverted
//lpwszStr:[out]Pointertoabufferthatreceivesthetranslatedstring.
//dwSize:[in]Sizeofthebuffer
//
//ReturnValues:
//TRUE:Succeed
//FALSE:Failed
//
//Example:
//MByteToWChar(szA,szW,sizeof(szW)/sizeof(szW[0]));
//---------------------------------------------------------------------------------------
BOOLCCommon::MByteToWChar(LPCSTRlpcszStr,LPWSTRlpwszStr,DWORDdwSize)
...{
//GettherequiredsizeofthebufferthatreceivestheUnicode
//string.
DWORDdwMinSize;
dwMinSize
=MultiByteToWideChar(CP_ACP,0,lpcszStr,-1,NULL,0);

if(dwSize<dwMinSize)
...{
returnFALSE;
}



//ConvertheadersfromASCIItoUnicode.
MultiByteToWideChar(CP_ACP,0,lpcszStr,-1,lpwszStr,dwMinSize);
returnTRUE;
}



//-------------------------------------------------------------------------------------
//Description:
//Thisfunctionmapsawide-characterstringtoanewcharacterstring
//
//Parameters:
//lpcwszStr:[in]Pointertothecharacterstringtobeconverted
//lpszStr:[out]Pointertoabufferthatreceivesthetranslatedstring.
//dwSize:[in]Sizeofthebuffer
//
//ReturnValues:
//TRUE:Succeed
//FALSE:Failed
//
//Example:
//MByteToWChar(szW,szA,sizeof(szA)/sizeof(szA[0]));
//---------------------------------------------------------------------------------------
BOOLCCommon::WCharToMByte(LPCWSTRlpcwszStr,LPSTRlpszStr,DWORDdwSize)
...{
DWORDdwMinSize;
dwMinSize
=WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,-1,NULL,0,NULL,FALSE);
if(dwSize<dwMinSize)
...{
returnFALSE;
}

WideCharToMultiByte(CP_OEMCP,NULL,lpcwszStr,
-1,lpszStr,dwSize,NULL,FALSE);
returnTRUE;
}




//-------------------------------------------------------------------------------------------
//Description:
//Comparethetwosystemtime.Thereturnvalueisthediffertime.
//
//Parameters:
//lpTimeA:[in]Systemtimetocompare
//lpTimeB:[in]Systemtimetocompare
//lpTimeResult:[out]Differenttime
//
//Returnvalues:
//0:Equal
//1:lpTimeAisgreaterthanlpTimeB
//-1:lpTimeAislessthanlpTimeB
//------------------------------------------------------------------------------------------
intCCommon::CompareSystime(constLPSYSTEMTIMElpTimeA,constLPSYSTEMTIMElpTimeB,LPSYSTEMTIMElpTimeResult)
...{

BYTEbBorrow
=FALSE;

intiReturn=0;

iReturn
=lpTimeA->wYear-lpTimeB->wYear;
if(iReturn==0)
...{
iReturn
=lpTimeA->wMonth-lpTimeB->wMonth;
if(iReturn==0)
...{
iReturn
=lpTimeA->wDay-lpTimeB->wDay;
if(iReturn==0)
...{
iReturn
=lpTimeA->wHour-lpTimeB->wHour;
if(iReturn==0)
...{
iReturn
=lpTimeA->wMinute-lpTimeB->wMinute;
if(iReturn==0)
...{
iReturn
=lpTimeA->wSecond-lpTimeB->wSecond;
if(iReturn==0)
...{
iReturn
=lpTimeA->wMilliseconds-lpTimeB->wMilliseconds;
}

}

}

}

}

}



SYSTEMTIMEsysTimeMinuend
=...{0};
SYSTEMTIMEsysTimeSub
=...{0};
if(iReturn!=0)
...{
if(iReturn>0)
...{
iReturn
=1;
sysTimeMinuend
=*lpTimeA;
sysTimeSub
=*lpTimeB;
}

else
...{
iReturn
=-1;
sysTimeMinuend
=*lpTimeB;
sysTimeSub
=*lpTimeA;
}

}

else
...{
memset(lpTimeResult,
0,sizeof(SYSTEMTIME));
gotoEND;
}





//Milliseconds
if(sysTimeMinuend.wMilliseconds>=sysTimeSub.wMilliseconds)
...{
bBorrow
=FALSE;
lpTimeResult
->wMilliseconds=sysTimeMinuend.wMilliseconds-sysTimeSub.wMilliseconds;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wMilliseconds=1000+sysTimeMinuend.wMilliseconds-sysTimeSub.wMilliseconds;
}




//Second
if(bBorrow==TRUE)
...{
sysTimeMinuend.wSecond
--;
}

if(sysTimeMinuend.wSecond>=sysTimeSub.wSecond)
...{
bBorrow
=FALSE;
lpTimeResult
->wSecond=sysTimeMinuend.wSecond-sysTimeSub.wSecond;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wSecond=60+sysTimeMinuend.wSecond-sysTimeSub.wSecond;
}




//Minute
if(bBorrow==TRUE)
...{
sysTimeMinuend.wMinute
--;
}

if(sysTimeMinuend.wMinute>=sysTimeSub.wMinute)
...{
bBorrow
=FALSE;
lpTimeResult
->wMinute=sysTimeMinuend.wMinute-sysTimeSub.wMinute;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wMinute=60+sysTimeMinuend.wMinute-sysTimeSub.wMinute;
}



//Hour
if(bBorrow==TRUE)
...{
sysTimeMinuend.wHour
--;
}

if(sysTimeMinuend.wHour>=sysTimeSub.wHour)
...{
bBorrow
=FALSE;
lpTimeResult
->wHour=sysTimeMinuend.wHour-sysTimeSub.wHour;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wHour=60+sysTimeMinuend.wHour-sysTimeSub.wHour;
}



//Day
if(bBorrow==TRUE)
...{
sysTimeMinuend.wDay
--;
}

if(sysTimeMinuend.wDay>=sysTimeSub.wDay)
...{
bBorrow
=FALSE;
lpTimeResult
->wDay=sysTimeMinuend.wDay-sysTimeSub.wDay;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wDay=60+sysTimeMinuend.wDay-sysTimeSub.wDay;
}



//Month
if(bBorrow==TRUE)
...{
sysTimeMinuend.wMonth
--;
}

if(sysTimeMinuend.wMonth>=sysTimeSub.wMonth)
...{
bBorrow
=FALSE;
lpTimeResult
->wMonth=sysTimeMinuend.wMonth-sysTimeSub.wMonth;
}

else
...{
bBorrow
=TRUE;
lpTimeResult
->wMonth=60+sysTimeMinuend.wMonth-sysTimeSub.wMonth;
}



//Year
if(bBorrow==TRUE)
...{
sysTimeMinuend.wYear
--;
}

lpTimeResult
->wYear=sysTimeMinuend.wYear-sysTimeSub.wYear;

END:
returniReturn;

}



//-------------------------------------------------------------------------------------
//Description:
//Createthedirectoryserialastothepath.Forexplame:Ifthepathis"harddisk/test/temp",
//itwillcreatethedirectory:"harddisk","test",and"temp".
//
//Parameters:
//pszPath[in]:Pointertothepathforcreating
//------------------------------------------------------------------------------------
voidCCommon::CreateDirectorySerial(TCHAR*pszPath)
...{

intiBeginCpy=0;
intiEndCpy=0;
TCHARszCpy[MAX_PATH]
=...{0};
TCHARszSource[MAX_PATH]
=...{0};

_tcscpy(szSource,pszPath);

intiLen=_tcslen(szSource);
if(szSource[iLen-1]=='/')
...{
szSource[iLen
-1]='';
}


while(TRUE)
...{
iEndCpy
=FindString(szSource,TEXT("/"),iBeginCpy);
if(iEndCpy==-1)
...{
break;
}


memset(szCpy,
0,sizeof(szCpy));
_tcsncpy(szCpy,pszPath,iEndCpy
+1);
CreateDirectory(szCpy,NULL);

iBeginCpy
=iEndCpy+1;

}


if(iEndCpy==-1&&iBeginCpy!=0)
...{
CreateDirectory(szSource,NULL);
}

}



//-------------------------------------------------------------------------------------
//Description:
//Broadthemessagetothespecifieswindow
//
//Parameters:
//bctype:[in]Specifieswhichtypeofwindowtoreceivethemessage
//wMsg:[in]Specifiesthemessagetobesent.
//wParam:[in]Specifiesadditionalmessage-specificinformation.
//lParam:[in]Specifiesadditionalmessage-specificinformation.
//---------------------------------------------------------------------------------------
voidCCommon::BroadcastMessage(BroadcastTypebcType,UINTwMsg,WPARAMwParam,LPARAMlParam)
...{
m_hWndBc
=NULL;
m_wMsgBc
=wMsg;
m_wParamBc
=wParam;
m_lParamBc
=lParam;
m_BcType
=bcType;
EnumWindows(EnumWindowsProcForBroadcast,NULL);
}



//--------------------------------------------------------------------------------------
//Description:
//Thisfunctionisanapplication-definedcallbackfunctionthatreceivestop-levelwindow
//handlesasaresultofacalltotheEnumWindowsfunction.Andthefunctionisonlybecalled
//intheBroadcastMessage()function
//--------------------------------------------------------------------------------------
BOOLCCommon::EnumWindowsProcForBroadcast(HWNDhWnd,LPARAMlParam)
...{
if(m_hWndBc==hWnd)
...{
returnFALSE;
}


if(m_hWndBc==NULL)
...{
m_hWndBc
=hWnd;
}



if(m_BcType==BC_VISIBLE||m_BcType==BC_VISIBLE_NOBASEEXPLORER)
...{
if(GetWindowLong(hWnd,GWL_STYLE)&WS_VISIBLE)
...{
if(m_BcType==BC_VISIBLE_NOBASEEXPLORER)
...{
TCHARszClsName[MAX_PATH]
=...{0};
GetClassName(hWnd,szClsName,MAX_PATH);
if(_tcscmp(TEXT("HHTaskBar"),szClsName)==0||
_tcscmp(TEXT(
"DesktopExplorerWindow"),szClsName)==0
)
...{
returnTRUE;
}

}


SendMessage(hWnd,m_wMsgBc,m_wParamBc,m_lParamBc);
}

}

elseif(m_BcType==BC_ALL)
...{
SendMessage(hWnd,m_wMsgBc,m_wParamBc,m_lParamBc);
}



returnTRUE;
}




//-------------------------------------------------------------------------------------
//Description:
//Deletethenoemptydirectory
//
//Parameters:
//pszPath:[in]Thepathofdirectory
//---------------------------------------------------------------------------------------
voidCCommon::DeleteDirectory(constTCHAR*pszPath)
...{

ULONGulLen
=_tcslen(pszPath);
TCHARszPathBuf[MAX_PATH]
=...{0};
_tcscpy(szPathBuf,pszPath);

ulLen
=_tcslen(szPathBuf);
if(szPathBuf[ulLen-1]!='/')
...{
szPathBuf[ulLen]
='/';
szPathBuf[ulLen
+1]='';
}

_tcscat(szPathBuf,TEXT(
"*.*"));


WIN32_FIND_DATAfd;
HANDLEhFind
=FindFirstFile(szPathBuf,&fd);
if(hFind!=INVALID_HANDLE_VALUE)
...{
do...{
TCHARszNextPath[MAX_PATH]
=...{0};
_tcscpy(szNextPath,pszPath);

ULONGuLenNext
=_tcslen(szNextPath);
if(szNextPath[uLenNext-1]!='/')
...{
szNextPath[uLenNext]
='/';
szNextPath[uLenNext
+1]='';
}

_tcscat(szNextPath,fd.cFileName);

if(fd.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY)
...{
//itmustbedirectory
DeleteDirectory(szNextPath);
RemoveDirectory(szNextPath);
}

else
...{
//itisfile
DeleteFile(szNextPath);
}

}
while(FindNextFile(hFind,&fd));
}


FindClose(hFind);

RemoveDirectory(pszPath);


}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值