CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閲讀模式
4 {) e( d/ q/ u2 o
  1. / RevApp.cpp : Defines the class behaviors for the application.
    7 n* Y, R: `$ ^/ \
  2. //" L- q) v- j) u8 n4 J0 P

  3. 2 G) w1 ?: j, E
  4. #include "stdafx.h"
    6 h# s9 Q/ E/ b, |

  5. 6 G: \. W4 x( l5 {& z
  6. //#define UNICODE
    9 `( H( H. M1 U& i$ }" `" ^* E/ M
  7. //#include <gdiplus.h>
    " d, s1 o) R; L, z. v
  8. //using namespace Gdiplus;
    . o+ R6 L8 r6 ^. R" h

  9. " l6 U" U( P  K+ g6 N; l
  10. #include "RevApp.h"1 M7 a$ h7 Y) c9 h4 [
  11. #include "RevAppDlg.h"
    % s& i: `2 i2 k) U! e: a

  12. 8 \4 u- }! \3 E8 `. u
  13. #pragma warning(disable:4786)
    " e* f0 P0 Y2 T: z% T$ }
  14. #include <map>
    4 ~7 c& S; Q( T! g8 c4 L4 l
  15. #include <list>
    8 V# W" a6 G& ~+ b# c
  16. #include <direct.h>
    4 E$ X- k" R' Z! P2 b

  17. : |  c; h2 T; q! ]
  18. #ifdef _DEBUG0 C+ B( Y5 D3 g  i& A
  19. #define new DEBUG_NEW
    " J) I* M; _/ ^0 a$ }% G
  20. #undef THIS_FILE' ?2 J7 c6 @6 }# f
  21. static char THIS_FILE[] = __FILE__;
    + Z2 j! j: [8 _5 c! U* E
  22. #endif1 P' p" P6 o; B% s5 [+ E
  23. #include "SkinResDef.h"! o. }( F' e0 `: N% W& Q
  24. #include "ChangeBG.h"
    1 k; w: l! [" R
  25. #include "AFXINET.H"8 E* N# m" U: X& W' L
  26. " H! G4 ^3 U: Q: `+ j
  27. #define TRADITIONAL_CHINESE 03 V! C8 M0 a8 W, g% K
  28. #define SIMPLIFY_CHINESE 18 ~/ X: z6 n. w# k& K; E1 y! D
  29. #define ENGLISH 2
    / M& t' A3 q. {; e6 H% z& B( e, m
  30. int m_iLanguage = ENGLISH;
    2 M) z0 w- [% |  _4 w8 i* \
  31. /////////////////////////////////////////////////////////////////////////////( w7 B6 i+ B# d0 o0 L
  32. // CRevAppApp2 N1 o. Q4 `1 [" R5 L
  33. . K6 z4 J, S) u' X
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    5 t/ F# T; E. @2 }3 c8 I; E* e
  35.         //{{AFX_MSG_MAP(CRevAppApp)
    ( Z+ P' K0 g8 u, ~' Q3 G) F; ]- |
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.
    9 P, n3 z1 q5 ~% J% x7 W- P
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!- {* K8 |4 J$ a1 A4 Q2 w
  38.         //}}AFX_MSG% G- e9 f" @+ T, S0 V! s: ?" I. w5 k
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp); }! ?9 z% R, f
  40. END_MESSAGE_MAP()
    6 S4 `; a  _! q3 i& R
  41. 3 o/ r5 i# @* W7 Z# p# D% i
  42. /////////////////////////////////////////////////////////////////////////////: l) l9 N2 j& k2 [; A
  43. // CRevAppApp construction
    $ b' o* n' D0 a

  44. - Z+ N7 W$ L! E+ w* v4 u2 @
  45. CRevAppApp::CRevAppApp()8 W+ |: Q' a; @9 O0 V; p+ R
  46. {
    ' Y& B0 F* P$ ?# H4 x
  47.         // TODO: add construction code here,
    0 k! x. r$ _9 _9 i
  48.         // Place all significant initialization in InitInstance( J3 B" k1 Y! F) p7 T
  49.   bDisplayIsBig5=FALSE;  C' X2 f/ Y/ M( E; v# p% r
  50.   bRestartUpdater=FALSE;8 X2 \) l6 J9 J2 Y0 U9 j8 B
  51.   bFinishUpdated=FALSE;
    ) n! V" j6 D- b2 P- o: s8 v
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;& D' a$ U: c# C% B8 w2 c
  53.   InitChangeDataBig52GBKS();6 ^2 I4 ]6 @( K: N
  54.   InitChangeDataGBKS2Big5();7 X5 P6 O1 h7 s! p9 b& M
  55.         //& ^1 \, P  m1 H% N  R/ p0 ?
  56.         bClickRunExe = FALSE;/ Z6 K8 q" x+ h" @, Q. B- ~
  57.         //
    * F6 I1 L& h4 H" x& V) q) B5 x3 {
  58. }
    + q' Q  R3 W' T( b' K

  59. $ `. Y& H& P& a1 W  @3 A9 ?% a
  60. CRevAppApp::~CRevAppApp()
    % T2 K) k. ?( U% S& |
  61. {: K, U- M. M) }$ Q# X
  62.         // TODO: add construction code here,
    9 {2 J, \) b8 }+ @! K% Y4 j! I
  63.         // Place all significant initialization in InitInstance6 Q" k; B, _6 x+ ~+ G
  64.   EndChangeData();1 h, e; G# k& w* ?( h/ j' H
  65. }$ d; Y7 N: K/ Q2 X+ l
  66. 0 l7 M5 B; G$ R. [. T
  67. /////////////////////////////////////////////////////////////////////////////3 w6 w1 j' o* {( t0 N7 X! D1 l
  68. // The one and only CRevAppApp object; u5 `3 R' c5 J% O! K4 Q  z
  69. + V' @0 D% |2 }2 }4 b6 Z5 s
  70. CRevAppApp theApp;
    ) }) M3 S2 i! {% b- W
  71. 8 S) y2 o3 O6 v7 i2 u9 v1 J3 m
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)
    " Z* E7 _% U: r
  73. {
    & u5 P0 h" v$ [4 V) `& _
  74.   int iEOF=0;
    ( t' }2 O  ?3 y# k2 F
  75.   char szTempName[MAX_PATH];& {% ^. ]3 J& R
  76.   *szFileName=0;
    7 i) f1 l: ?% E4 U. J4 R! z5 [$ `- ^* x
  77.   iEOF=fscanf(fp,"%s",szTempName);
    2 E) x. V+ N" a+ Q' m( O6 \
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    ; U/ t+ l( Z4 ]1 }5 u
  79.   {
    2 m2 p7 h5 W1 ?6 n$ q; W
  80.     strcpy(szFileName,&szTempName[1]);
      U$ d7 k3 [2 w) y, A
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    # J$ X$ I$ s5 C: n8 v  y- I6 T& a. m
  82.     {8 {" Q# ?1 ^. P8 @; |6 ^
  83.       iEOF=fscanf(fp,"%s",szTempName);- X) R" Q0 M2 W. @$ {; n
  84.       strcat(szFileName," ");
    ' a1 i3 d  W3 N/ ]* Y
  85.       strcat(szFileName,szTempName);
    & ?% b' _9 L* x( D/ N/ E
  86.     }* O( Y) n. k( L# H4 }
  87.     if(strlen(szFileName)>=1): a" [9 K; X8 s: W$ n/ p% |2 G
  88.     {  K  n$ A) p) a# c
  89.       szFileName[strlen(szFileName)-1]=0;
    . K/ q$ U0 t! e
  90.     }
    ) O/ C5 ?  Z) S# g2 h% Y9 y
  91.   }
    5 a- _2 k2 p, b6 n' L' [+ L# Q
  92.   return szFileName;
    5 L" S5 x$ Z" e$ p
  93. }" K5 G6 \: B2 J1 y9 F1 d, n. L. d
  94. % I+ N1 b$ h7 i4 Q1 |
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    ! x) }! G8 N5 d: X& N9 v3 D
  96. {( y+ x; Q# _; C0 c
  97.   FILE *fp;) ?' y8 x+ \4 a" D: u+ X% X
  98.   char *key=NULL;
    8 k" @( Q+ {6 |; j
  99.   char version[MAX_PATH];$ J! N- b0 b; A# o
  100.   LPUPDATEFILE file,olds;8 U8 x5 n# O; z+ `& g# X. A
  101.   std::map<CString,LPUPDATEFILE>::iterator p;. ]! z# J8 W5 N

  102. 3 o2 T% ?5 n! \  j
  103.   UpdateList.clear();9 a7 t$ O8 M4 _7 P
  104.   UpdateFile.clear();4 I3 N) c5 [% S5 S: x" x# C8 J. X* J
  105.   if(GetFileAttributes(filename)==-1) return false;! X# u7 B0 M6 k1 O3 D* [7 V
  106.   if(!(fp=fopen(filename,"r"))) return false;5 D$ y7 ~8 T! }1 J. y! p
  107.   fscanf(fp,"%s",version);
    * c1 u; a4 s' r! H' J" ^; @# Z
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }: {) e. B# }( [/ I: C7 A# {/ O
  109.   while(fscanf(fp,"%s",version)!=EOF)
    + G3 Q) I# p/ S4 ~- U- P5 ?
  110.   {# L- Z% u2 ]9 E4 g, c
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    , T$ n2 ?- |/ p, u) B
  112.     fscanf(fp,"%s",file->path);
    + _" |) ^8 [6 \( b
  113.     ReadFileNames(fp,file->file);' w" ^$ r8 ?  s# p- Q% ^' \
  114.     strcpy(file->full,".");
    $ C, g: F: I7 T* \. d/ `0 J  T
  115.     strcat(file->full,file->path);5 U; V1 w3 q5 e$ R7 y+ o
  116.     strcat(file->full,file->file);1 C$ V9 h# |3 k
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())
    + g. Y0 U% g( r, `
  118.     {
    " C, P: x) @+ ~2 E; g
  119.       file->vers=(float)atof(version);
    + u0 z1 h* X! O6 l
  120.       UpdateList.push_back(file->full);
    0 e$ _: Y8 D8 y# o! g
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
    ( g* U/ ?( E' T# {0 ~  j
  122.     }
      j( ?, r! g6 i1 K- S) `
  123.     else1 @9 Q7 B3 ^" r. Q. L1 Y
  124.     {; W# F4 ]. K  n" F8 ?" ?
  125.       olds=(*p).second;! q  o% [& k2 P9 _
  126.       if(olds->vers<(float)atof(version))) k2 k9 z6 T7 Q
  127.       {
    ' J$ i: c. [5 [. Z! V0 `
  128.         olds->vers=(float)atof(version);# J0 ]$ [3 P2 _: V0 ~5 l$ \
  129.       }9 P; a+ ?/ A- F6 J9 Y1 ]1 w
  130.       free(file);
    / z% V9 D3 P0 P' w; P
  131.     }: _* ~4 p' {' }# Q
  132.   }$ q1 f1 B. e5 O# s+ T0 b
  133.   fclose(fp);' Z# j8 R1 J5 U& D
  134.   return true;* t3 J8 I  j; ^" l/ g
  135. }
    " M0 b/ V! q6 t+ ~5 L2 d7 i3 {
  136. 0 g: s1 X; F( w( k- }2 A& H/ m% L& G: Z
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)
    6 N& m; Q1 ?4 H3 P2 @# t
  138. {
    ! M& b% }& W2 f# O
  139.   TCHAR  szFull[MAX_PATH];
    % k+ ?0 s- V7 }* l
  140.   TCHAR *token,*inter;
    & T+ ?% J9 g; t. e2 G
  141.   *szPath=0;
      V7 o; v$ a8 m8 `$ A1 y* [
  142.   strcpy(szFull,szFullPath);; l( |* g4 L% B- I( |' `
  143.   token=strtok(szFull,"\\/");5 M( k! i% O- c+ F) V3 c& `0 K8 Y
  144.   inter=token;
    8 _1 r7 I' G7 }  ]6 p) |7 s
  145.   while(token=strtok(NULL,"\\/"))
    % Z' s& ?* V9 N8 e8 `& i% y' C0 I
  146.   {
    / J/ F  ^0 H3 a4 v
  147.     strcat(szPath,inter);
    5 F4 N9 R; o! l0 {
  148.     strcat(szPath,"\");: S6 g+ ~  Q/ _
  149.     inter=token;
    ! @$ ?1 L# `0 L  M
  150.   }
    ' P0 F; x+ v1 b; U7 W8 s7 z1 u
  151.   return strlen(szPath);
    + W2 X6 q7 ^% I. v. E' j. T* _& |
  152. }, q  V7 g( h8 E+ V' k) N" B
  153. 3 u" d/ T. f# d
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)
    ) ~! h. @6 @" w9 B4 M
  155. {, C: b+ K% q( w
  156.   DWORD attrib=GetFileAttributes(Target);
    2 m* Q$ A- H: q6 c0 S7 ^
  157.   if(attrib!=-1)
    ) ?' I7 C8 f6 y1 Q- `4 r9 A
  158.   {8 O7 I8 S8 H( a5 B+ o" @1 [
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    4 s# ^! ], Q* o& X0 h; Z+ ~
  160.     {$ Y8 M* P$ G0 f( ~2 z( ]) K% ?
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);
    ( g0 {9 T- G" z% ~
  162.       SetFileAttributes(Target,attrib);) @; @) Y$ h, _4 P7 A
  163.     }( _) a! M, A5 E# j
  164.   }
    ( ]7 o' T) p& W- Y, t' r1 Q
  165.   CopyFile(Source,Target,Erase);- k/ b5 }4 t0 K' G) K9 v; C6 u. C1 x
  166. }
    / P7 U9 C/ l, C1 {/ r
  167. 2 h1 W, |; v3 j7 n
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)
    7 c9 ?6 n  |3 T& c
  169. {
    7 `  q9 D. |+ N# G
  170.      FILE *fp;
    ' D$ ~4 G7 x( n5 \
  171.      char  szBuffer[8192];. w8 D% m4 b/ n& E' q) H/ w4 |( A
  172.   va_list  argptr;- n- @9 Q( A3 P( G
  173. & m* c5 o2 r8 E2 b; Y% q* k
  174.         va_start(argptr,message);  X* a9 x0 x+ g! u. L& T
  175.         vsprintf(szBuffer,message,argptr);$ p" ?: b3 I0 B; d
  176.         va_end(argptr);9 D0 q. _1 R1 X5 |3 k" d/ G
  177.   fp=fopen(FileName,"a");: N2 D, O' i% Z- p4 r
  178.   if(fp)
    5 a% U! A- m3 i
  179.   {
      G- ^7 O+ Z. }3 r: l7 d% L
  180.     fprintf(fp,szBuffer);
    6 l) Y5 I* i3 n7 b
  181.     fclose(fp);
    3 F4 d/ K4 y  m$ o9 f% S3 |
  182.           _flushall();
    * N& w; e+ B+ ]3 y/ H# \
  183.   }! @' p9 o1 }6 k6 Z+ F* \
  184. }
    9 d9 j2 R5 K/ q1 U! F) ~& j

  185. / a+ P' A6 z3 C9 @4 V9 [
  186. BOOL CRevAppApp::Fclearf(char *FileName)
    * R( A' n7 t0 |+ z7 E( Z/ S5 p) G
  187. {
    ; t+ y8 F* r* y, y
  188.      FILE *fp;
    / U. @: q" |/ D( `
  189.     DWORD  attrib;
      Y( r2 Y9 X3 d9 i+ a
  190.   attrib=GetFileAttributes(FileName);
    ; T. D& H7 C! L
  191.   if(attrib!=-1)
    ( J" j! H% u- p
  192.   {" Q. `+ [" E$ C5 G0 P
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
    2 a8 _3 I$ W$ `. S
  194.     if(!SetFileAttributes(FileName,attrib))
    $ M* e1 Z7 D+ }5 [3 J
  195.     {
    + }* p4 l7 O0 Y& E) ^, r
  196.       return FALSE;
    % A. W9 D1 x# F6 D3 R0 k" U
  197.     }1 n* p. u& O$ x
  198.   }- V7 d9 i  k% F  K
  199.   fp=fopen(FileName,"wb");
    % k5 S* \9 ^" h) |; [8 Q, K
  200.   if(fp)
    2 U* R* A" L$ l1 d2 ]7 J* K1 F
  201.   {4 A/ K7 j# _: L6 i  `
  202.     fclose(fp);
    6 Z7 z! |# J9 J" U8 O6 v
  203.   }9 V5 P, o: B2 p9 `3 v# C. x/ {
  204.   return TRUE;
    * P- P# Z, t* C8 L' i
  205. }5 u5 m" T3 f2 x$ P& r" k1 G! p

  206. ! t9 a7 Z+ P) {. L, h1 F7 _
  207. BOOL CRevAppApp::UpdateLocalVersion(void)
    ) L9 r' f$ f; j/ m+ }4 q6 o
  208. {
    - S2 f" a  H0 ^3 a; V+ ^7 o1 ^; j3 n
  209.   char filename[MAX_PATH];
    4 \0 D7 o& l  Y8 z
  210.   LPUPDATEFILE file,olds;" ]2 \) s5 M0 @" g7 ~( @
  211.   std::map<int,CString>::iterator i;1 Y/ _7 r6 k8 ?0 u
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    * s: o0 ]: s( e+ J
  213.   std::list<CString>::iterator l;- m7 |" x* D9 {: z$ H2 d3 A

  214. 7 d5 j1 H, {& q3 I2 K& O& s+ I
  215.   if(bFirstUpdate)
    & c- d6 T7 g5 [# Q8 N6 C
  216.   {; }; u! N+ d* i# _* Q& J' ]5 s
  217.     dwCurrFile=0;
    : Q; f$ |" E5 s0 Y/ A
  218.     bFirstUpdate=FALSE;8 i5 h9 d5 N3 o7 Z+ y+ ^
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end()): s; l/ N/ q* S! U9 S6 ~( q: b
  220.     {
      i. c/ Q' C2 K
  221.       dwTotalFiles=UpdateLocal.size();; q* Y6 Z4 u2 R' \% o; u
  222.       dwDownLoaded=0;0 `% w% k$ q$ ~- D1 o
  223.       bSilentStep=FALSE;7 g' D4 h% L) h: f& ~' m+ H( N3 e
  224.       bCompressed=TRUE;( q  h- M# e4 p' C. P) p5 b
  225.       strExtLocal.Empty();# D1 o6 S! E7 O
  226.       strFullName=(*i).second;
    $ `5 h' E; w; A, Y8 s2 y; R- g$ _
  227.       dwProgramState=AP_CONNECT;
    8 Z0 j+ \* m, d6 o8 w8 q* A, [
  228.       return TRUE;
    . i0 F5 V# Y) X2 F
  229.     }
      r8 q% B/ q; @7 }. m
  230.   }
    ) ^5 H, W) F/ f5 J2 u
  231.   else if(bRestartUpdater==FALSE)
    1 r1 x, ~4 Y0 {% d: w2 E" d1 R
  232.   {4 J3 ^3 d0 `+ e2 g1 E
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())  i8 ?5 Q+ b/ d$ l. h( z, {
  234.     {
    ' R3 n" @' D- ^" X. A5 f1 ?) N
  235.       file=(*p).second;& Y0 z. s8 z* a. `5 z6 b8 c
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())
    2 P7 `* C8 ~! Y& x
  237.       {- C( T1 f7 S+ |8 g! `
  238.         olds=(*p).second;( m* E5 C2 O6 d8 z5 v3 p& F# T- l
  239.         olds->vers=file->vers;( Q* p: r) n! M: o& ]4 E
  240.       }$ L# M+ T& K- ~( s- G' H: [
  241.       else2 \8 C3 ^, d1 ]6 ^. `: f
  242.       {" S8 w7 k; v, B  z  Z* j& |
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    3 v$ Q0 J0 O) |( z2 c. a* A
  244.         memcpy(olds,file,sizeof(UPDATEFILE));
    . Q" o. ]8 D9 c9 E
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));2 h" ^  g( W0 @/ A3 I& l& `
  246.       }
    ) B* W+ |# Y: S6 X
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");
    # t+ Q& m  G& x; ^
  248.       sprintf(filename,"(%s)",file->file);
    4 `+ c& B8 |! J( @) f$ m# g. N
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);0 D- d5 Z& U% V% h+ v
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }
    9 e% c, \' ]# T! ]$ A
  251.     }* N2 g! |& F2 p, y. f3 v
  252.     dwCurrFile++;
    * r( n0 S! j$ f
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())0 f8 L! L' j& m' s; W8 D2 G
  254.     {
    ) m4 B( }6 p* `: ^! J
  255.       bSilentStep=FALSE;
    % a3 R$ o2 E7 s. r& J
  256.       bCompressed=TRUE;* y8 f- S( t8 G* a
  257.       strExtLocal.Empty();
      ], L  p0 e, C* X& w4 Y( d
  258.       strFullName=(*i).second;
    % X" w( f; H, {$ M
  259.       dwProgramState=AP_CONNECT;
    ! b, q, M8 ]/ N& ?, q  m' E( b# L
  260.       return TRUE;/ C+ }* @. Q# \9 v/ Z+ c) R7 T
  261.     }' @0 c" `' n7 m- P) E
  262.     if(!bRestartUpdater)
    6 K6 g5 P: ^' e# N% r
  263.     {
    : K( K& f; W4 Y
  264.       int iCurrSize,iFileSize;4 m' W" X& f& J+ n
  265.       iCurrSize=0;* O6 J' Z4 r) k9 Z. A3 x: h; N
  266.       iFileSize=UpdateList2.size();, t8 b: ?9 a% y3 K
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");1 t1 l, P$ K5 U0 h8 ?0 O
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");
    5 N2 a5 q% A  a" j6 g, g# y! ?% U
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");
    4 S7 y) o  W' i( _2 O! s5 B. e9 B
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    3 N4 E% V, S/ o9 b$ p3 O0 }
  271.       Fclearf(".\\update.dat");2 d6 L% y  {! F9 N( X) L: q3 F0 l) G
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    ' |: P2 T2 I$ Y# P! v/ b6 B) K
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)
    2 _8 ]2 J/ y  l, b; V! z7 K
  274.       {
    ; ^6 L# G6 o& P; K0 f
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())
    & ~1 l& A  g* k  @2 B
  276.         {
    0 h, d$ G9 m4 O
  277.           file=(*p).second;
    - d: s6 A* g6 m/ z. @' Y4 l9 L
  278.           sprintf(filename,"(%s)",file->file);3 v2 l( `" U( @1 w* P. P
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    " f1 m1 H- I: v0 e, m
  280.           iCurrSize++;' W) @8 q2 `! P$ W8 f- B
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));6 Z" `; W/ b2 G
  282.         }
    4 _  J8 |6 {# ?% z$ i  p) R
  283.       }7 \1 T4 x% q+ i: Y7 H* I$ D" V3 E# T
  284.       unlink(".\\update.txt");( a, D& d* A. j* g# j
  285.       unlink(".\\update.tmp");# y% [& l3 s1 f/ d" H
  286.       Fclearf(".\\checkversion.dat");
    & h; z( V0 V' @1 I  ]
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);: [/ F2 q9 R. [( a
  288.       if(UpdateLocal.size())1 ^/ R# a/ e$ C( N& M
  289.       {
    ! Q/ i6 W. K: f/ C
  290.         UpdateLocal.clear();- @; n) l- P; y3 y7 y! Z& V
  291.       }. [5 b; i" B2 }
  292.       if(UpdateFile3.size())5 w5 G4 z) k" f" U
  293.       {
    $ k6 n% M" H; @6 K8 `
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)1 U* _3 T/ C9 Y7 K3 j6 p8 Q
  295.         {
    6 y+ T2 `, v( P1 I" d7 T
  296.           file=(*p).second;% O* L+ N" I8 b
  297.           free(file);" B! ]9 i& F' F: W9 K" A
  298.         }
      |% i2 j$ u. I5 h% O6 i5 j/ O
  299.         UpdateFile3.clear();
    8 m+ p& b1 [3 b0 q' c8 U3 K2 }
  300.         UpdateList3.clear();
    ( [7 f' }9 }6 f- M
  301.       }6 T* ^; |5 f" }3 X+ B% i% j
  302.       if(UpdateFile2.size())0 R/ ?( p: `  {* f6 ^; v
  303.       {
    ' o1 N: _# m2 ^9 D: p& E
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    ; W- ~) D6 j" @( O
  305.         {; f4 I4 W6 g; b; ?8 ?# d
  306.           file=(*p).second;
    6 b& M! O, ^! r) `0 I: Y; p
  307.           free(file);
    , h( @5 h3 r2 e! P" b
  308.         }/ o8 m/ ~1 W  M( H& t
  309.         UpdateFile2.clear();1 p2 B% y2 h& ?
  310.         UpdateList2.clear();
    7 _  L/ Y) d4 e7 H. w$ ^. S/ w) M
  311.       }
    6 N( e# u3 ]( c, n- D/ N
  312.       if(UpdateFile1.size()); Y7 L; \6 x) f7 c! g
  313.       {- d( P. ^( A# F# _. G
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    * w8 P. Y1 z3 {! r; `
  315.         {. h% X* i% z; T  ?8 d( ~# s5 x5 H* @
  316.           file=(*p).second;
    $ B) E7 @8 O' D; \! L
  317.           free(file);
    7 T& C+ H3 y; {
  318.         }1 e# A+ S' O$ V
  319.         UpdateFile1.clear();
    . W$ S5 t4 @" R& u/ u: E& ~
  320.         UpdateList1.clear();1 [; Z$ U0 R# c" V- a: d2 z6 ]5 O
  321.       }
    + R- u$ @& W9 P6 e# v) E
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
    + ^* p" g* W" T9 M
  323.     }
    0 _1 x  d4 c; X+ P
  324.   }! o, V  A1 D- ?, P8 b
  325.   return FALSE;2 ^, [' t3 l8 Q
  326. }5 P' b! a7 f$ r& I) G  Q$ B

  327. ; \0 ^* E, Y" Z4 g7 X  m
  328. void CRevAppApp::ClearAll(void)
    ' a5 E& m, b; Q6 j* Y; x
  329. {
    " `& ?! ?- e* V& \4 t% N3 x
  330.   LPUPDATEFILE file;
    ' |/ e  h& q. u" g( ]; L7 I
  331.   std::map<CString,LPUPDATEFILE>::iterator p;# N0 Z1 ]0 O; e2 f4 h9 M$ f. ]
  332. ( d7 N' i! n; o! J; s% Z9 u2 u
  333.   if(UpdateLocal.size())
    ( ?( x1 ?3 o1 j% M, b
  334.   {8 N0 K( P+ |: `, c
  335.     UpdateLocal.clear();* ^6 z3 s( T) ^7 l1 w( p/ j
  336.   }
    ! V/ ~) X" }$ h0 D5 s
  337.   if(UpdateFile3.size())
    ; h" z, K4 x: T$ ]/ k
  338.   {
    & c  G/ S6 T' v- n4 |  @
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)6 M! @, j- ^4 B7 E  K7 V+ h
  340.     {
    * r3 A4 P+ h# G
  341.       file=(*p).second;$ i" i/ Y. s/ a! X4 w
  342.       free(file);8 {% N$ t; k0 {- Q2 v! r
  343.     }! c5 b! K8 n% h" S" u* u0 _5 \
  344.     UpdateFile3.clear();
    / ]$ f* R+ s9 t8 l, Y
  345.     UpdateList3.clear();
    $ _, r/ g, M$ s0 F* b3 k
  346.   }
    % h/ g$ C. b5 f( W5 }- v
  347.   if(UpdateFile2.size())
    1 E- N2 c+ G9 P5 T) |5 b* T
  348.   {
    8 i4 w& \- L" W
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)5 J5 [( z* u  @7 `
  350.     {
    : ?( T  H8 b1 @' ?  {1 L$ I
  351.       file=(*p).second;: S* j, _6 I; k/ `7 n' m
  352.       free(file);
    % }  ?- `  h9 y. ?
  353.     }
    " A7 }! G( D0 ?3 \
  354.     UpdateFile2.clear();) {% P0 G% U2 ~5 Y& z, Q
  355.     UpdateList2.clear();
    . `5 S, {. L% M
  356.   }
    9 h* `1 Z3 b( ]
  357.   if(UpdateFile1.size())
    - Z2 W; O; |6 }7 q; B% Q
  358.   {, C9 |0 c6 d$ I0 q# i
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    $ ~$ ]" b( Q$ T6 H' A* r/ C" W
  360.     {
    5 F5 R$ s. D4 h; z9 Z& ^
  361.       file=(*p).second;
    5 {8 \2 p$ j$ Z, C" C! c
  362.       free(file);
    : N* |1 n' C( p; p; v1 x1 c- g
  363.     }
      @& ~8 U6 W, `% V& m, Z4 O# h. {4 s
  364.     UpdateFile1.clear();
    8 Z$ e) M' o. D
  365.     UpdateList1.clear();: Y+ Y9 I* a. c. q6 s) R* a! _
  366.   }
    ) j1 X$ M& n7 x- U
  367. }  " H9 S5 m9 J/ H  t* J4 v* G
  368.   7 K4 n6 Q) n3 l7 X9 E
  369. BOOL CRevAppApp::CheckLocalVersion(void). Y6 J+ i* z& n' Q& ]  G( T
  370. {
    ( U6 L3 w) I! x) |4 e
  371.   int c;
    1 f* h- q/ O5 l7 J+ K
  372.   LPUPDATEFILE file1,file2;  I2 V* l0 y" q: ~9 z
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    0 l# {* _4 Q, e* F. w4 W: P
  374.   std::list<CString>::iterator l;7 K9 S+ f, `0 P' O7 E+ X

  375. $ K7 T# Z6 ^" V$ u7 _. F2 U
  376.   UpdateLocal.clear();
    " |0 y5 I0 ?2 d) T
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    9 s( H' U( z% k# C$ Y" W
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);3 f: G( b0 x  Q+ s& `& F9 ?
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);4 r0 O7 i9 a4 R3 U
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    1 s- i$ m* ~% v  ~7 O0 e: c  s
  381.   if(UpdateFile3.size()), t0 ?5 e1 d8 ]* ^- a. z
  382.   {
    9 |! {$ p# s: O& L& C, c
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)
    , ?$ H/ l/ }* f9 G1 j" r
  384.     {) ?; W7 W+ I) O' H/ f8 H( R
  385.       file2=(LPUPDATEFILE)(*i).second;
    : ]4 H. d3 J% e; b0 N4 V
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())" c! }& ^2 u: w) f/ |
  387.       {! e3 {) Z' B9 J
  388.         file1=(LPUPDATEFILE)(*p).second;) G+ b* O2 }7 ?8 h, c4 o# E
  389.         file1->vers=file2->vers;- m0 t1 J+ E6 }6 \  b& J
  390.       }9 p. ]+ p# P% h; `
  391.       else
    8 w) g- Z8 y9 g/ m6 b. R
  392.       {
    4 H7 [# O9 d! ]% B4 Q
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));6 g4 ^: `2 M% h: q
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));* t6 O" o2 g: e' X5 N. `
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
    - k( q& t$ w! R3 x8 ?: {- _
  396.       }' J3 M7 F) ~2 R- k/ c
  397.     }
    ) U9 H$ p- J/ C- J. u. u
  398.   }
    + X( x! R0 j' q$ w9 j& o" {3 S
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    4 g& J3 U* q& T( {+ U" |6 ^
  400.   {
    , @* k+ g6 |( F: F: l' f
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())
    7 g. F! w7 f4 U) p3 J2 k, V. Z
  402.     {
    ! e2 N' h7 U& x7 C
  403.       file2=(LPUPDATEFILE)(*i).second;
    . m6 [) W2 Q. B/ }
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
    0 t) S% Z6 X* b. n
  405.       {) Z; a; M7 `5 ^' c% I" i* ~) p% O
  406.         file1=(LPUPDATEFILE)(*p).second;
    1 \2 {! ?* r7 c2 o1 O
  407.         if(file1->vers!=file2->vers)
    0 v" x* Z, l: ]! ?. _& p  Y. P
  408.         {
    3 s8 w' J7 x2 _
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));( j& `: Y2 d$ @
  410.           c++;
    1 N. y0 u6 u9 ?6 z7 p
  411.         }
    & H, }, [! p. `8 K( s8 w
  412.       }: ]% u  A5 O2 M3 G
  413.       else
    2 b/ }7 t/ a' X- [
  414.       {
    9 Z8 }: U, V3 C/ ?. e0 a: |
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    ; }! O4 y9 |  k) }# u
  416.         c++;# f2 @, ^( {4 D
  417.       }; p/ p* |$ z- u* s, `" G
  418.     }
      S- f" z& U: R, W; G
  419.   }
    ( O2 C8 @* H; L' O, Z$ x
  420.   unlink(".\\DownLoad\\update.txt");
    % P# E) B2 r% s  P
  421.   if(UpdateLocal.size()) return TRUE;
    7 \) Q8 o: r  s
  422.   else                   return FALSE;3 l8 A4 }4 A, ~6 G, Q) n( ~5 u" G5 z' n$ O
  423. }
    & G2 U8 x) b, q& ^( B

  424. 1 D4 j* r$ B  j$ x/ c- v+ K
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"3 c9 T! K1 ?5 y+ \; k* r
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"+ p5 D7 ~0 i. H* N

  427. + W% _9 B- ]$ K0 t

  428. 4 l, @+ s4 Z% n6 S

  429. + Q. @# |+ I/ L, t& R
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)$ s: `1 D" V( F
  431. {  }$ y; A' U7 \  F0 e7 B! p5 O, {
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;% q* ~& f% w+ z  t- C/ f
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
    5 i9 c6 S* v" Z
  434.   {
    7 T) w# _: }; w% a6 [' H! [
  435.     char szLanguage[50];1 T5 [8 O( Q$ A8 x
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");( G" S9 H" C/ E2 c: E
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ( j8 k, h* u+ i: P' d' m* s
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    % x' O! i6 d. c2 t9 G
  439.     else                                   m_iLanguage=ENGLISH;2 @1 x6 ]  F) \3 p& w* r2 k
  440.     char szRegister[100];# g8 K9 ]+ \& i
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    - R+ b  t1 D0 V1 a1 P% M/ [5 t. G
  442.     strRegsName=szRegister;
    / M& i, c2 t7 F9 [) o- O+ `, ?* K
  443.     char szPatchURL[100];
    3 U5 o: V0 f- y' w' k
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    % ?6 [0 k& V+ C- t  _4 ^+ w
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    " Q) Z" B1 C( [
  446.   }# _, c* L* z4 M" S- f
  447.   else
    ; _0 s1 \+ B% {4 I
  448.   {
    ; c- X. F# _1 B$ F8 w: ?0 c3 B
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    8 Q) T/ |6 [2 D3 j
  450.     strRegsName=DEFAULT_REG_URL;
    5 e5 K( U1 z8 a$ G+ ^. a9 l/ P
  451.   }
    , Y: d/ [# ]% c0 @
  452.   if(GetFileAttributes("hosts.ini")!=-1)
    ! V' l. B0 h6 \. D4 M
  453.   {/ b$ {- a5 q- g* h
  454.     char szIP[50];3 G5 _9 N" L0 D: d6 W: _
  455.     char szDIR[300];' s; ?0 W* P3 P$ Q
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
    7 @+ w7 D% a# J( a
  457.     {
    - N. `9 m, m. d! _" _
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");
    , U$ x$ A- ]2 e% N- S
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");6 W" K( U& T3 X$ I
  460.       strHostName=szIP;
    + D1 r7 G! c4 k. v# X
  461.       strHostPath.Format("/%s",szDIR);
      S& O: u( T; M: x' @
  462.     }/ b( r7 r4 q# d8 M$ A( ^* b9 g8 [
  463.     else; l- n& k, F8 F) m0 o
  464.     {
    / k4 L( n; e& U3 b8 B
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1); h  r6 e; R7 T; q1 y  n3 f
  466.       {
    / c& i# S% n( N( r  ]$ r/ U" _
  467.         char szLanguage[50];1 h! {) j  w3 U; T
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");) e9 H* c% Y' g
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;8 \5 ^& K) Q* |- d. K
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    4 T) n* u$ h( K
  471.         else                                   m_iLanguage=ENGLISH;8 s- \9 r) J# b( v" L! i, b9 P, m
  472.         char szRegister[100];. ~: W" Z# R0 Q/ b- k  a
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");. }  G/ |' u5 c8 d. Q. d8 i6 T, v1 T/ Y5 x
  474.         strRegsName=szRegister;
    8 p6 B  y/ n/ |  C4 ?
  475.         char szPatchURL[100];
    3 E9 L0 z0 n: B- u1 z
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    8 O# F8 O3 {# `5 l9 P+ c# \/ g+ \
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    + n, B1 D3 k  p6 g. n6 C
  478.       }& r" L1 O5 o6 V# V7 t
  479.       else
    8 o6 N. \& o7 C* E2 |. e  c+ f, I
  480.       {
    & s' }4 K$ j7 q6 U4 x
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    " u4 I6 u: e" Q; |2 o) h- J
  482.         strRegsName=DEFAULT_REG_URL;8 r- O* u6 F1 O0 T* _0 g
  483.       }
    6 }: Y6 |% Q- N* ~
  484.     }
    * T& t( Z3 L+ W+ _- X- a
  485.   }
    % N( t$ b* ~! n. Y  Y7 |% f
  486.   return true;
    # T% h1 h0 B  y( G
  487. }2 s# s% Z, y0 i: ~4 r% ]0 \

  488. & X6 U- m, j  y1 K  J" W
  489. #include ".\ZLib\unzip.h"
    3 a6 g. q/ }" t/ Z+ B
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    ( G' s7 V; ]# D1 w' K
  491. /////////////////////////////////////////////////////////////////////////////
    , Q. t4 G  ~* `- i, i$ [7 V
  492. // CRevAppApp initialization/ r; J1 T. {" F! m/ y
  493. $ r5 Y1 Y$ [$ b) \8 G6 I0 A
  494. BOOL CRevAppApp::InitInstance(); Y' R1 S8 p6 e# ~
  495. {1 H6 o6 a/ j3 Y& H* a$ m6 _! z0 O
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    # B* q/ J$ k$ r2 A+ ^
  497. % m4 w& }2 W7 @" Q0 c
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);
    8 N8 @* G$ v- J0 B
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))- f& A; Y0 l4 S& t8 u. k' Z
  500.   {
    - n( p" f# {' c& Z/ Z* O4 y9 h
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
    8 F6 D; V7 F4 v/ Z
  502.     GetPathFromFullPath(szPathTarget,szPathSource);* Q8 }8 a1 M: R- l! e
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))9 t" ?3 B0 ~- c' ~3 ]
  504.     {
    + u* t+ T) {1 c  O% A
  505.       strcpy(szPath,szPathTarget);
    . R( }/ b: ?4 Z7 L0 e' B0 S
  506.       SetCurrentDirectory(szPath);1 W! i. y* G' ^( }; W
  507.     }6 r+ l+ S6 D: Z% U
  508.   }; S  j5 y" ~8 M5 T
  509. #ifdef _DEBUG* S* U! d, w* Y* b7 {0 C, ^
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    , z4 @' f* @) L2 M7 U3 [
  511. #else& j$ n" z* }3 A' H5 x) S8 i
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    2 N5 K/ X0 c5 C# L! f( Y6 @
  513. #endif
    * `4 H- I- d2 i4 m  J# b
  514.   {
    5 {; v  l8 I" R. P; @
  515.     char tempFileName[MAX_PATH];* ^* [3 Y1 I! d1 q' I1 Q
  516.     strcpy(tempFileName,szPathSource);
    0 L* R0 {' ]6 V1 l/ k* p+ c( g
  517.     tempFileName[strlen(szPathSource)-12]=0;* O# |4 A  H8 W1 w# W5 ]0 h
  518.     strcat(tempFileName,"\\$CSUpdate.exe");; p, }+ y9 u0 Q2 S: O
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);) m0 J% Z. C! Z0 r% M
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);5 M& h3 U9 p3 F/ `" I5 G
  521.     return TRUE;) r4 ~+ |6 ^; H$ z; F! V
  522.   }
    5 f- S7 z# b1 e5 @' k* [/ o
  523.   // Nuke 0118: Delete run.exe
    , V7 g/ F  s- r" K8 t
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
    & ?# _( Y5 J  r" A: B5 U
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");
    ! I3 l: [+ r7 _% f: i, w: U- }" f
  526.   if(!ReadCfgFile("Config.ini"))  M. _0 q' m8 }; x! [) G
  527.   {
    / K) R! b% T  V; q/ i
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);
    ! H3 ~1 v) b$ F
  529.     return TRUE;
    . O6 R$ }1 K. F+ Y8 Z$ a
  530.   }) z( H0 v8 F$ V8 }
  531.   HANDLE mutex;$ k9 C0 e/ `7 {/ l9 v
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium")); D5 {3 D% Y8 V) O
  533.   {
    2 e3 l$ }. U* i6 M( K' n
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
      v8 }  `$ y$ T1 B* j
  535.     {* T! a3 J8 u7 A7 i3 _5 z' Q8 R
  536.       CloseHandle(mutex);
    6 P- h! V6 C1 W. H. q- h% r/ d- l
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    / O# V/ e: [' I& l6 n7 N, }  D. v
  538.       return TRUE;
    : z5 q& C/ D" k6 Z1 b
  539.     }
    . H5 X* F( Z5 }, M  P/ K
  540.   }  
    8 L1 ^6 y, l+ Z/ c1 ~) }
  541.   CloseHandle(mutex);
    " u) \0 Y  L! F8 S9 B/ i
  542. " o9 r. B5 H7 Z' D- _7 T
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);
    ) ^$ E0 M! w, o5 T" h7 W

  544. 5 P( e8 E/ U' v3 I7 a
  545.         AfxEnableControlContainer();4 }+ C2 X  U' b8 Q

  546. 8 Q' O4 s+ Z$ j
  547.   bCanUpdate=FALSE;1 ^3 y5 j- H" {* _0 ~" P
  548.   dwStartUpSteps=1;$ z% L, p% c: Z% K
  549.   dwProgramState=AP_NOTHING;
    9 E9 A5 O1 o$ g7 g& z- R

  550. 1 D, z+ w) C, q/ l9 ]5 e
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);6 k$ w/ B' F& d' g5 L1 k6 h

  552. % S0 w7 {* A7 V+ o
  553.         // Standard initialization
    7 D( D4 Z0 [5 j7 Q$ S$ U# A: r
  554.         // If you are not using these features and wish to reduce the size7 f/ w0 o$ G/ U
  555.         //  of your final executable, you should remove from the following2 {& j( A5 {/ u& `. v2 \6 D5 K
  556.         //  the specific initialization routines you do not need.- A" v( R2 M2 Z" O) o' x7 O5 P' j
  557. ' Y& g% U, X/ }8 }8 u! ^8 c, h7 Y
  558. #ifdef _AFXDLL
    ; E/ H0 Y3 j9 M" d
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL
    " U3 B7 ?. A' y
  560. #else
    & a! E5 Y! x1 [9 [6 X! i
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically0 B, q# A* {% K* f' ]0 ~7 \( U( R
  562. #endif3 w' W8 M1 x# E: ^( w+ y
  563. , e& W" H  \: a4 G. k
  564.   dlg=new CRevAppDlg;, ?1 b, _/ K5 J7 a% c/ ?$ V& c0 e
  565.   dlg->Create(IDD_REVAPP_DIALOG);( a; x& J0 [/ ]: n) e/ J* G1 n
  566.   dlg->ShowWindow(SW_SHOWNORMAL);" x# t0 i0 j2 K
  567.   m_pMainWnd=dlg;
      U5 b; C  Y8 t

  568. - q5 Y8 f9 N9 R
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);+ t7 K# k4 p6 u; a9 e# C
  570. 5 q$ p# a2 C2 Z, ^7 L
  571. //  GdiplusStartupInput gdiplusStartupInput;
    ; r3 G4 J: d/ J+ n
  572. //  ULONG_PTR gdiplusToken;+ I2 M% H6 n+ _" j1 ~3 c
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);. p; H  z3 n  M- o5 K6 @

  574. - i- ^5 v' C# @! s  k0 _$ D: @
  575. //        CRevAppDlg dlg;
    3 B: b) ^! h) U' m. r! ]' F
  576. //        int nResponse = dlg.DoModal();
    ! o& T" d' h, O6 \
  577. //        if (nResponse == IDOK)
    ' z- P& j: y/ U# z5 S4 M' f2 l
  578. //        {, N5 h/ t  v0 U( o
  579. //                // TODO: Place code here to handle when the dialog is
    0 O  R  z) Z# O/ }6 p! B0 M7 n5 k
  580. //                //  dismissed with OK
    # r1 g  W9 e* ?. P/ k
  581. //        }
    * e+ _6 A: G8 l# B; o+ |
  582. //        else if (nResponse == IDCANCEL). J* e7 ?: q& E+ G" ?  ^1 p: V
  583. //        {* F; m0 N/ W6 x" j2 Z
  584. //                // TODO: Place code here to handle when the dialog is
    * M( S% Q8 C8 Q  G9 u
  585. //                //  dismissed with Cancel5 a: V6 s  q" @& c# t8 H
  586. //        }
    , Q/ J% C! T( |3 ^

  587. % ^$ n+ L/ s( a6 {% r
  588.         // Since the dialog has been closed, return FALSE so that we exit the
    ! z" m, L. R8 Z& S! j
  589.         //  application, rather than start the application's message pump.
    1 ^2 i& z7 a7 o$ S+ G. I( G
  590.         return TRUE;
    # W3 o! P" B! O: `0 M+ P
  591. }
    ! z+ O0 n2 e/ a% D) A

  592. % m7 B" ]9 G) c& X4 ~
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    . H5 u; {4 b- o# \' B7 k
  594. {; ~1 T* x! ]% N" s) f# |
  595.   int i;
    5 A! a, [8 J+ a+ y  _7 ]
  596.   char *szRet;
      ~1 P2 D& x; u0 Z0 p
  597. & X" B5 [7 E5 N" |
  598.   if(pSource) { itoken=0; sztoken=pSource; }
    " N( c; J" u! p* N1 {
  599.   if(sztoken)
      U2 Y# ?9 n; v/ v# a* {* J" X
  600.   {4 G1 L* Z' h" ^: w# y5 b
  601.     szRet=&sztoken[itoken];% I( ^# k1 H) r; W! G
  602.     while(sztoken[itoken]). X  s/ @$ g8 {' O
  603.     {& G2 E- t9 M7 l# r9 c, B+ m
  604.       for(i=0;i<(int)strlen(token);i++)0 s' Q) S/ j% }7 m3 l' \0 S
  605.       {
    $ v' t5 x2 z3 a) R* U5 s
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])+ q( V# d! M% y) c6 n
  607.         {
    , c9 R2 ^9 R# T% Q4 b% y: @
  608.           sztoken[itoken++]=0;2 A# j8 R5 b" n
  609.           sztoken[itoken++]=0;; Y- Q+ r6 c2 b% P7 D
  610.           return szRet;. R6 g/ ~, U+ U( y# u& k" j2 D
  611.         }1 f3 Y( ~" @. U* Z
  612.       }
    8 w: a$ s8 _+ p/ ~
  613.       itoken++;
    . n4 q3 [# k: x; a7 L0 ^2 s
  614.     }
    4 W  v, I9 T1 q
  615.   }
    6 A# f; w: i( ]  n$ L4 h0 n) B" e! N
  616.   return NULL;
    7 @$ w) g8 b  x' c( q/ Y7 l
  617. }
    + _( N  I" {! Q
  618. : i$ v2 ], T8 t- O7 d
  619. void ProcessProc(long Total,long Current)
    ' L* n) f/ ], s8 u2 ]
  620. {. \" o6 f3 J1 f! J. ^2 j1 w- b
  621.         MSG msg;% G0 W5 g8 H+ q* G3 x$ E
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);
    ( [  N  O! ~4 X/ A! k
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));- ^: v8 w2 ~$ H/ o( Q+ T
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))0 W% X( j: D9 o# H; x) }7 |
  625.         {; r0 u$ H. }% ]1 B, ~
  626.                 if(!GetMessage(&msg,NULL,0,0))
    - j* x* D4 j( {, _, ^7 K# V: C" z
  627.                 {
      M9 ]8 Z; S/ e6 @' V  h
  628.                         return;
    ! N( \* m* n+ u5 g  _& K5 T! y
  629.                 }
    / Q4 r* g0 L8 D- O
  630.                 TranslateMessage(&msg);
    - P6 k- B0 e4 J. \
  631.                 DispatchMessage(&msg);# Y1 L/ t! J5 t, e+ a
  632.         }       
    1 r  r' ~$ e" T6 z9 O1 \& \4 j
  633. }
    : u2 q! C* E2 Z. C# a6 m1 l, M
  634. * }2 u! e$ e2 _3 D% E' s7 [- H
  635. BOOL bFirstChar=TRUE;. B4 j$ v$ C& r9 k! P) G2 X

  636. 2 j. S. s! l* q5 e
  637. BOOL CRevAppApp::OnIdle(LONG lCount)9 J4 H& ?7 k% N
  638. {7 t. A5 Z6 R% y6 K! |) x
  639.         // TODO: Add your specialized code here and/or call the base class
    9 C4 ~" U) K% w. P) X7 x
  640.   switch(dwProgramState): s: C) M% |) K+ B, t0 X
  641.   {
    8 d& {5 A* C4 H( U$ S) K& H( `
  642.   case AP_NOTHING:0 G7 i0 `0 T" m3 T
  643.     switch(dwStartUpSteps)
    & @- t, \# {6 f8 e  k
  644.     {
    1 |* A0 D7 z5 s! {6 E
  645.     case 1:
    * T, a% K% g4 P0 i. ?
  646.       {
    / L. ]1 K& K: J$ h/ ]% G* s0 h
  647.         int i;
    ; L' v  X5 `8 k
  648.         CDC *pCDC=dlg->GetDC();! K" [; j6 |+ Z/ q5 I8 B/ f  [
  649.         HDC hdcwnd=pCDC->m_hDC;* v  t4 t5 _. K  c/ ]
  650. //        Graphics graphics(hdcwnd);& Y& K3 o# a; }+ h7 ?
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");" T; _1 p6 t- t" _
  652. //        INT iWidth=bitmap.GetWidth();
    % Y5 ^# k* ]+ l; ^* P, g2 \
  653. //        INT iHeight=bitmap.GetHeight();
    0 a) Y4 d- x0 q" s
  654. //        Color color,colorTemp;
    5 M7 y( I( i/ d  K$ F4 t# u
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)
    9 A2 ^- ~3 D. }" Q6 q! _, Z( _6 M6 D
  656. //        {( D+ s9 F) a$ t) k7 [- r
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)6 D) q: K8 z. N4 m
  658. //          {
    ' R, r3 v5 N! y# W/ V0 X
  659. //            bitmap.GetPixel(iColumn,iRow,&color);) z4 K; m* K7 h/ g
  660. //            colorTemp.SetValue(color.MakeARGB(9 s( g  g7 B/ N* g& u+ R
  661. //              (BYTE)(255*iColumn/iWidth),- m' I7 P" a* w
  662. //              color.GetRed(),
    / T5 U8 q9 M5 L) G$ Q5 |0 u1 g2 U( M$ P
  663. //              color.GetGreen(),! m2 r- y7 F' u
  664. //              color.GetBlue()));
      g0 q; x' f: `# Y/ F7 w! \5 ~5 s
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);; g# s; _- B8 b' k8 q( e
  666. //          }
    - ]9 Y2 U0 R" o1 u" G3 l" g! S
  667. //        }% j9 a4 k- o+ n: g
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    8 z7 `4 C  C8 g0 I
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");% \) J/ Q( q0 x$ W1 E" M
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    9 b, h% F$ W# i5 q! h( ?
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    / Q8 [, H) \$ A  l1 R: T8 d! E. v
  672.         for(i=0;i<240;i+=8)/ N/ G! N4 p, u- ]0 h- `. p$ u  h
  673.         {
    5 v8 ^' w# x$ M; S! p. t3 k1 L
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);2 B* P$ }4 T& X' T3 k1 H! F5 C9 F
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    . Q+ y+ D) G+ `1 Q
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    - E+ [% s5 X+ a. m- l
  677.           Sleep(33);& ]. [- H: A- w
  678.         }; g9 ]. U2 e0 j
  679.         Sleep(1000);
    . a. N. h$ `4 h* Z8 ^, T1 W
  680.         for(i=240;i>0;i-=8)
    8 h, o" I# R- S4 Y. S  f& u1 F
  681.         {+ c6 P0 W0 p3 |2 r- v& o
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    4 `$ Z" h7 M( A3 _" a& Y2 T
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);- r: X8 k1 v) F2 R, {  O* ]% B0 C, u
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);) u( F; n8 t4 H6 r6 ^9 \) J' b, ~
  685.           Sleep(33);
    2 N0 l  A0 T& G5 Z# \, r, i
  686.         }
    % X7 W+ s; e) Y5 z
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
    ) H* A; q+ M0 m2 j
  688.         dlg->ReleaseDC(pCDC);
    2 o6 c% C6 c7 ?* a+ n4 q+ Z
  689.         DeleteDC(hdctar);
    / s- S2 s0 t: O0 y- |  V
  690.         DeleteDC(hdcsrc);
    , `# Y9 t1 C; ^/ x
  691.         DeleteDC(hdcorg);# J* Q% X2 C8 K) ]! t
  692.       }  J1 l- @0 s: l9 B6 @: R" j
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);8 s* T) a. {0 u. k- U7 T* V$ ?
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");
    2 ^2 W- z7 q& q# J0 |
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");; [8 I( Z5 A  ~5 r
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");
      E7 l8 a1 S& X3 }
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ' q2 [( y& ~) g; n* q& R9 q
  698.       if(!Dn.Connected())
    . m' q4 c; K. R" u
  699.       {; {* J0 \0 o7 @4 e4 N
  700.         dwTotalFiles=1;" w+ Z. B) D* B8 d0 q
  701.         dwDownLoaded=0;
    / q" z9 T" i, t
  702.         bSilentStep=TRUE;  x* ^9 H1 ]7 Z: v) w9 @' o
  703.         bCompressed=FALSE;
    2 {1 c* e) V& d4 c# E$ D9 l. ^/ @
  704.         strExtLocal.Empty();
    & y2 T( `  `3 o8 A
  705.         strFullName="readme.txt";% C# i8 B9 D. w1 B
  706.         dwProgramState=AP_CONNECT;
    7 \; I8 p/ d% k9 w
  707.       }
    6 o2 U4 s( j0 C# {6 N* F# v
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();
    ' x' V. p0 S9 _& p0 F  ~
  709.       dwStartUpSteps=2;
    # y9 \; ?% m- y# z7 Z* t
  710.       break;
    : D! Q  ^- U. T; f. m8 P0 b
  711.     case 2:" p; T4 T3 W0 U/ y4 r
  712.       {
    ' Y0 a4 S. |+ u% b, c$ M
  713.         int iEOF;
    : H! f) I2 G8 Q  Q6 q! K7 D
  714.         FILE *fp;
    8 A3 ]" g/ J6 @5 W/ @5 e
  715.         char szString[512];
    . t6 U' o3 I; O1 U  R3 {
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");
    " S! p; S) ]( `# C' i0 v; _
  717.         if(fp)( C# [& s: @( R
  718.         {
    / X, a  h) K0 s0 G+ Q- j/ r9 O7 ~
  719.           do
    , P/ N6 w  g& O+ X1 j: s! Z% N
  720.           {
    3 D$ T4 D. [: W: h
  721.             iEOF=fscanf(fp,"%s",szString);" s0 ]: P& c' m: D2 G
  722.             if(strlen(szString)), C; G; E5 b4 b; R" `9 n
  723.             {
    & l8 G7 i  r% t% s3 e
  724.               if(bFirstChar)
    : ?* e& n/ d: |8 P5 ^
  725.               {! Z- }# c! F9 x$ |
  726.                 bFirstChar=FALSE;3 I) v8 H4 m  {- j
  727.                 bConnectIsBig5=FALSE;1 i1 e* J% O5 S: G. _
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;, ]% [1 q) Z, T9 z8 V3 C
  729.               }% O, ]# D7 Z4 y+ [( v
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));' M3 D4 l8 E6 l: j
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));4 q3 E6 R/ ?* ^4 t4 Q, G; L
  732.               dlg->m_ListText.AddString(szString);! C: Q  U8 W  Z# E+ V' S. o
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    - Q, C- M' N4 F3 M$ g8 j
  734.               *szString=0;
    4 y, z3 K9 L# |: `8 E* N6 D: C4 D6 ^
  735.             }
    & w2 k9 E+ K1 O+ j
  736.           } while(iEOF!=EOF);
    : C0 J: S5 k+ {* m$ U( c! k$ y. n/ w
  737.           fclose(fp);1 o3 O, r4 R4 ?- T& q% u
  738.           unlink(".\\DownLoad\\readme.txt");
    ! z2 ?6 P/ f1 G8 n7 N
  739.           dwStartUpSteps=3;
    & r: K( V* @7 R" T+ u! y+ d
  740.         }4 p& V) t+ {2 b3 q# W2 z
  741.       }9 h4 ^* W' z: B: _+ c; u
  742.       break;  M3 i# I. O6 t
  743.     case 3:
    ) f- N6 P$ f1 n+ g1 R+ x, P; C2 v
  744.       if(!Dn.Connected())$ Q( z2 P4 |  c
  745.       {
    6 S6 h4 ?: ?, t$ v3 }7 A
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);
    ; L4 Q1 f1 ^) j7 J! b
  747.         dwTotalFiles=1;
    " T* h6 m) H1 \+ J7 p  `: C
  748.         dwDownLoaded=0;
    8 M5 G; x/ D! m& F
  749.         bSilentStep=TRUE;  _- w/ L7 h; h+ D, B8 ^
  750.         bCompressed=FALSE;8 x! S0 f  M" O* U
  751.         strExtLocal.Empty();
    6 {; h+ q/ S; Y1 @; J( J
  752.         strFullName="checkversion.txt";
    $ s1 e* G$ \4 k. ]8 ^
  753.         dwProgramState=AP_CONNECT;7 `! D# P" M0 d- r( {
  754.       }
    ; M  z6 Y. Z! P& ~8 o& y" V& I- p: {
  755.       dwStartUpSteps=4;
    3 g. K, {8 m) y, @
  756.       break;
    + ]  a  I) e! U) K1 y5 L
  757.     case 4:0 a& m) g( p2 y7 `4 \
  758.       {
    ( _/ a3 I5 w0 f1 J' c9 t4 H
  759.         FILE *fp;
    : g5 R, f: j0 y% U& o# {$ u3 d
  760.         char szString1[128];
    & A* P3 u) X0 Y8 n1 E4 T
  761.         char szString2[128];8 l5 Q: O2 y: [" B) y
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    1 d% u* b: \% L7 e" |
  763.         if(fp)
    1 f$ g. ?% y0 q) w* E6 `
  764.         {
    3 S. n9 l! k+ N# G9 }3 D
  765.           fscanf(fp,"%s",szString1);4 M0 |2 ^8 F1 ~! z! i; K8 ]
  766.           fclose(fp);2 y/ H/ _& |9 J* y; o
  767.           fCheckVersion=atof(szString1);( y# d9 d+ c" t# H
  768.           fp=fopen(".\\checkversion.dat","r");
    / V8 N2 l+ {. d1 @9 @
  769.           if(fp)# g, G; y/ {5 ~& {3 ~3 B6 _* q+ a2 I. c
  770.           {1 y4 K. @- Y: ^  j
  771.             fscanf(fp,"%s",szString2);, F+ D) ?0 `; [6 f
  772.             fclose(fp);
    5 c' e/ I% g, y1 T' j  _# h
  773.             if(atof(szString1)!=atof(szString2))
    ' }  t$ A) q* x. R# B! g. z' w. b
  774.             {
    : i) u3 r, D' h$ S
  775.               if(!Dn.Connected())
    : t0 w! S* e1 P3 f  x
  776.               {+ d, `% S, x2 M+ C, k
  777.                 bFirstUpdate=TRUE;
    " ?8 H- r( c8 q* ^0 f
  778.                 dwTotalFiles=1;
    + U. e' z; G$ r
  779.                 dwDownLoaded=0;% @! q9 K* S3 d
  780.                 bSilentStep=FALSE;9 L+ b$ p6 Q; X7 M9 {
  781.                 bCompressed=TRUE;0 E1 e0 J& x& J  @& z1 L7 l
  782.                 strExtLocal=".\\DownLoad\";- Q. c: u; o. b/ n+ e
  783.                 strFullName="update.txt";/ J8 z4 {# [! A, M: ~) c- A+ [* D
  784.                 dwProgramState=AP_CONNECT;) G6 P! j/ z, b5 I2 B8 j
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    " I. Y/ o/ S5 O2 O
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");  E1 o9 y3 m* l5 S
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");
    ; a8 A9 R1 c0 y4 h8 ~

  788. ' E6 t/ @8 L# c
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);7 k# K( {) K! G/ b$ c
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    3 I( p2 Z$ L5 r* }
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)$ h# D  W; d" R5 w, T1 `
  792.                 {
    * P( i- C" d' ]- o/ O* F# G& V
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
    6 `2 D# \% l% d% L2 p9 `0 Y
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");/ D, ?$ O0 h# b2 [; u
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");
    6 w$ J4 S5 E. v) E$ n( h+ g
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    1 P1 h' p# L$ i1 R4 V2 k

  797. - S6 q8 w5 I3 |4 ?, p9 g* Q0 t
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    - ^* t* W: y$ \; V$ ^
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    6 S; o# _9 v; D/ k2 r/ Q' l3 _
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");0 t/ |7 e7 ~$ A, J
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);, F! Y; Z1 Y5 q8 ^6 ~/ J- [
  802.                 }5 ^# d- ^4 D& p* c  U4 t
  803.                 dwStartUpSteps=5;8 y8 e* Z4 o2 `! z9 ?% G
  804.               }8 M4 W0 n2 C/ ]* I- z
  805.             }
      N# _" M/ o1 k  p  }4 X
  806.             else7 j% X/ t) h: P6 N. H# i9 R& j: f
  807.             {
    , i' `) ]: x  ?: P# w$ W
  808.               unlink(".\\DownLoad\\checkversion.txt");5 ~; v7 V6 {5 S+ H! o
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    - O! q, a9 U( V3 |3 S
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    & f; y" d; m  F. ~" i  m! j
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");
    . l) @4 b! a3 j; G/ }
  812. 7 y/ x9 i3 ^: x& G
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);8 s' m5 Q6 D" C5 V: a' ]
  814.               dwStartUpSteps=99;* Z2 c: v6 M/ c6 Z$ A
  815.               bFinishUpdated=TRUE;7 f- ?2 ^; E5 h8 O' L: M# b. R$ I: b
  816.               bCanUpdate=TRUE;
    6 S6 s7 r! S# R, u
  817.             }
    1 k' O/ B  N$ x+ l
  818.           }5 {& p8 T7 k2 B8 J3 B" @
  819.           else0 N/ t$ Q6 {! w: S. }3 W2 m
  820.           {  G4 g' k7 d' J! C
  821.             if(!Dn.Connected())8 h; H' m, a# d4 j
  822.             {
    % o9 M3 v' o2 z9 r: y
  823.               bFirstUpdate=TRUE;
    : X! L0 r& |1 D* u+ ~+ |: }1 `
  824.               dwTotalFiles=1;
    + v9 {8 W, F9 i, q5 s
  825.               dwDownLoaded=0;' i; A( ^0 W  P" \  J
  826.               bSilentStep=FALSE;, [( ]. c0 w+ O, ^# V
  827.               bCompressed=TRUE;+ s7 q$ `4 Y5 n6 J# V4 u) e, Y
  828.               strExtLocal=".\\DownLoad\";
    9 ^2 r6 L* s5 i- Z5 V
  829.               strFullName="update.txt";
    0 y' S/ _1 v7 ?1 Y, X# G9 Y3 s# w
  830.               dwProgramState=AP_CONNECT;
    0 Z$ ?; u& \+ n. W/ m( F" [) U
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");% }: L/ c' [1 \6 ?, V* f3 O8 n/ X
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    6 U: e- t0 ]- g& h% ~- j+ S/ Q. {
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");6 l' `# ]! A* E5 P+ |- R* b$ W
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);1 e/ _: b1 D. h( g8 k: z
  835.               unlink(".\\DownLoad\\checkversion.txt");
    8 W9 c0 ?# w. k; q- k
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)! h  J6 ~% }) D, Y0 B7 K1 C# x
  837.               {
    $ w; S# f% Y% j$ a8 R/ h2 y/ m& o
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");2 ^  l6 h; T# `$ `- H3 r# e  s+ c1 l
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");
    5 N; G0 D5 G( h. `9 W+ G  Y# v
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");
    , A" u* R% @( y. ?) E  \7 T5 S
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);* e4 I2 M1 O& N  Z8 d- J
  842.                
    9 Y- C; \2 A" t! ~
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");$ i9 u* u& |6 D
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    0 x1 u9 }7 o9 [, R
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");5 \  o5 j/ L+ C7 c5 B5 W* [4 @
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    9 X, l% b' W2 z( U4 x3 q' L
  847.               }
    - p9 [# \% l2 p# T* W8 i: h
  848.               dwStartUpSteps=5;
    , g( k* }/ @0 ?
  849.             }( c7 W6 G" j0 K5 P0 b9 k$ P( V
  850.           }# t0 ]+ I" ^: j' `+ w
  851.         }# A4 e7 m  b- A+ W  \
  852.         else  V6 b' U- H. t6 Q' V; G5 g
  853.         {+ W0 F' s( B; r! n, N
  854.           dwStartUpSteps=3;
    ) }7 B9 t  l9 I+ t- k& S. s
  855.         }
    ; b$ y" X4 F- k8 [) M+ e" u, C& [+ }
  856.       }
    : d% l( \  n( t9 _, X
  857.       break;
    : h. s+ ^% i2 @% a2 N
  858.     case 5:
    ; G8 H& H. o, X1 }  i
  859.       {
    4 ]& d  K2 T/ _# W0 ?  j) y
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)% ]# u; o$ c2 n) V
  861.         {
    $ C9 L5 E* e# M7 N, Q9 u
  862.           int opt_overwrite=1;8 c( N6 Y5 I( n: J5 J0 |4 ?
  863.           int opt_do_extract_withoutpath=0;: j* t# T1 v7 X+ B9 W. W& U7 c; I- q
  864.           unzFile uf=NULL;$ q' E5 m( ^3 J, S: Y! Q' L
  865. + U: @: W2 Y2 z, C$ ~2 v
  866.           uf=unzOpen("Wsa.zip");& B/ z0 B4 t$ A* D" o  \0 d+ R
  867.           if(uf)
    $ |* U+ P+ F2 }( _% E+ j
  868.           {# \3 N' U8 C( J1 \1 m, h
  869.             do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
    ( e# c! x5 C; ]
  870.             unzClose(uf);
    ' z/ \% k4 t! E; W
  871.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃ЧΘ.....");1 o1 }( u$ v. A  Z
  872.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压完成.....");
    - c# J3 }" j7 Z# h
  873.             else                                                      dlg->m_ListText.AddString("Unzip OK.....");
    ; `+ g# b2 ~4 D$ [" H1 \
  874.                                           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    9 m: W; }- z9 ?/ n7 t7 h1 u7 H4 B
  875.           }3 r! x% x, u, b
  876.           DeleteFile("Wsa.zip" );$ R4 b/ p! c  B! J7 K' t) R
  877.         }3 Q7 f! G8 g0 H# K8 u2 Y2 F4 v

  878. 4 f5 m5 M$ m5 C( ~& N( g6 [+ x
  879.         if(CheckLocalVersion())
    / ~8 }; B' h7 |9 x
  880.         {
    2 R; Y8 E" p, X$ Y9 p
  881.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫磅︽絬穝戈.....");
    # y: P4 G. F! C
  882.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请执行线上更新资料.....");
    % H5 ~2 J( W# ?: J+ w1 J* s
  883.           else                                                      dlg->m_ListText.AddString("Please update.....");
    7 {& y0 _9 J- k6 c) _, s
  884.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ! w9 a9 Q3 G6 n
  885.           SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);
    2 B9 t# m5 y5 z5 ?, _2 q. b3 G3 u
  886.           dwStartUpSteps=99;! n6 M& B$ \" b9 g3 b) Y- D7 P
  887.         }+ o3 M; A; ?8 p- h  W
  888.         else
    % S; o3 W. s3 R
  889.         {
    , S$ E. Y9 X4 b( ~1 e4 z/ j8 d
  890.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    3 o# d9 _/ r6 j/ U" N
  891.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
      e; ?% l% i/ D/ B
  892.           else                                                      dlg->m_ListText.AddString("no new file update.....");! b" y2 ?, s+ B

  893. 1 n6 t3 |0 |" P" [$ q
  894.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    4 s5 {7 M( `: o' Y# ?  ^6 n+ d
  895.           dwStartUpSteps=99;7 a6 t! k" V. x" [$ ~% Z
  896.           bFinishUpdated=TRUE;5 `. B! R5 G+ P! J, |5 o
  897.         }
    7 u3 X8 H- @) x+ G9 ~% t
  898.         bCanUpdate=TRUE;+ _- @4 i- B2 c/ A* w
  899.       }5 p5 c- D9 O5 f( O7 X( K
  900.       break;! J, P( b1 i* n
  901.     case 6:
    # E1 W1 r; i6 F. c$ O9 b
  902.       {
    & f6 R' J$ i9 a4 ~6 c1 V* B
  903.         if(!UpdateLocalVersion()). @! R3 `2 U' z$ z3 D
  904.         {7 q& G. ^3 L" j. t7 \$ Y
  905.           if(bRestartUpdater)7 }0 L! g) [; b, Z( R2 \
  906.           {4 q6 p: W, a9 [/ p' W6 l
  907.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);
    6 H' l0 o! G0 R" G8 j
  908.             else if( m_iLanguage == SIMPLIFY_CHINESE )                MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);
    5 w7 o, `* D; W2 ?3 X
  909.             else                                                      MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);9 s- K( `3 |$ S, [
  910.             DestroyWindow(m_pMainWnd->GetSafeHwnd());7 E" R$ P5 \9 v  Y. R" F
  911.             dwStartUpSteps=99;
    5 j% U4 {/ M9 s' F
  912.           }
    ) `0 f* Q4 Q9 Y, x/ W) U. M
  913.           else
    3 U0 n. C  J% ?( q8 H
  914.           {0 b. Z( |! f* B- c$ z: G  p" u
  915.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈竒ЧΘ.....");. L6 N, P3 `8 k# x* T
  916.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新的资料已经完成.....");8 b+ v6 X( o: x" f
  917.             else                                                      dlg->m_ListText.AddString("updated file ok.....");
    ) J& }$ D, S& h/ j+ k( M( f) U
  918.             dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);3 n4 i. ], v: Y# T* x+ d' W2 o+ x
  919.             SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,0,0);
    6 X: \! y( E" [4 a2 ^# d8 ?. V# U
  920.             dwStartUpSteps=7;
    . F& D; \) C- x: R. K" F/ w
  921.             bFinishUpdated=TRUE;& u2 k. A; \6 x: d
  922.           }
    " R  V6 E, [8 y3 e
  923.         }' l8 |- [5 }! ?+ b% l; b
  924.         else
    4 ~% c6 H# g0 ~7 z/ _, ?- D
  925.         {8 @9 P; E# C( o
  926.           if(bRestartUpdater)
    ) }" L' B) d1 {% C' d, U' \
  927.           {' |4 P8 X5 Y7 i& K, q9 E' ~5 \
  928.                                                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);, F# d- K& `( a  X( \+ }
  929.                                                 else if( m_iLanguage == SIMPLIFY_CHINESE )                MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);: ~. i2 c/ g7 V4 v  a- l2 T
  930.                                                 else                                                      MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);
    / f$ G) M' _. K7 E/ L; h
  931.                                                 DestroyWindow(m_pMainWnd->GetSafeHwnd());' B* v4 m4 Y' `6 t
  932.             dwStartUpSteps=99;
    % \. p2 t& Q: l3 @6 m" q4 p7 S
  933.           }
    * \$ X2 f9 ]3 J) R
  934.         }
    " n8 S7 B8 G" x. t
  935.       }
    3 |& d, V: H* s# z
  936.       break;
    . N5 b. Y  [& j
  937.     case 7:
    / `( c9 d# I8 K! Z6 X
  938.       {  ~" O/ S( `$ |4 u" X8 {% d
  939.         char szExecuteFile[14]="Bf_Client.exe";& {" u: N2 s' \$ j+ d* t& p
  940.         if(GetFileAttributes("Run.exe")!=-1) strcpy(szExecuteFile,"Run.exe");
    * B. K1 W& w1 R" V+ n0 U
  941.         if(m_iLanguage==TRADITIONAL_CHINESE)   ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);. \5 f; G  p% n/ q, Q7 F) J- T
  942.         else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open",szExecuteFile,"updated2",NULL,SW_SHOW);6 B9 v( N; J. ]7 L5 T
  943.         else                                   ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);
    & z" w( u9 Y- \" g; P
  944.         DestroyWindow(m_pMainWnd->GetSafeHwnd());
    7 Q' S7 P  d# g3 r; W! `
  945.         dwStartUpSteps=99;) Z3 z5 H- m& N6 D: w, [
  946.       }* R; R. `; H" }( S7 f, f' O. _
  947.       break;" l7 L. I+ ~5 K. b8 y5 e
  948.                 //add by cece
    8 ?" {7 y' S# z  B3 j4 U
  949.                 case 8:
    ! {; L" y0 }& q, F1 b$ Q
  950.                         {0 @  ^' e" |0 e" L% e) C: k+ Y+ e5 X
  951.                                 if(!Dn.Connected())
    / ^2 u% R/ O0 R; r
  952.                                 {
    ! P" l( q% G% y" F7 u* J1 R! O7 K
  953.                                         dwTotalFiles=1;6 h' _3 _( x. u& e+ _4 l/ _) G
  954.                                         dwDownLoaded=0;( v) G, a' n7 @4 \
  955.                                         bSilentStep=TRUE;) s$ m3 K- F, z
  956.                                         bCompressed=TRUE;3 p& V% P0 b: e  Z/ a3 D
  957.                                         strExtLocal.Empty();
    $ [# |1 ~) t5 m" U' e
  958.                                         strFullName="download/CRCTable.txt";
    9 v: ]0 E' G9 L: v- r! g4 o3 C- T
  959.                                         dwProgramState=AP_CONNECT;, a& a: W  M1 k. J! W
  960.                                 }: ^6 ]7 E: E- N* y7 {) r1 r% m
  961.                                 //
    2 Z# w' E0 B) ~0 S" Y
  962.                                 dwStartUpSteps = 9;
    2 Y- f  l4 a  x5 J9 D
  963.                         }- `% J( Z" I9 n
  964.                         break;: p7 Y" C  v  H  b" |
  965.                 case 9:
    ; X: |; y( b# q& D/ @7 J! D
  966.                         {! M, y9 f  q3 [) A* z- S" K. ~; W
  967.                                 if(!Dn.Connected())
    . r" p- |2 E' p/ Q& O4 R# Z; X
  968.                                 {' ]9 `4 P7 g: ?' A, u! d
  969.                                         dwTotalFiles=1;
    ) B  Y& A2 U$ s5 u
  970.                                         dwDownLoaded=0;
    2 Y+ {( T) s7 t5 E# ~
  971.                                         bSilentStep=TRUE;1 l5 [! E$ n0 f1 |2 g7 ]  W
  972.                                         bCompressed=TRUE;
    ! V- m: v: n* l1 k+ m2 v6 L: }+ `
  973.                                         strExtLocal.Empty();
    1 @5 j5 O  B, |4 p9 x
  974.                                         strFullName="Run.exe";; ?+ ~, x: F- q- l
  975.                                         dwProgramState=AP_CONNECT;; [' u5 k4 Q, e$ X2 B4 {1 t& @
  976.                                 }
    5 B3 ?7 {8 V# b1 d2 f! U
  977.                                 //
    + u9 s; M3 @- \8 Q# Q' s& ^0 l* ~
  978.                                 dwStartUpSteps = 10;; l* |# Y/ a% @; z' S+ ?1 P
  979.                         }
    " Z6 K! q/ o: k) t: e' A* E$ T
  980.                         break;# `' @1 z$ {- w4 W2 N% Z# f5 T3 A
  981.                 case 10:
    6 k% Q. s! J4 z# [8 Q# P
  982.                         {8 b7 y* g4 x$ L( x* Z! c' K
  983.                                 if(m_iLanguage==TRADITIONAL_CHINESE)   ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);- p' [; R# Q0 K, _7 o2 Y+ W5 B
  984.         else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open","Run.exe","updated2",NULL,SW_SHOW);9 v4 U4 G& x$ G% e2 M7 j9 [$ \+ I
  985.         else                                   ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);
    % C. z& e1 [. _
  986.                                 DestroyWindow(m_pMainWnd->GetSafeHwnd());4 B- d" E( U" z$ [0 _, \
  987.                                 theApp.bClickRunExe = FALSE;
    ! y( [7 e% Q7 {" v& z
  988.         dwStartUpSteps = 99;
    $ V* t2 c; {7 ?. A) S' w0 T
  989.                                 //  k4 j( A6 r/ [3 n+ g. S
  990.                         }1 x, X  ~9 R$ H
  991.                         break;3 e8 o) b3 S8 d* m8 T  m; @: q
  992.                 //+ m5 W! g4 `- w+ a+ ^- X: f
  993.     }
    - A" [# n" b8 h
  994.     break;
    . O) E$ v9 K$ g% v# ^* e' y
  995.   case AP_CONNECT:
    , k" w. s# e2 \+ o# b( _+ {
  996.           if(Dn.InitNWSSock(4096,4096))- |0 c6 y, f9 Z% E$ W
  997.     {1 Z$ G  o7 n, ]! |. A
  998.       char szPathName[MAX_PATH];' _, i6 M9 O/ T: G8 c- ]
  999.       dwLastSize=0;
    ! V) b3 \( `3 X
  1000.       GetPathFromFullPath(szPathName,(char*)(LPCTSTR)strFullName);
    # b# O' Q; T! b  r1 C4 Z, ]( q7 K
  1001.       strFilePath=strExtLocal+szPathName;' A/ f  M) n  z, c$ K, m3 c
  1002.       strFileName=strFullName.Right(strFullName.GetLength()-strlen(szPathName));
    5 e+ f" I& x0 O/ G' G
  1003.       dwResumeNums=0;( T. a+ W+ ]/ ~! Z' @5 J
  1004.       CString strTempName;
    7 m0 H; x& n% K. G0 \
  1005.       if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);5 q' [$ Y" \" _' u) E: a
  1006.       CString strCountData;' q( o" f0 E- E. Y
  1007.       strCountData.Format("%d/%d",dwDownLoaded+1,dwTotalFiles);% F6 u2 s8 {" D, B
  1008.       dlg->m_FileNumber.SetWindowText(strCountData);
    ; H# s7 U$ W* Q# W7 u( l' ?
  1009.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));- A# b% Q6 U2 v/ \
  1010.       if(bCompressed)) Q' t) O5 P0 @9 e5 }$ H3 L4 |) ~
  1011.       {! w* K) I/ [4 S& A' i
  1012.         strTempName.Format("GET %s%s.zip HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);
    9 y4 h! w1 Y  V0 y
  1013.       }  h7 Q- p. n2 i# l/ F, @7 T7 w, e9 H
  1014.       else
    ( E( Y8 }- \; u% c: l
  1015.       {# W+ l( M* Y9 k  W
  1016.         strTempName.Format("GET %s%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);
    # E4 d6 r! v* ~) r3 R* M
  1017.       }
    , c: i1 e. ~' d* ]3 o( ^
  1018.                   Dn.Connect((char*)(LPCTSTR)strHostName,wPort);
    6 q+ k! }* z3 |: O' u
  1019.       Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());
    $ ?3 i! l6 [5 v! m4 D. s1 Q
  1020.       LastTickCount=GetTickCount();/ P8 }; n8 B" h, O4 k. h( j+ n
  1021.       dwProgramState=AP_SENDING;
    9 g5 ^: a/ [/ \$ }+ l/ s4 E
  1022.     }' t( ~3 D/ A: j
  1023.     else* z3 g3 ?. n2 W8 X7 M
  1024.     {
    1 f1 O4 {7 W, J
  1025.       Dn.QuitNWSSock();. }3 Z5 y4 I% V
  1026.       dwProgramState=AP_NOTHING;
    ( R+ Q8 K5 u& w6 I* {9 h$ P
  1027.     }
    ; f7 D: j: ?5 {0 E9 _4 w* j4 P
  1028.     break;6 W0 X* s3 R3 Y* K( e" O0 A
  1029.   case AP_RESUMED:8 D( s& u$ x" S/ e2 D& _  l6 [* b6 e# ]
  1030.           if(Dn.InitNWSSock(4096,4096))
    5 M5 ~- F9 S0 `! B* k( i
  1031.     {) f; n8 H  S  b7 M. q9 _
  1032.       dwResumeNums++;
    7 R; X( w/ x; b+ c. V7 [0 \
  1033.       CString strTempName;, e3 k+ h0 _. j* z5 i! A5 b4 l
  1034.       if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);  R' j2 u- K; j3 j' a
  1035.       CString strCountData;3 X: l0 f) ]% Z; G* q
  1036.       strCountData.Format("%d/%d",dwDownLoaded,dwTotalFiles);
    2 h: G+ A+ I4 r) n+ y
  1037.       dlg->m_FileNumber.SetWindowText(strCountData);3 s, s( _5 C9 m) Q
  1038.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));9 J( e9 v2 `2 K* W4 t! z
  1039.       if(bCompressed)
    * M5 s8 s; Z) D4 N3 B
  1040.       {
    2 @# K. W. S0 y2 M1 u0 q
  1041.         strTempName.Format("GET %s%s.zip HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName,dwCurrSize);) U1 V: i, i1 E5 C* o9 `
  1042.       }' \, @5 ?1 ?+ W+ O
  1043.       else
    9 ?$ m; @6 C; L1 \9 e$ d
  1044.       {' b4 i5 w/ [' h4 o& G% q/ u
  1045.         strTempName.Format("GET %s%s HTTP/1.1\r\nHost: %s\r\nRange: bytes=%d-\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName,dwCurrSize);
    + W: E8 H  i9 p8 M, t
  1046.       }
      y6 Y: v% m, j7 _9 V
  1047.                   Dn.Connect((char*)(LPCTSTR)strHostName,wPort);4 C6 }3 q! s8 a% x
  1048.       Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());3 w- F0 h$ s) d0 U* D. Q; H% F
  1049.       LastTickCount=GetTickCount();8 W. P# W4 F) q# A5 h/ S! U4 m
  1050.       dwProgramState=AP_SENDING;
    ; ]) g6 r2 ]9 i' h4 ^! [
  1051.     }
      ?% \$ P! ?; M+ o4 n
  1052.     else/ X  |! _9 h2 K
  1053.     {& f( H1 S: ?; U9 `
  1054.       Dn.QuitNWSSock();
    % ]' ^  G/ C. B/ ~& g3 f) v
  1055.       dwProgramState=AP_NOTHING;% L6 \, V; b. q- D
  1056.     }
    3 Z: v2 Y2 D/ U2 W
  1057.     break;
    4 K, j# D- H* q# i1 U5 O
  1058.   case AP_SENDING:
    " t1 u( c3 r) u' z  c/ n. \
  1059.     {
    . [  K) ^6 h* |) z
  1060.       DWORD RecvLen,SendLen;% Z6 n7 E7 _. d
  1061.       if(Dn.NetworkLoop(RecvLen,SendLen))
    / C1 @0 v8 @2 ?+ ~0 Q$ `  Z8 q0 m+ _
  1062.       {
    ) v# G! L& |4 M' }5 g
  1063.         LastTickCount=GetTickCount();
    ( [6 c8 O; {1 v" T
  1064.         if(SendLen)% V/ F, }: r+ Y
  1065.         {
    $ j% Y9 G. {* M  j; q* }+ ^' k! h$ X
  1066.           bReadHeaders=FALSE;" L9 ~& l4 w  e7 h
  1067.           dwProgramState=AP_RECEIVE;
    / z6 R2 p& X" x5 G+ \# b. t
  1068.         }
    ; Q: n1 g7 F3 S5 f- j3 w
  1069.       }8 o3 E7 Q. t' K
  1070.       else
    4 W& a$ P5 u  I, P/ d* `8 Y
  1071.       {
    & v$ `/ d: j) L( J- B( }* T
  1072.         if(GetTickCount()-LastTickCount>3000)
    & h2 s  y2 Y; w% I1 c' }& {" i
  1073.         {
    + o! A( _( C8 \/ w' [/ X5 e
  1074.           Dn.QuitNWSSock();9 Z: y0 k% r0 o1 B" S! |+ q; y
  1075.           dwProgramState=AP_CONNECT;
    & ]5 c' K  {  D
  1076.                                         //3 t+ d3 r7 i7 W. ~% K
  1077.                                         static DWORD s_dwCount = 0;- d: x/ E- F( z3 w* o( G+ W: A) s/ R
  1078.                                         s_dwCount++;
    : _. M% l1 ~+ e0 l1 F
  1079.                                         if( s_dwCount > 10 )2 Q4 R8 E. g7 w6 Z: D
  1080.                                         {5 D& ]. B' K# Q# H8 V% l6 z7 @) ~
  1081.                                                 if(m_iLanguage==TRADITIONAL_CHINESE)   MessageBox(GetActiveWindow(),"硈钡穝狝竟ア毖叫浪琩眤呼蹈砞竚   ","Error",MB_OK|MB_ICONERROR);! b* l/ l  S6 ?+ w
  1082.                                                 else if(m_iLanguage==SIMPLIFY_CHINESE) MessageBox(GetActiveWindow(),"连接更新伺服器失败,请检查您的网络设置   ","Error",MB_OK|MB_ICONERROR);$ y5 o- A3 ^+ y% |& t3 R
  1083.                                                 else                                   MessageBox(GetActiveWindow(),"Connected Error, Please Check Your Network Status   ","Error",MB_OK|MB_ICONERROR);6 Y- {" s: V  y, u7 X9 B8 W' T
  1084.                                                 DestroyWindow(m_pMainWnd->GetSafeHwnd());+ n: Y- v4 `9 d# O
  1085.                                         }; P0 ^9 U9 o' W% w6 f6 r5 W
  1086.         }
    . P6 I% C# p" E1 K" f
  1087.       }2 J! V7 v$ G, e  n4 D
  1088.     }, J& V+ z3 m  g$ L
  1089.     break;
    % _# U% q6 `3 C7 `  b" ~
  1090.   case AP_RECEIVE:
    / a* x" Y# H- l" `8 Q. T
  1091.     {
    - J& Z0 Y3 a: V0 l& Q9 R
  1092.       int Count;
    , Z! c: P# O3 x$ [# d. ]) {3 P
  1093.       DWORD RecvLen,SendLen;
    - M$ I& B; Y' t9 l: G1 a; \( i
  1094.       if(Dn.NetworkLoop(RecvLen,SendLen)). K/ |+ R% q/ Z( z% J% @/ w
  1095.       {+ s+ y2 |' c/ r, c
  1096.         LastTickCount=GetTickCount();6 I' c9 u9 b1 X! [
  1097.         if(RecvLen)- N9 V$ Y0 Q3 v2 g5 U* E- d# `( j
  1098.         {: J, A% f+ d0 i- H1 b/ q' M
  1099.           if(!bReadHeaders)+ k  \; b' n: N) r! S4 N1 l
  1100.           {" _* a3 H3 p& m; D" t% D: t" O
  1101.             char *token=strtok3(Dn.szRecvBuff,"\r\n");5 A/ y! `0 O* ]- R* y! ]
  1102.             if(token)3 R/ ]. h1 V8 c0 q# n! A+ |' T5 ~
  1103.             {; b8 s$ U6 T/ v: p* u1 K
  1104.               dwFileSize=0;$ x2 `0 b4 U( k: s  N1 d2 S5 s" b
  1105.               for(int i=0;i<(int)strlen(token)-3;i++), _5 v. L' }& [7 O
  1106.               {+ t  ?  b( |8 E) |
  1107.                 if(!strnicmp(&token[i],"206",3))$ X+ J7 ?1 h3 p. d
  1108.                 {
    9 f) w0 a2 q# C0 i- I; o
  1109.                   if(!bSilentStep)
    4 K; q9 |9 C4 u& [: t; c7 _; m
  1110.                   {
    ! j) K2 T) z% f  f5 m1 P( s
  1111.                     CString strTempName;) Y; H8 B4 a0 [$ _3 a- g
  1112.                     strTempName.Format("%s.....resuming(%d)",strFileName,dwResumeNums);' p; R* W9 S9 y5 M, `
  1113.                     if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
    ) m2 N: y/ C" y8 N" U
  1114.                     dlg->m_ListText.AddString(strTempName);" Y  H7 T1 c; w
  1115.                     dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);9 G$ t% R2 I# ?- Z
  1116.                   }
    % i. n8 o9 S( t  r' a* ]0 _& u
  1117.                   bReadHeaders=TRUE;2 a; Q9 g( M# s  d# P
  1118.                   while(token=strtok3(NULL,"\r\n"))
    1 Z+ i+ i; |9 L& c9 z( e- j
  1119.                   {; _+ \& {% S* v6 U& u2 b0 j
  1120.                     if(!strlen(token)&&dwFileSize)
    ( N! h; Q1 H5 b* A$ `3 q! ?
  1121.                     {
      Y$ y4 Y* ]* \3 V# ~+ `
  1122.                       Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;; g1 z, T( [3 z/ J1 _
  1123.                       if((int)Dn.dwRecvLeft>0)# \1 v8 x  T: b0 R. z1 L
  1124.                       {
    3 C/ A; g  L! b# Q# b5 R7 K
  1125.                         if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)% b' t  r, e6 I/ d; r  U' \
  1126.                         {! E; c2 l; Q4 c6 u
  1127.                           dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;9 i" K3 O  ?1 I/ N
  1128.                           Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);& w$ y+ T; D- ?1 z
  1129.                         }
    2 s* V! P6 j) w: c3 F
  1130.                         memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);
    2 ^" o1 g* I3 ^' R( q8 ^
  1131.                         dwCurrSize+=Dn.dwRecvLeft;
    ( c2 ~  v4 Z5 x- g
  1132.                         Dn.dwRecvLeft-=Dn.dwRecvLeft;
    : k, M+ `/ i* W; h0 Z( Q
  1133.                                                                                                 if(dwCurrSize>=dwFileSize) goto SaveFileJump;8 ]  Q. w5 }1 y2 U, A6 ?- S* o1 x
  1134.                       }0 t  R, k: _" b. J! W# \' O
  1135.                       break;2 ~7 d; v  U  H- ~7 ]
  1136.                     }
    ; e6 b  y: ~9 t8 K7 P/ L# G: F
  1137.                     else
    : Q/ t; `2 K& s  g/ L4 v
  1138.                     {
    9 G6 ?+ E) _, |3 w
  1139.                       if(!strnicmp(token,"Content-Length",14))
    & ?7 N9 z+ T! M- S9 V
  1140.                       {/ [* B1 |; N* \% M2 K$ E) r
  1141.                         if(!Dn.szCompBuff)
    : K! q. ~7 Z" j/ [8 O  P% f
  1142.                         {
    1 t/ }4 H' C. Z8 r
  1143.                           dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;
    % F6 |$ ?& w) y
  1144.                           Dn.szCompBuff=(LPSTR)malloc(dwFileSize);
    + {0 m9 M1 n- |) ?' u8 ~; m6 i
  1145.                         }$ |' Q" E2 h, b* _& i8 f
  1146.                         else if(dwFileSize!=dwLastSize)
    : h; v) ?5 c* q# I0 I! a" D4 I) j
  1147.                         {
    1 F0 A8 ?' L/ o9 z' J2 `1 n' f
  1148.                           dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;6 x: {( {7 s4 u1 ~
  1149.                           Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);4 G4 |8 `6 k( ]# t
  1150.                         }
    , G! W- ]% z. w
  1151.                       }
    & B  `1 \% u* t! c; i1 J6 Z+ d7 P, z
  1152.                     }
    $ O. `8 z1 I4 `# s5 M  S7 g8 S
  1153.                   }
    9 k) H2 F  a7 z0 G8 O. |
  1154.                   break;; K8 w) c. ~" c
  1155.                 }
    8 |, Q) @% K* T. e( `1 \
  1156.                 if(!strnicmp(&token[i],"200",3))% l6 ~# Y; S+ W9 q+ e7 [, Y( p) ?
  1157.                 {
    7 D1 u2 ?, ?; D+ S" ?& f" A
  1158.                   if(!bSilentStep)
    7 O! C; `) \6 n- Z: J& \1 C5 }6 C; F
  1159.                   {0 p% L$ s" C! r5 P) M  l5 P0 Q
  1160.                     dlg->m_ListText.AddString(strFileName+".....downloading");$ g0 ]. Y( Y! J- H
  1161.                     dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ }) `% `5 M, `6 K
  1162.                   }
    ' A- j8 t$ U" @6 j9 Q
  1163.                   dwCurrSize=0;& n7 A. J# [0 f% ^% o
  1164.                   bReadHeaders=TRUE;2 E& g) y" n4 y5 R! V
  1165.                   while(token=strtok3(NULL,"\r\n"))
    7 O$ k- r4 x# u. g
  1166.                   {
    # S9 |* P( \9 N. D/ U" y
  1167.                     if(!strlen(token)&&dwFileSize)
    . L/ Q! X  _4 u/ Q2 `
  1168.                     {& u7 J3 D5 Z4 S' P$ }
  1169.                       Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;
    9 k/ w! s" o1 J- s' F) M8 E
  1170.                       if((int)Dn.dwRecvLeft>0)
    / A/ q  m% m3 W$ b; U0 Z
  1171.                       {% Y' k7 C5 P* p( Y# M
  1172.                         if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)9 s/ E# z6 H) m( Y/ p  Y
  1173.                         {' x4 q6 G2 C" I/ b
  1174.                           dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;
    " M) D$ R9 G; i; x" c! s
  1175.                           Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);/ A; v! b  K6 {/ \4 S' O/ y
  1176.                         }2 Z* E! i. x' E, b
  1177.                         memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);
    + R0 {0 S' b7 G8 I: K! O
  1178.                         dwCurrSize+=Dn.dwRecvLeft;3 u0 [9 \6 V5 P
  1179.                         Dn.dwRecvLeft-=Dn.dwRecvLeft;9 I; P* x& ~- n1 |2 P. g
  1180.                                                                                                 if(dwCurrSize>=dwFileSize) goto SaveFileJump;6 }" U, {; l) D
  1181.                       }- x2 u! U0 P1 @& l4 w9 H
  1182.                       break;
    ! w( B- a5 F0 o( d  h; q9 c
  1183.                     }& [# `* i- n4 U
  1184.                     else
    8 V) Q5 N9 u  c- ~2 X
  1185.                     {
    ' y% F' m) b1 ^0 l) F
  1186.                       if(!strnicmp(token,"Content-Length",14))
    + }( D( d3 T8 i) z
  1187.                       {: N* Q) I5 B( y4 k' F7 |! D* y0 ]
  1188.                         if(Dn.szCompBuff) { free(Dn.szCompBuff); Dn.szCompBuff=NULL; }* K" L  Q; w/ [& Y) U. b
  1189.                         dwLastSize=dwFileSize=atoi(&token[16]);1 j5 C2 z1 P; U8 g- Z
  1190.                         Dn.szCompBuff=(LPSTR)malloc(dwFileSize);0 D$ z/ Z/ D4 {) v
  1191.                       }: M; ]0 u) j2 X2 t, G  e3 }' }' j
  1192.                     }0 S9 A0 e7 \8 L* ?+ f* ]! R1 W: J
  1193.                   }
    ) b# o5 W. ~; v
  1194.                   break;6 T( _( i' [6 X# p+ ?8 E
  1195.                 }6 w9 U* P2 p8 q9 k: [
  1196.               }; \$ k' u! Z) [: L$ u1 L# ], u- b
  1197.               if(!bReadHeaders||!dwFileSize)
    ' i' O  I5 w7 `5 a- G" ^6 j& e
  1198.               {' ~- n& t/ E; l1 j0 C( A% E
  1199.                 // Wrong Header or Reading File Size Error) f( t  z7 a( B$ ~0 H
  1200.                 Dn.QuitNWSSock();% P' z8 u6 v/ Q8 \2 S
  1201.                 dwProgramState=AP_NOTHING;
    2 J( m* E3 m$ J
  1202.                 CString strTempName;
    ( D' N* ^2 I& N: c! U# y
  1203.                 strTempName.Format("Navigate %s File Error !",strFullName);
    0 C' H: \" J& P7 W
  1204.                 MessageBox(GetActiveWindow(),strTempName,"Error",MB_OK|MB_ICONERROR);) D, F6 l. S" h# G7 O
  1205.                 bRestartUpdater=TRUE;, r' }" z; T2 d) x9 S
  1206.               }- f, J# ~4 R& m
  1207.             }  e7 [- f7 L' u7 ~  s/ b6 z
  1208.             else; _; D7 y5 |) ?. s+ l+ b
  1209.             {
    ; s% n' q: y) I2 I
  1210.               // Have No Header2 C8 U( a4 }5 q
  1211.               Dn.QuitNWSSock();
    1 A( U! [4 {$ l9 w2 i
  1212.               dwProgramState=AP_CONNECT;
    ( n4 B0 S0 H0 I4 S: v( `+ T( q
  1213.             }& M$ e) r! S, q: W
  1214.           }
    6 f" L9 g% D1 b' O" k
  1215.           else, X% L( r6 ?) d( c* ~
  1216.           {
    ' H; f& G0 Y$ d; M8 c& M' Y
  1217.             // Reading File From Web$ e4 Y4 _( B+ `0 f+ o
  1218.             if((int)Dn.dwRecvLeft>0)
    + |% b2 h: b6 C. {! y, @
  1219.             {1 ~* h% f. k6 n- c1 b1 e& d
  1220.               if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)
    1 P0 N( h3 d" j; P- Q  n
  1221.               {' L' h+ O; p9 c6 ^
  1222.                 dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;# L+ ?9 R( t' p7 T) L! [) G6 S" L
  1223.                 Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);5 p, @& F6 ~0 V3 V
  1224.               }
    6 [8 F' c5 i+ e2 y
  1225.               memcpy(Dn.szCompBuff+dwCurrSize,Dn.szRecvBuff,Dn.dwRecvLeft);
      a- [8 S! n* r$ v
  1226.               dwCurrSize+=RecvLen;
    ! b. x; E9 d# q9 H( H
  1227.               Dn.dwRecvLeft-=RecvLen;
    ) N; ^/ P+ k# z0 c7 N( t
  1228.             }
      w* i* M* O. q. X4 o
  1229.                                                 dlg->m_Process2.SetPos(100*dwCurrSize/(dwFileSize<=0?1:dwFileSize));6 S( w5 V6 C$ l3 r, B: d2 P# ?0 S
  1230. //            int iRate = 100*dwCurrSize/(dwFileSize<=0?1:dwFileSize);) t! H* I1 N$ u6 s2 S4 O  Y% ^) w
  1231. //            dlg->m_Process2.SetPos(iRate);& G' @) W. R0 M, m) y- z2 D0 ~
  1232. //            if(iRate < 0)   iRate = 0;* ~4 e5 }) B! z0 t4 v4 z* I
  1233. //            if(iRate > 100) iRate = 100;
    ) v4 e) ?5 h3 B: _
  1234. //            char szShow[5];/ |( s+ x) v4 S/ s7 r1 b( W
  1235. //            sprintf(szShow,"%d%%",iRate);  X7 W5 R* N& y7 z8 J; {& n1 q
  1236. //            dlg->m_SingleRate.SetWindowText(szShow);6 ^: a3 S) Z* d
  1237.                                                 if(dwCurrSize>=dwFileSize) goto SaveFileJump;. l/ b' ~* l4 h9 c$ Y3 g8 D
  1238.           }
    6 U9 g* W! C' N3 E$ l" V8 J/ s
  1239.         }
    : K4 J8 X$ [2 h) r! P$ c
  1240.         else if(dwCurrSize<dwFileSize)
    * T0 n+ a5 l* m- D3 K0 U4 W; K6 E
  1241.         {
    + J7 P* ]1 [7 D# m- t% E& b# n( ~
  1242.           // Disconnection But Size Error( }( c6 @2 W+ G) D
  1243.           Dn.QuitNWSSock();. u( N* s% c- W( D3 n5 x5 u  L* ^
  1244.           if(dwCurrSize) dwProgramState=AP_RESUMED;* B2 E6 M* I  q% B1 {/ }" F8 W
  1245.           else           dwProgramState=AP_CONNECT;/ ]8 O  e5 b9 b. S2 T! y
  1246.         }
    * C& E. a$ `) W0 y! V
  1247.         else
    ( j& m0 f% f8 T! Q% c6 c, K9 g; W
  1248.         {" @9 b7 r5 \# E( D
  1249. SaveFileJump:; v* G/ B9 I- Z+ Y# s
  1250.           // End of File and Disconnect* h' M- R4 p) K- p3 {
  1251.           FILE *Fp;4 c. C5 I+ E7 J, O0 b5 x
  1252.           char szTempName[MAX_PATH];
    8 y1 A8 Q  y! T2 a4 J
  1253.           strcpy(szTempName,".\\DownLoad\");
    5 w; r3 K/ J7 \  ^7 V" }6 p
  1254.           strcat(szTempName,(char*)(LPCTSTR)strFileName);
    ( H* Q, _+ N2 j/ x2 W: k
  1255.           if(bCompressed) strcat(szTempName,".zip");7 K1 V* s/ o0 ?
  1256.           if(dwCurrSize)6 @8 |0 e# [7 G- \
  1257.           {; `# q/ T- a7 m; K& Z* \' X' k
  1258.                   Fp=fopen(szTempName,"wb");" E  n+ g* s) E: S9 r, j
  1259.             if(!Fp): i; c: X* o9 e6 _
  1260.             {
    : R% r" V0 S" p' i7 C
  1261.               _mkdir("DownLoad");
    * s6 n; E( _  m1 R6 Z* D% i
  1262.               Fp=fopen(szTempName,"wb");' E) K% u4 l! j. Q! {
  1263.             }
    6 J: k( f5 e3 f' {2 W
  1264.             if(Fp)/ e* ^5 ^6 Y8 Y& ]
  1265.             {
    $ W0 }5 p  j6 M
  1266.               fwrite(Dn.szCompBuff,1,dwCurrSize,Fp);( Z/ A- n6 [( U( V
  1267.               fclose(Fp);
    ) G6 Y% i+ i3 ~6 G) j( m) b
  1268.             }
      g8 X0 l8 q" p3 j4 O. @, Q) l
  1269.           }, W9 E: K( X7 N' y0 P7 s1 v
  1270.           if(!bSilentStep), V: W: W6 ~+ \& B
  1271.           {7 v) b% e5 `$ Z3 R1 }7 n! c  e& Y
  1272.             if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);# _7 }( _( Q4 ^9 ?/ t
  1273.             dlg->m_ListText.AddString(strFileName+".....saving");
      Y6 K: @4 L* |5 _' C5 W3 ~1 j! `
  1274.             dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);0 I  H9 @' ~+ j0 H% E
  1275.           }) ]' C, c+ n" k4 D
  1276.           if(bCompressed)$ V( a1 l+ ^+ Q
  1277.           {
    ; B4 r$ ~( a& _, q  `* ?: Q! F9 ~
  1278.                    int opt_overwrite=1;
    / z8 H( r! B3 ]/ c8 ~8 b
  1279.             int opt_do_extract_withoutpath=0;
    , M' l% h9 X* l& Z0 p+ r
  1280.                    unzFile uf=NULL;% B- m- `2 y6 V" Q* Q, x0 h
  1281.                          uf=unzOpen(szTempName);. m8 ?" O$ ~0 f+ Z* X1 o, ^, P/ M6 ^6 T
  1282.             if(uf)
    + z* `# p% V+ C# [2 H4 ~  b8 Y9 g
  1283.             {
    8 @' [+ a, d* x+ C
  1284.               if(!bSilentStep)1 \4 |! A( _* ^# J+ Y# A( w
  1285.               {. E+ Z9 p, p* c/ y
  1286.                 if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
    , {/ w8 Y* _% c
  1287.                 dlg->m_ListText.AddString(strFileName+".....extracting");
    $ J3 J- s! D- _2 @  M* m7 T  X
  1288.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ) U' z6 J1 E- S" |) `; K" f$ g
  1289.               }
    , F) l+ D) O$ {6 o7 v/ C
  1290.               if(do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,(char*)(LPCTSTR)strFilePath,NULL)==UNZ_OK); o: Y7 T/ V1 t9 l0 I0 j- R
  1291.               {
    # e* A% L8 p5 l3 `
  1292.                 if(!bSilentStep)
    . g+ y- b' n! {) K. E9 Q
  1293.                 {
    7 R6 D9 Y. u; x: L* Y" a' H9 p
  1294.                   if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);3 g* m& \' ~5 K. b4 F2 U& S9 V- o0 t
  1295.                   dlg->m_ListText.AddString(strFileName+".....done");: B- L2 U( k: M, Z
  1296.                   dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    + \/ U0 ]' U; z4 H: W% M- q  J. Q$ N
  1297.                 }0 o% c5 t. K0 W( {
  1298.                 dwDownLoaded++;
    ' {# Z& k0 G7 r& E
  1299.                 dwProgramState=AP_NOTHING;1 X: b) H6 o, }2 r4 n0 c  P
  1300.               }
    * a! X8 _3 H2 d6 t
  1301.               else
    8 w' t5 j2 ]0 Z& I3 F! U
  1302.               {
    ; e- U* p3 z2 U" @0 }& R, U$ y
  1303.                 dwProgramState=AP_CONNECT;
    ! K9 \' K2 P) R6 V4 J
  1304.               }
    4 t' J! \1 A# v3 A, M1 x$ j0 {
  1305.                     unzClose(uf);
    ! V& v/ {9 I% r! Y
  1306.             }
    2 x) F. j0 `! e! J
  1307.             else
    . ]; m$ B# V5 U# k! h8 l
  1308.             {+ L% m; e7 d0 h/ @7 K% B! i  z2 T( T6 S
  1309.               dwProgramState=AP_CONNECT;
    1 Q( ]. J- o8 x% L- X) I
  1310.             }. c, f- N4 N, ], \7 H8 Q' \
  1311.             unlink(szTempName);
    . f' B5 u- u6 {2 w/ J; S
  1312.           }
    3 t, s) Y) E, ?3 j7 m% m+ u
  1313.           else
    4 V, |, b8 j' e. w  |* j
  1314.           {1 Q  j( d1 n) D, _& f" k+ W
  1315.             if(!bSilentStep)
    + b6 }7 ^. c  d+ b- V" i- s
  1316.             {
    % e/ I! g2 [' |8 q2 ^! }6 k& r1 E
  1317.               if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);+ s9 Z9 f5 S$ }
  1318.               dlg->m_ListText.AddString(strFileName+".....done");6 q! `' h( N. L6 Y. B2 r  v1 \
  1319.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);0 ^) A, g# |9 m9 v$ Y( V
  1320.             }" f, u( b8 }/ r  t; w9 X; r; p: Q
  1321.             dwDownLoaded++;
    , ~( c% T: q3 @5 h  u3 b2 V4 F
  1322.             dwProgramState=AP_NOTHING;$ }5 \- ~8 v& M5 T) l
  1323.           }
    8 J+ ~( p* ^, E1 v
  1324.           Dn.QuitNWSSock();
      k( t% }% Q9 v( b, u# p
  1325.         }
    ; A( I8 ~: c- N6 n& ]3 o0 o
  1326.       }1 D7 F$ u) Z5 B
  1327.       else  q' e" c- R( w0 T
  1328.       {
    7 d1 i# q" l( Q. V+ ^
  1329.         // Connect Timeout& d8 V* u5 M1 @4 n9 |
  1330.         if(GetTickCount()-LastTickCount>30000)0 `& |1 _$ L1 U8 G5 |! S8 E! |4 s
  1331.         {# N7 f; V& j7 c) t# B+ M. O
  1332.           Dn.QuitNWSSock();. j+ ~' K! ~- D, \8 i" y+ G( G
  1333.           if(dwCurrSize) dwProgramState=AP_RESUMED;/ _! c. T7 o4 I" y! X* {& f5 ^
  1334.           else           dwProgramState=AP_CONNECT;/ W* c8 }9 @: m) F! r! P+ Z& M
  1335.         }
      }! R& h/ w; E  L
  1336.       }
    2 A' I/ V2 G2 j; F: u, o5 |
  1337.     }5 A# z: t$ k* {$ ~
  1338.     break;: E0 B0 f. n+ f4 t( Y! ]2 \  c. D
  1339.   }
    # C# z' S$ _; v, h
  1340.         return CWinApp::OnIdle(lCount);* b4 K9 Q2 X& k5 T2 X) \
  1341. }, V$ f2 S/ s6 N8 i8 w/ O
複製代碼
其实登陆器也就是这么一回事儿……, q9 O3 I/ ]  H- Y: f, Z) @
附件有编译教程和源码! f) f. W/ t9 c
遊客,如果您要查看本帖隱藏內容請回覆
( B% Z) \# u' r$ a, X2 p! A& e' P* X
! U6 I7 A& R( J2 g8 Q& o+ M

評分

參與人數 1金币 +500 收起 理由
cheng2002 + 500 很给力!谢谢分享!!

查看全部評分

wuzhenpan 發表於 2019-10-24 09:31:51 | 顯示全部樓層
1111111111111111111111111111111111111111111111111111111
回覆

使用道具 舉報

15820046275 發表於 2019-4-18 21:00:55 | 顯示全部樓層
555555555555555555555555555555
回覆

使用道具 舉報

15820046275 發表於 2019-4-18 21:00:50 | 顯示全部樓層
555555555555555555555555555555
回覆

使用道具 舉報

yun5520245 發表於 2018-1-29 21:25:42 來自手機 | 顯示全部樓層
东西不错,只是现在研究的人少了。
回覆

使用道具 舉報

寂寞在_NBC3C 發表於 2018-1-30 18:08:32 | 顯示全部樓層
东西不错,只是现在研究的人少了。
回覆

使用道具 舉報

qutebaby6309 發表於 2018-1-31 08:29:25 | 顯示全部樓層
來看看囉 謝謝大大的分享 ~
回覆

使用道具 舉報

advsolarpower 發表於 2018-3-17 13:42:22 | 顯示全部樓層
热爱他肺癌热锅额度都是感受到
回覆

使用道具 舉報

提莫 發表於 2018-3-23 17:17:22 | 顯示全部樓層
顶顶顶顶顶顶顶顶顶顶顶顶顶顶
回覆

使用道具 舉報

提莫_k6Zum 發表於 2018-3-29 13:30:35 | 顯示全部樓層
dddddddddddd
回覆

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:admin@discuz.vip

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版發帖QQ客服返回頂部