TCHAR tcModule[MAX_PATH] = {0};
GetModuleFileName(m_hInstance,tcModule,MAX_PATH); //獲取文件自身目錄
*(_tcsrchr(tcModule,_T('\\')) + 1) = 0;
if(_tcsicmp(tcModule,tcPath) == 0)
{
//
TCHAR tcTemp[MAX_PATH] = {0};
GetTempPath(MAX_PATH,tcTemp); //要復制到的目標目錄
CString csSrcPath,csDestPath;
csSrcPath.Format(_T("%server.exe"),tcPath); //源路徑
csDestPath.Format(_T("%server.exe"),tcTemp); //目標路徑
CopyFile(csSrcPath,csDestPath,FALSE); //復制文件
ShellExecute(NULL,_T("open"),csDestPath.GetBuffer(0),NULL,NULL,SW_SHOW); //運行目標文件
return FALSE; //返回FALSE源程序就會退出運行狀態
//ExitProcess(0);
}