thread1.cpp
上传用户:zhenhuadz
上传日期:2007-01-07
资源大小:1511k
文件大小:17k
源码类别:

远程控制编程

开发平台:

Visual C++

  1. // thread1.cpp: implementation of the thread class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "anywhere.h"
  6. #include "thread1.h"
  7. #include "blocksock.h"
  8. //#include "msgman.h"
  9. //#include "mainfrm.h"
  10. //#include "thread.h"
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[]=__FILE__;
  14. #define new DEBUG_NEW
  15. #endif
  16. //////////////////////////////////////////////////////////////////////
  17. // Construction/Destruction
  18. //////////////////////////////////////////////////////////////////////
  19. //#define timeout 15
  20. //#define request 400
  21. HWND m_hMainWnd;
  22. HANDLE hRecv,hSend;//接受,发送两个线程的句柄
  23. HANDLE recvevent,sendevent;
  24. CCriticalSection cs;
  25. Link linkrc;
  26. int timeout,request;
  27. CString pix="800*600";
  28. void LogBlockingSocketException(LPVOID pParam, char* pch, CBlockingSocketException* pe)
  29. { // pParam holds the HWND for the destination window (in another thread)
  30. /* CString strGmt = CTime::GetCurrentTime().FormatGmt("%m/%d/%y %H:%M:%S GMT");
  31. char text1[200], text2[50];
  32. pe->GetErrorMessage(text2, 49);
  33. wsprintf(text1, "WINSOCK ERROR--%s %s -- %srn", pch, text2, (const char*) strGmt);
  34. ::SendMessage((HWND) pParam, EM_SETSEL, (WPARAM) 65534, 65535);
  35. ::SendMessage((HWND) pParam, EM_REPLACESEL, (WPARAM) 0, (LPARAM) text1);
  36. */
  37. MessageBox(NULL,pch,NULL,MB_OK);
  38. }
  39. UINT Connect(LPVOID pParam)
  40. {
  41. Link *plinkrc;
  42. plinkrc=(Link*)pParam;
  43. CBlockingSocket saClient;
  44. char connect[17];
  45. char assume[17];
  46.     cs.Lock();
  47.     strcpy(assume,plinkrc->username);
  48. strcat(assume,plinkrc->password);
  49. //strcpy(szsBuf,plinkrc->sbuf);
  50. CSockAddr sa=plinkrc->sAddr;
  51.     cs.Unlock();//将待发消息传给变量
  52. connect[16]=0;
  53. assume[16]=0;
  54.     //CBlockingSocket sockClient;
  55. try {
  56. saClient.Create();
  57. saClient.Connect(sa);
  58. if (!plinkrc->bConnected) {
  59. saClient.Write(assume,strlen(assume),timeout);
  60.             saClient.Receive(connect,16,timeout);
  61. if (strcmp(assume,connect)) {
  62. MessageBox(m_hMainWnd,"不正确的用户或密码,被服务端拒绝服务","提示:",MB_OK);
  63. ExitThread(0);//不等退出
  64. }//认证过程
  65. else plinkrc->bConnected=TRUE;
  66. }
  67. cs.Lock();
  68. plinkrc->bConnected=TRUE;
  69. cs.Unlock();
  70. saClient.Close();
  71. return 1;
  72. }
  73. catch (CBlockingSocketException *e) {
  74. MessageBox(NULL,"连接错误!","提示",MB_OK);
  75. e->Delete();
  76. saClient.Close();
  77.     return 0;
  78. //cs.Unlock();
  79. }
  80. //sockClient.Close();
  81. }
  82. DWORD WINAPI SysThread(LPVOID pParam)
  83. {
  84.     WaitForSingleObject(sendevent,INFINITE);//无限阻塞
  85. //自动重设,使信号实效
  86. Link *plinkrc;
  87. plinkrc=(Link *)pParam;
  88.     char szsBuf[1024];//待发字串
  89. //char connect[17]; //认证
  90. //char assume[17];
  91. //LPTSTR szrBuf;
  92. //int *iLength;
  93. //iLength= new int;//堆,这里new的对象共计有:ilength,szrbuf
  94. HWND hWndThread;
  95.    
  96.    CBlockingSocket saClient;
  97. cs.Lock();
  98.     //strcpy(assume,plinkrc->username);
  99. //strcat(assume,plinkrc->password);
  100. strcpy(szsBuf,plinkrc->sbuf);
  101. CSockAddr sa=plinkrc->sAddr;
  102.     hWndThread=plinkrc->m_hWnd;
  103.     cs.Unlock();//将待发消息传给变量
  104. //connect[16]=0;
  105. //assume[16]=0;
  106. try {
  107. saClient.Create();
  108. saClient.Connect(sa);
  109.      int tmplength=strlen(szsBuf);
  110. saClient.Write((char *)&tmplength,4,timeout);
  111. saClient.Write(szsBuf,strlen(szsBuf),timeout);//命令
  112.     if ((!strcmp(szsBuf,"RESTART*")) || (!strcmp(szsBuf,"SHUTDOWN")))
  113. linkrc.bConnected=FALSE;
  114. SetEvent(sendevent);//设置可接受信息长度,生效
  115. /*saClient.Receive((char *)iLength,4,request);
  116.     
  117. //SetEvent(recvevent);
  118. WaitForSingleObject(recvevent,INFINITE);
  119.         //失效
  120. szrBuf=new char[*iLength+1];//应该判断
  121. saClient.Receive(szrBuf,*iLength,timeout);
  122. szrBuf[*iLength]=0;
  123. CString text=szrBuf;
  124. // WaitForSingleObject(recvevent,INFINITE);
  125. ::SendMessage(hWndThread,WM_SETACTIVE,1,(DWORD)&text);
  126. //ResetEvent(recvevent);//重置信号//发送消息给窗口
  127. //会等待sendmessage返回
  128. //必须在适当时候删除szrbuf
  129.     saClient.Close();//Cleanup();
  130. SetEvent(recvevent);//设置可接受信息
  131. delete iLength;
  132. delete szrBuf;
  133.        
  134.         //cs.Lock();
  135. //strcpy(plinkrc->rbuf,szrBuf);
  136.         //cs.Unlock();
  137. */
  138. return 1;//成功
  139. }
  140. catch (CBlockingSocketException *e) {
  141. CString sErrmsg;
  142. sErrmsg.LoadString(IDS_ERROR_RECEIVE);
  143. MessageBox(hWndThread,sErrmsg,"提示",MB_OK);
  144. e->Delete();
  145. saClient.Close();//leanup();
  146. SetEvent(sendevent);
  147. ::SendMessage(hWndThread,WM_SETACTIVE,0,(DWORD)&sErrmsg);
  148.     return 0;
  149. }
  150. }
  151. DWORD WINAPI SendThread(LPVOID pParam)
  152. {
  153.     WaitForSingleObject(sendevent,INFINITE);//无限阻塞
  154. //自动重设,使信号实效
  155. Link *plinkrc;
  156. plinkrc=(Link *)pParam;
  157.     char szsBuf[1024];//待发字串
  158. char connect[17]; //认证
  159. char assume[17];
  160. LPTSTR szrBuf=NULL;
  161. int *iLength=NULL;
  162. iLength= new int;//堆,这里new的对象共计有:ilength,szrbuf
  163. HWND hWndThread;
  164.    
  165.    CBlockingSocket saClient;
  166. cs.Lock();
  167.     strcpy(assume,plinkrc->username);
  168. strcat(assume,plinkrc->password);
  169. strcpy(szsBuf,plinkrc->sbuf);
  170. CSockAddr sa=plinkrc->sAddr;
  171.     hWndThread=plinkrc->m_hWnd;
  172.     cs.Unlock();//将待发消息传给变量
  173. connect[16]=0;
  174. assume[16]=0;
  175. try {
  176. saClient.Create();
  177. saClient.Connect(sa);
  178.        
  179. if (!plinkrc->bConnected) {
  180. saClient.Write(assume,16,timeout);
  181.             saClient.Receive(connect,16,timeout);
  182. if (strcmp(assume,connect)) {
  183. CString sErrmsg,tmp2;
  184. sErrmsg.LoadString(IDS_ERROR_USER);
  185. tmp2.LoadString(IDS_CAPTION);
  186. MessageBox(hWndThread,sErrmsg,tmp2,MB_OK);
  187. saClient.Close();
  188.                 ExitThread(0);//不等退出
  189. }//认证过程
  190. else plinkrc->bConnected=TRUE;
  191. }
  192. int tmplength=strlen(szsBuf);
  193. saClient.Write((char *)&tmplength,4,timeout);
  194. saClient.Write(szsBuf,strlen(szsBuf),timeout);//命令
  195. saClient.Receive((char *)iLength,4,request);
  196. SetEvent(sendevent);//设置可接受信息长度,生效
  197.     
  198. //SetEvent(recvevent);
  199. WaitForSingleObject(recvevent,INFINITE);
  200.         //失效
  201. if ((*iLength<0) || (*iLength>10000)) 
  202. throw new CBlockingSocketException("Receive");
  203. szrBuf=new char[*iLength+1];//应该判断
  204. saClient.Receive(szrBuf,*iLength,timeout);
  205. szrBuf[*iLength]=0;
  206. CString text=szrBuf;
  207. // WaitForSingleObject(recvevent,INFINITE);
  208. ::SendMessage(hWndThread,WM_SETACTIVE,1,(DWORD)&text);
  209. //ResetEvent(recvevent);//重置信号//发送消息给窗口
  210. //会等待sendmessage返回
  211. //必须在适当时候删除szrbuf
  212.     saClient.Close();//Cleanup();
  213. SetEvent(recvevent);//设置可接受信息
  214. if (iLength!=NULL) delete iLength;
  215. if (szrBuf!=NULL) delete szrBuf;
  216.  
  217.   return 1;//成功
  218. }
  219. catch (CBlockingSocketException *e) {
  220. CString sErrmsg;
  221. sErrmsg.LoadString(IDS_ERROR_RECEIVE);
  222. MessageBox(hWndThread,sErrmsg,"提示",MB_OK);
  223. e->Delete();
  224. saClient.Cleanup();
  225. SetEvent(sendevent);
  226. SetEvent(recvevent);//设置事件可用
  227. ::SendMessage(hWndThread,WM_SETACTIVE,0,(DWORD)&sErrmsg);
  228. linkrc.bConnected=FALSE;
  229.     //失败
  230. if (iLength!=NULL) 
  231. delete iLength;
  232. if (szrBuf!=NULL) 
  233. delete szrBuf;
  234.     return 0;
  235. }
  236. }
  237. DWORD WINAPI ViewScr(LPVOID pParam)
  238. {
  239. Link *plinkrc;
  240. plinkrc=(Link*)pParam;
  241. char szsBuf[1025];//定义发送字串
  242. char *data=NULL;
  243. char *tmp=NULL;
  244. data=new char[1024];
  245. int *iLength=NULL;
  246. LPTSTR szrBuf=NULL;
  247. iLength= new int;//堆
  248. HWND hWndThread;
  249. memset(szsBuf,0,sizeof(szsBuf));
  250. CBlockingSocket saClient;
  251. CBlockingSocket sockClient;
  252. cs.Lock();
  253.     strcpy(szsBuf,plinkrc->sbuf);
  254. CSockAddr sa=plinkrc->sAddr;
  255. CSockAddr saa=CSockAddr(plinkrc->ip,plinkrc->viewport);//temp截图
  256. hWndThread=plinkrc->m_hWnd;
  257.     cs.Unlock();//临界区
  258. try {
  259. saClient.Create();
  260. saClient.Connect(sa);
  261. int order_length=8;
  262.         saClient.Write((char *)&order_length,4,timeout);
  263. saClient.Write(szsBuf,strlen(szsBuf),timeout);
  264.         
  265. saClient.Receive((char *)iLength,4,request);
  266. szrBuf=new char[*iLength+1];
  267. saClient.Receive(szrBuf,*iLength,timeout);
  268. szrBuf[*iLength]=0;
  269.         //是否需等待????
  270. if (strcmp(szsBuf,szrBuf)) {//为真则不相等
  271.     CString sErrmsg,caption;
  272. sErrmsg.LoadString(IDS_SERVER_FAILED);//无法响应
  273. caption.LoadString(IDS_CAPTION);
  274.     MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  275.                 saClient.Close();
  276. if (szrBuf!=NULL) delete szrBuf;
  277. if (iLength!=NULL) delete iLength;
  278. ExitThread(0);//不等退出
  279. }
  280.       saClient.Close();
  281.   sockClient.Create();
  282.   sockClient.Connect(saa);
  283.   int  *pLength;
  284.       char cLength[4];
  285.       sockClient.Receive(cLength, 4,timeout);
  286.       pLength=(int *)cLength;
  287.   int dataLength=*pLength;
  288.    
  289.     char tmppath[MAX_PATH];
  290.     char tmpname[MAX_PATH];
  291. GetTempPath(MAX_PATH,tmppath);
  292. GetTempFileName(tmppath,"any",0,tmpname);
  293.     //获得一个临时文件名
  294. CFile destFile(tmpname, CFile::modeCreate| CFile::modeWrite| CFile::typeBinary);
  295. int loopnum=dataLength/1024;
  296. int rest=dataLength-loopnum*1024;
  297. int nBytesRecv,nBytesThisTime;;
  298. for (int i=0;i<loopnum;i++)
  299. {
  300. nBytesRecv=0;
  301. tmp=data;
  302. do {
  303. nBytesThisTime=sockClient.Receive(data,1024-nBytesRecv,timeout);
  304. nBytesRecv+=nBytesThisTime;
  305. data+=nBytesThisTime;
  306. } while (nBytesRecv<1024);
  307.        
  308.        destFile.Write(tmp,1024);
  309.    data=tmp;
  310. }
  311.      sockClient.Receive(data,rest,timeout);
  312.  destFile.Write(data,rest);
  313.  destFile.Flush();
  314.  destFile.Close();
  315.      sockClient.Close();
  316. if (iLength!=NULL) delete iLength;
  317. if (szrBuf!=NULL) delete szrBuf;
  318.     if (data!=NULL)   delete data;
  319.      
  320.  CString text="VIEWSCR*";
  321.  text+=tmpname;
  322.  //strcpy(szrBuf,"VIEWSCR*");
  323.  //strcat(szrBuf,tmpname);//将命令和文件名发给主窗口
  324.  ::SendMessage(hWndThread,WM_SETACTIVE,1,(DWORD)&text);
  325.  
  326.  return 1;
  327. }
  328. catch (CBlockingSocketException *e) {
  329. CString sErrmsg,caption;
  330. sErrmsg.LoadString(IDS_ERROR_RECEIVE);
  331. caption.LoadString(IDS_CAPTION);
  332. MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  333. e->Delete();
  334. data=tmp;//add temp
  335. if (data!=NULL) delete data;
  336.         if (szrBuf!=NULL) delete szrBuf;
  337.     if (iLength!=NULL) delete iLength;
  338.        sockClient.Cleanup();
  339.     return 0;
  340. }
  341. }
  342. DWORD WINAPI GetFileThread(LPVOID pParam)
  343. {
  344. Link *plinkrc;
  345. plinkrc=(Link*)pParam;
  346. char szsBuf[1025];//定义发送字串
  347. char filename[MAX_PATH];
  348. char *data=NULL; //用于传输文件
  349. data=new char[1024];
  350. int *iLength=NULL;
  351. LPTSTR szrBuf=NULL;
  352. char *tmp=NULL;
  353. iLength= new int;//堆
  354. HWND hWndThread;
  355. memset(szsBuf,0,sizeof(szsBuf));
  356. memset(filename,0,sizeof(filename));
  357. CBlockingSocket saClient;
  358. CBlockingSocket sockClient;
  359. cs.Lock();
  360.     strcpy(szsBuf,plinkrc->sbuf);
  361. strcpy(filename,plinkrc->rbuf);
  362. CSockAddr sa=plinkrc->sAddr;
  363. CSockAddr saa=CSockAddr(plinkrc->ip,plinkrc->getfileport);//temp截图
  364. hWndThread=plinkrc->m_hWnd;
  365.     cs.Unlock();//临界区
  366. try {
  367. saClient.Create();
  368. saClient.Connect(sa);
  369. int order_length=strlen(szsBuf);
  370.         saClient.Write((char *)&order_length,4,timeout);
  371. saClient.Write(szsBuf,strlen(szsBuf),timeout);
  372.         
  373. saClient.Receive((char *)iLength,4,request);
  374. szrBuf=new char[*iLength+1];
  375. saClient.Receive(szrBuf,*iLength,timeout);
  376. szrBuf[*iLength]=0;
  377.         //是否需等待????
  378. if (strncmp(szsBuf,szrBuf,8)) {//为真则不相等
  379.     CString sErrmsg,caption;
  380. sErrmsg.LoadString(IDS_SERVER_FAILED);//无法响应
  381. caption.LoadString(IDS_CAPTION);
  382.     MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  383.                 saClient.Close();
  384. if (szrBuf!=NULL) delete szrBuf;
  385. ExitThread(0);//不等退出
  386. }
  387.       saClient.Close();
  388.   sockClient.Create();
  389.   sockClient.Connect(saa);
  390.   int  *pLength;
  391.       char cLength[4];
  392.       sockClient.Receive(cLength, 4,timeout);
  393.       pLength=(int *)cLength;
  394.   int dataLength=*pLength;
  395.           
  396. CFile destFile(filename, CFile::modeCreate| CFile::modeWrite| CFile::typeBinary);
  397. int loopnum=dataLength/1024;
  398. int rest=dataLength-loopnum*1024;
  399. int nBytesRecv,nBytesThisTime;;
  400. for (int i=0;i<loopnum;i++)
  401. {
  402. nBytesRecv=0;
  403. tmp=data;
  404. do {
  405. nBytesThisTime=sockClient.Receive(data,1024-nBytesRecv,timeout);
  406. nBytesRecv+=nBytesThisTime;
  407. data+=nBytesThisTime;
  408. } while (nBytesRecv<1024);
  409.        
  410.        destFile.Write(tmp,1024);
  411.    data=tmp;
  412. }
  413.      sockClient.Receive(data,rest,timeout);
  414.  destFile.Write(data,rest);
  415.  destFile.Flush();
  416.  destFile.Close();
  417.      sockClient.Close();
  418.      if (data!=NULL) delete data;  
  419.  if (iLength!=NULL) delete iLength;
  420.  if (szrBuf!=NULL) delete szrBuf;
  421.  CString text="GETFILE*";
  422.  text+=filename;//filename为下载到那个文件
  423.  //将命令和文件名发给主窗口
  424.  ::SendMessage(hWndThread,WM_SETACTIVE,1,(DWORD)&text);
  425.  return 1;
  426. }
  427. catch (CBlockingSocketException *e) {
  428. CString sErrmsg,caption;
  429. sErrmsg.LoadString(IDS_ERROR_RECEIVE);
  430. caption.LoadString(IDS_CAPTION);
  431. MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  432. e->Delete();
  433. CString text="GETFILE*";
  434.     text+=filename;//filename为下载到那个文件
  435.   ::SendMessage(hWndThread,WM_SETACTIVE,0,(DWORD)&text);
  436. data=tmp;
  437. if (data!=NULL) delete data;
  438. if (iLength!=NULL) delete iLength;
  439.     if (szrBuf!=NULL) delete szrBuf;
  440. sockClient.Cleanup();
  441.     return 0;
  442. }
  443. catch (CFileException *fe) {
  444. CString sErrmsg,caption;
  445. sErrmsg.LoadString(IDS_FILEWRITE_FAILED);
  446. caption.LoadString(IDS_CAPTION);
  447. MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  448.     fe->Delete;
  449. CString text="GETFILE*";
  450.     text+=filename;//filename为下载到那个文件
  451.   ::SendMessage(hWndThread,WM_SETACTIVE,0,(DWORD)&text);
  452. data=tmp;
  453. if (data!=NULL) delete data;
  454. if (iLength!=NULL) delete iLength;
  455.     if (szrBuf!=NULL) delete szrBuf;
  456.     return 0;
  457. }
  458. }
  459. DWORD WINAPI PutFileThread(LPVOID pParam)
  460. {
  461. Link *plinkrc;
  462. plinkrc=(Link*)pParam;
  463. char szsBuf[1025];//定义发送字串
  464. char filename[MAX_PATH];
  465. char *data=NULL; //用于传输文件
  466. data=new char[1024];
  467. int *iLength;
  468. LPTSTR szrBuf=NULL;
  469. iLength= new int;//堆
  470. HWND hWndThread;
  471. memset(szsBuf,0,sizeof(szsBuf));
  472. memset(filename,0,sizeof(filename));
  473. CBlockingSocket saClient;
  474. CBlockingSocket sockClient;
  475. cs.Lock();
  476.     strcpy(szsBuf,plinkrc->sbuf);//发往客户端的命令
  477. strcpy(filename,plinkrc->rbuf);
  478. CSockAddr sa=plinkrc->sAddr;
  479. CSockAddr saa=CSockAddr(plinkrc->ip,plinkrc->putfileport);//temp截图
  480. hWndThread=plinkrc->m_hWnd;
  481.     cs.Unlock();//临界区
  482. try {
  483. saClient.Create();
  484. saClient.Connect(sa);
  485. int order_length=strlen(szsBuf);
  486.         saClient.Write((char *)&order_length,4,timeout);
  487. saClient.Write(szsBuf,strlen(szsBuf),timeout);
  488.         
  489. saClient.Receive((char *)iLength,4,request);
  490. szrBuf=new char[*iLength+1];
  491. saClient.Receive(szrBuf,*iLength,timeout);
  492. szrBuf[*iLength]=0;
  493.         //是否需等待????
  494. if (strncmp(szsBuf,szrBuf,8)) {//为真则不相等
  495.     CString sErrmsg,caption;
  496. sErrmsg.LoadString(IDS_SERVER_FAILED);//无法响应
  497. caption.LoadString(IDS_CAPTION);
  498.     MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  499.                 saClient.Close();
  500. if (szrBuf!=NULL) delete szrBuf;
  501. ExitThread(0);//不等退出
  502. }
  503.       
  504.       saClient.Close();
  505.   sockClient.Create();
  506.   sockClient.Connect(saa);
  507.   //int  Length;
  508.       //char cLength[4];
  509.       
  510.   CFile destFile(filename, CFile::modeRead|CFile::typeBinary);
  511.       int dataLength=destFile.GetLength();
  512.   sockClient.Write((char *)&dataLength,4,timeout);
  513.       //pLength=(int *)cLength;
  514.   //int dataLength=*pLength;
  515.           
  516. int loopnum=dataLength/1024;
  517. int rest=dataLength-loopnum*1024;
  518. //int nBytesRecv,nBytesThisTime;;
  519. for (int i=0;i<loopnum;i++)
  520. {
  521. /*nBytesRecv=0;
  522. char  *tmp=data;
  523. do {   
  524. nBytesThisTime=sockClient.Receive(data,1024-nBytesRecv,timeout);
  525. nBytesRecv+=nBytesThisTime;
  526. data+=nBytesThisTime;
  527. } while (nBytesRecv<1024);
  528. */
  529.        destFile.Read(data,1024);
  530.    sockClient.Write(data,1024,timeout);
  531.        //data=tmp;
  532. }
  533.     destFile.Read(data,rest);
  534. sockClient.Write(data,rest,timeout);
  535.  
  536.  //destFile.Flush();
  537.  destFile.Close();
  538.      sockClient.Close();
  539.      if (data!=NULL) delete data;  
  540.  if (iLength!=NULL) delete iLength;
  541.  if (szrBuf!=NULL) delete szrBuf;
  542.  //delete data;  
  543.  CString text=szsBuf; //为上传到那个文件
  544.  //将命令和文件名发给主窗口
  545.  ::SendMessage(hWndThread,WM_SETACTIVE,1,(DWORD)&text);
  546.  return 1;
  547. }
  548. catch (CBlockingSocketException *e) {
  549. CString sErrmsg,caption;
  550. sErrmsg.LoadString(IDS_ERROR_RECEIVE);
  551. caption.LoadString(IDS_CAPTION);
  552. MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  553. e->Delete();
  554.         if (data!=NULL) delete data;  
  555.         if (iLength!=NULL) delete iLength;
  556.     if (szrBuf!=NULL) delete szrBuf;
  557. sockClient.Cleanup();
  558.     return 0;
  559. }
  560. /* catch (CFileException *fe) {
  561. CString sErrmsg,caption;
  562. sErrmsg.LoadString(IDS_FILEWRITE_FAILED);
  563. caption.LoadString(IDS_CAPTION);
  564. MessageBox(hWndThread,sErrmsg,caption,MB_OK);
  565.     fe->Delete;
  566. }
  567. */
  568. }