CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閲讀模式
8 b7 B5 i& M, X# ^
  1. / RevApp.cpp : Defines the class behaviors for the application.; h) c* c; C3 U+ O
  2. //% r" {3 f$ x7 D4 y

  3. ; K  F) \; H, T0 p0 p
  4. #include "stdafx.h"6 V4 e" g- P* D) n6 f6 E6 q

  5. & J; {! Q3 D: C5 a# u' n& m
  6. //#define UNICODE
    8 O. w8 \9 D' k7 L/ X6 b/ o' c& i
  7. //#include <gdiplus.h>. C/ L6 o" }% p& S6 M) q& S
  8. //using namespace Gdiplus;+ a, D5 K* J- N2 t) p

  9. 5 J+ _' A4 u6 P
  10. #include "RevApp.h"
      }+ u- n. N7 B* J) K3 M
  11. #include "RevAppDlg.h"
    9 R% ~: _" _3 ^$ U# W  l
  12. $ r2 D! Q5 b$ f9 Q
  13. #pragma warning(disable:4786)' R/ P4 S8 e$ A8 |2 |/ R$ e+ q$ z8 T
  14. #include <map>$ m, v( N) D0 U. L' \; e
  15. #include <list>
    8 G3 z. }3 ]6 ~
  16. #include <direct.h>) K. A1 b, U: j: A, p  P
  17. 5 @% u: O' Z7 p6 e* ~7 v9 a
  18. #ifdef _DEBUG
    - \$ ?4 O$ P0 i3 N
  19. #define new DEBUG_NEW3 r' n6 Q- f1 q7 K6 E
  20. #undef THIS_FILE
    ' M5 r5 \8 M, a* J+ f
  21. static char THIS_FILE[] = __FILE__;, g9 [. h7 l3 |% T
  22. #endif
    , I$ i# s- T& C+ X) d
  23. #include "SkinResDef.h"
    ( @( k; C+ y7 ^" M
  24. #include "ChangeBG.h"
    - f5 J' A$ M% M8 i9 F, m7 w6 B5 ~) A
  25. #include "AFXINET.H"4 ~( C& y" y2 Y) `( F9 s
  26. - H, Y( }# \. D3 e* Q/ \, i9 I9 w+ d
  27. #define TRADITIONAL_CHINESE 0
    1 j( \2 }# l& d9 q& S, c0 u7 ?0 i: _
  28. #define SIMPLIFY_CHINESE 1
    * B9 t- C" n# h7 i
  29. #define ENGLISH 2
    " L" J; R) b; G
  30. int m_iLanguage = ENGLISH;
    9 N  A0 I% u6 G$ ^2 ]" u, I
  31. /////////////////////////////////////////////////////////////////////////////
    3 _5 y& {* V. ]: k
  32. // CRevAppApp% u& D/ k. k+ H6 G* z

  33. 6 P, o, G$ J! W8 o  W
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    # V: B, z' Z: \5 ^* E: I
  35.         //{{AFX_MSG_MAP(CRevAppApp)
    ) Q7 s" q$ t0 F6 W: D9 a% V4 b
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.
    0 F% Z5 b' }, b
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!
    / ], P5 @% ]. E% z! b" @6 m; u
  38.         //}}AFX_MSG5 M7 f: o9 Z/ j2 j$ f, Y6 z
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)
    3 R+ g4 Y4 ?4 X4 w8 f
  40. END_MESSAGE_MAP()
    # a' j: G$ j; m
  41. # P+ T) m6 f3 ~! w% X6 m
  42. /////////////////////////////////////////////////////////////////////////////
    ) A/ V, e+ C, P  S
  43. // CRevAppApp construction
    ' Y5 D1 I6 c6 B2 s& N
  44. ( m8 M8 ?4 A" [, x0 w( G- G' z
  45. CRevAppApp::CRevAppApp()
    # v  L) }( Y: @) W
  46. {
    / p* C" q& v6 b6 E. ?% H% {! Z
  47.         // TODO: add construction code here,
    ; O% H; Z7 x9 W3 ~' \! z* b
  48.         // Place all significant initialization in InitInstance
    # ~0 ^3 O6 b6 y; V# h7 @
  49.   bDisplayIsBig5=FALSE;
    1 @/ }6 g) `5 u3 @4 p" }7 k
  50.   bRestartUpdater=FALSE;
    # H4 c7 z& h& h1 J
  51.   bFinishUpdated=FALSE;
    ! x& c5 i3 W1 K/ C4 [! j
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;5 _, H5 s* Z. k
  53.   InitChangeDataBig52GBKS();
    / a0 x1 a5 K  J" o' }# T. |
  54.   InitChangeDataGBKS2Big5();0 X( w5 X' B% c# B) P7 Q
  55.         //
    % e& Z: [- G- R& L8 k5 h# S  o
  56.         bClickRunExe = FALSE;2 J* I  V9 @- y$ k: Q6 z& e
  57.         //- k  I/ H" I& S4 E# c# M8 m6 g
  58. }
    * b' Y3 b6 E' ]# c1 r" n  V

  59. # A: i, F7 H" H9 n. h
  60. CRevAppApp::~CRevAppApp()
    * ~  Z* [6 t9 _) }
  61. {
    3 ]5 H& E: u1 O. X# w; r! K
  62.         // TODO: add construction code here,
      l0 ?( ?5 W7 Z1 Q) h2 |
  63.         // Place all significant initialization in InitInstance
    / `6 b( @1 Z6 n- k7 l# U% X
  64.   EndChangeData();  t7 l% c/ L( K2 L8 Z. p( b8 `
  65. }+ U7 n  r% u# S" J. d2 g
  66. " l; }+ P) m  n* Z- D$ r# v
  67. /////////////////////////////////////////////////////////////////////////////
    ; d/ b6 A* d5 ]3 n7 V+ C, {
  68. // The one and only CRevAppApp object& o' N. C0 J* M* V
  69. 0 e: `* a3 X/ r* D6 H% h- c! T2 z
  70. CRevAppApp theApp;8 t* C2 w, _" s. [! B

  71. 8 ]4 a/ t/ m4 o
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)
    , K$ t0 b- R2 r" g' \# [$ K% a# `9 ]
  73. {
    0 ]5 U$ l. Z+ V3 m/ `& u0 e% _/ v2 D
  74.   int iEOF=0;
    , k. X+ O  G+ r9 _5 ]' L
  75.   char szTempName[MAX_PATH];
    / B$ l9 p3 r1 K; r4 }+ E( u# L3 e' z
  76.   *szFileName=0;
    % G& I6 B5 S5 y* s
  77.   iEOF=fscanf(fp,"%s",szTempName);6 f! r; l0 S  I4 V
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')- D4 j+ V9 R% d! |. y
  79.   {
    % }, v7 {9 p& k8 q
  80.     strcpy(szFileName,&szTempName[1]);
    6 v# G5 J6 p' b4 R9 k8 S
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    5 f: g% p# U( O0 K
  82.     {% b, h5 Y8 g7 Q- r1 `7 m
  83.       iEOF=fscanf(fp,"%s",szTempName);
    0 L. p4 f3 U+ ^+ m4 ^
  84.       strcat(szFileName," ");& N: |2 A* q/ s2 K0 F! h, L5 v
  85.       strcat(szFileName,szTempName);  G, W- k& @2 t* A$ h/ v  l
  86.     }  X& c/ X7 t7 G+ ~
  87.     if(strlen(szFileName)>=1)
    " q* j. W0 j' F& N) F# w/ O( s( ^
  88.     {
    & i- h3 t% ]  Y
  89.       szFileName[strlen(szFileName)-1]=0;4 |( U0 I( n* P9 Z$ d6 @0 O- d/ c
  90.     }  ~- p) Q# _  Y. F
  91.   }
    ) ~; s* }6 R# ~4 j  ~; s5 e
  92.   return szFileName;
    ' n2 F6 W7 Q; {6 P
  93. }4 `; S, q5 ~$ [$ e- G- @

  94. 7 \! d2 i& J7 {3 a
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile). w& k/ [5 W" z6 y( t
  96. {. B- M( i- {8 l. K6 W4 t
  97.   FILE *fp;: G6 _. g* {+ ?: ]9 r
  98.   char *key=NULL;( Z# f6 ]7 _: r- S
  99.   char version[MAX_PATH];
    & a4 t6 [. @$ m2 c8 A1 K
  100.   LPUPDATEFILE file,olds;
    " ~6 X& I( J/ B$ D! P% f# g7 B
  101.   std::map<CString,LPUPDATEFILE>::iterator p;: e3 Q, K9 `5 R
  102. 6 @2 B) D2 D- L
  103.   UpdateList.clear();2 d$ T7 d) {4 ~6 `& [- V
  104.   UpdateFile.clear();7 C$ n0 E3 y2 l; {5 G5 E
  105.   if(GetFileAttributes(filename)==-1) return false;
    , g- N4 p% }5 R9 ?
  106.   if(!(fp=fopen(filename,"r"))) return false;- ~/ o/ Y* x" j* R7 n
  107.   fscanf(fp,"%s",version);
    $ |4 b9 t* {) _* X3 m! B; n' b5 g
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }" W# g8 ^. S# Z. C1 [" V6 W  m
  109.   while(fscanf(fp,"%s",version)!=EOF), n) ]( v3 ]" Q3 y; V6 {, d: {
  110.   {/ Q- b) G. g, C5 M: {  W
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    : `2 h$ k3 Z9 g! x! E
  112.     fscanf(fp,"%s",file->path);" c' f; G  r, t" B9 g
  113.     ReadFileNames(fp,file->file);& o# H6 N( `+ y5 f
  114.     strcpy(file->full,".");' G6 h* ~! p. A6 F, x$ }
  115.     strcat(file->full,file->path);
    5 g/ R& I( O, t, ^1 {* J
  116.     strcat(file->full,file->file);
    " o7 E! ]# G$ x/ \: F% d: S8 m( e: N
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())* ]. Z4 t- M! q0 `) T
  118.     {  O4 E, l% ]5 ?4 z6 d
  119.       file->vers=(float)atof(version);
    , N  o( X$ @# x3 P
  120.       UpdateList.push_back(file->full);
    8 |2 c. z6 T- S, v* `6 t
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));- x# R& [) f$ ~  A; w$ Z0 U# Q* J
  122.     }" @* c. G6 w6 M& U8 I- R# o- v
  123.     else# O, @! g& I! N$ K
  124.     {
    : D) p; i2 P% ~7 |% d
  125.       olds=(*p).second;& x; Y7 [, o6 j0 l2 _
  126.       if(olds->vers<(float)atof(version))$ G  I' Y. |* Y! z: r
  127.       {
    - Y( [6 I. J% M
  128.         olds->vers=(float)atof(version);
    . ~: W/ }4 d1 t/ Y/ a  {
  129.       }
    ( B# K% o" u# O/ E* n- J( U6 i
  130.       free(file);( x) X" ^4 o; U# i# f% Z/ l+ C: |
  131.     }0 Q# M# m1 }. P0 M
  132.   }4 c. @: E# O! E* Y5 Z
  133.   fclose(fp);
    ' S; W$ W# J# V! x( h( S5 j( W# G
  134.   return true;
    / j3 I$ n  c# ?* M9 w* w
  135. }% h: l. g8 K( P9 g( v6 z

  136. 6 {4 O/ m- A4 {* ~
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)/ F3 C% t* {; x/ d3 Q) S" h- \$ h
  138. {) n: T  t0 |: D) R* n
  139.   TCHAR  szFull[MAX_PATH];4 A/ G) ?+ |6 ?0 B% Z
  140.   TCHAR *token,*inter;
    ( d+ s4 O! O0 T0 U4 g
  141.   *szPath=0;
    : I' b' `+ p9 I* M! _( }3 s! ?
  142.   strcpy(szFull,szFullPath);4 A" ?, c/ Y( \0 t! h# [; ^* F9 @
  143.   token=strtok(szFull,"\\/");2 A. L3 S! _3 @0 W- o/ E
  144.   inter=token;& |0 r# @1 n$ z4 K4 l  ]
  145.   while(token=strtok(NULL,"\\/"))4 C" X, \! M6 M) o/ t6 ~, U9 ?% e
  146.   {& f$ f+ P. M3 I' d2 L; d) `* b
  147.     strcat(szPath,inter);% `" f. j! b1 N9 [# I
  148.     strcat(szPath,"\");' o$ S. K; k, n4 ]( D
  149.     inter=token;
    : Z  t# v9 X. O# I+ O: t
  150.   }! N" a( ]  L( [' }
  151.   return strlen(szPath);! {9 _( L/ U- Y
  152. }
    0 T" i- I$ k/ Y- |! k0 ~
  153. + s  I3 X) q; v) F9 I2 _4 D8 N  m
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)
    ' X3 d; I% C  B/ P9 L$ j" {
  155. {
    ' t. R1 K9 O. I) o) [9 U
  156.   DWORD attrib=GetFileAttributes(Target);0 @1 ^0 o) B8 C3 B$ U
  157.   if(attrib!=-1); _* [0 a% E( D- n
  158.   {5 B, d& i- C$ y6 e8 w5 W
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))$ u& o' e! f, Z9 M$ [& e0 z9 J
  160.     {
    9 `4 `, E6 R7 O7 Y
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);
    ; G  K; T' i3 W2 I8 {
  162.       SetFileAttributes(Target,attrib);
    5 a4 p; ~4 W( q) z) {% v3 E
  163.     }
    9 \* Q/ B; i: Q3 P$ v8 w1 j% H
  164.   }. {3 U# }. J6 p+ Z- c
  165.   CopyFile(Source,Target,Erase);
    , m, M4 {# G& U& f# n2 Y
  166. }
    : `' P8 j0 a% `! w+ B. D

  167. * }5 n; P: A5 }5 F% [1 n
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)# n, R  L( W) W- E
  169. {
    ) c% z! u; c( j! n# i; f& w
  170.      FILE *fp;
    / g& B; X/ v$ B7 k
  171.      char  szBuffer[8192];
    , O$ ~4 W& |3 u5 P# T% d8 A' ]* @
  172.   va_list  argptr;4 R' Q0 x1 a: a6 D7 Z

  173. 3 A1 y: _. Y' ?3 J1 O$ P
  174.         va_start(argptr,message);, `, c1 P; C0 b. C0 e
  175.         vsprintf(szBuffer,message,argptr);& g, ?- z, i0 @
  176.         va_end(argptr);
    7 x5 o! A  R/ p  r9 G
  177.   fp=fopen(FileName,"a");
    3 q- W# E( m. \9 r' U' O6 z' L
  178.   if(fp)
    7 v! b) f$ ]# q2 k* t
  179.   {0 s  l. y/ o3 m& `4 l! x
  180.     fprintf(fp,szBuffer);3 I8 Q; M9 R0 [/ e8 n. e- p
  181.     fclose(fp);- s7 S( m& [  y
  182.           _flushall();; F9 n5 S: m: ?- ~
  183.   }; E7 ]% K: p' C
  184. }
    , v& M: x$ y% O
  185. 2 d: A) @: I2 O) ~( e' P6 W1 ^# W
  186. BOOL CRevAppApp::Fclearf(char *FileName)0 v. m6 T6 c$ N; \! D) n, f
  187. {
    4 X5 x+ ^4 ^( o# f/ d
  188.      FILE *fp;8 a. E' j: l6 ~/ e* q
  189.     DWORD  attrib;
    0 A! R( }# R8 z9 E# \
  190.   attrib=GetFileAttributes(FileName);6 h8 T/ `- I9 W+ j- H: \2 J
  191.   if(attrib!=-1): ?9 T- i, C. A: Y/ v
  192.   {0 W, ^6 G, t6 x* Z/ y1 j
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
    $ t' \0 y. \' d; B! Q
  194.     if(!SetFileAttributes(FileName,attrib))
    2 L% p8 m) d( }* M
  195.     {
    , j& }! D$ I, \5 m+ I/ }0 X) d6 b
  196.       return FALSE;
    % p# Q4 B+ W9 M2 L! |8 D5 x
  197.     }
    : _: I3 R8 l' N4 U) @/ R$ }
  198.   }! `) r' P9 e( ^- R
  199.   fp=fopen(FileName,"wb");# x) Z5 v7 D. O+ E) t, B
  200.   if(fp)
    , Q/ t( r/ r6 r: C- g4 @& D
  201.   {3 d9 ~, {# y( b$ y* Z+ x
  202.     fclose(fp);
    6 k5 c9 Y  I% u+ z  H5 m
  203.   }- U/ F7 q! t/ v, j$ r6 G
  204.   return TRUE;7 t# M+ `6 b; ?- a1 y
  205. }) J, l6 U% [2 O
  206. + i# s3 z% d7 P$ K$ h
  207. BOOL CRevAppApp::UpdateLocalVersion(void); Q: r# i+ @' h2 n0 S
  208. {7 o! i3 M* e$ i3 i+ E0 O
  209.   char filename[MAX_PATH];
    * j4 }1 G) q( ]3 j
  210.   LPUPDATEFILE file,olds;3 ~' \+ T+ L* J
  211.   std::map<int,CString>::iterator i;
    + R3 J8 }+ {+ I
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    * j& z( s) z( h: Y
  213.   std::list<CString>::iterator l;
    % {' J( S, g5 x* D% x

  214. 3 [6 q% t8 t8 M& t
  215.   if(bFirstUpdate)" n$ K* Y7 f+ ?1 m8 b9 v9 s9 x& n
  216.   {
    / p2 `2 z) W; a4 s7 S% @, T" x
  217.     dwCurrFile=0;
    . U% ~% E( ^, U1 c/ i; ^- n! J
  218.     bFirstUpdate=FALSE;9 o9 x: b) @+ }7 A+ z
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())8 D2 {+ b' j# G3 g2 R2 m
  220.     {2 x! n* V: a( h5 Q3 T
  221.       dwTotalFiles=UpdateLocal.size();! m5 Q0 x8 w* p0 [
  222.       dwDownLoaded=0;
    ! f# S6 a! g7 g0 K) w
  223.       bSilentStep=FALSE;
    6 X* p& O7 Y& G9 N
  224.       bCompressed=TRUE;
    / L& y! B7 p5 g( \! g$ g
  225.       strExtLocal.Empty();* F; R' ^! y7 a/ \
  226.       strFullName=(*i).second;
    ! q( a/ K& T6 d6 s; N
  227.       dwProgramState=AP_CONNECT;
    7 v! R  R  H2 j% G2 d3 h
  228.       return TRUE;
    & U( Z$ A! q* }  D1 a1 a5 }5 w
  229.     }9 \* i# ]( l7 p# g/ J
  230.   }
    3 p6 r* v! }7 v) A/ F3 Z0 l
  231.   else if(bRestartUpdater==FALSE)- S+ q, q% w, Z+ `. ^5 r
  232.   {
    " z7 j4 S! \. x0 e* @
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())
    * e" `: P" y# e" q
  234.     {
    ' w2 c6 {1 _4 V* [1 b; n6 A' v
  235.       file=(*p).second;
    ! C7 _4 _6 ^' B( t
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())
    ' x* u& @3 s5 r  y% X& N4 W
  237.       {
    ! G7 K8 Z: E2 J$ j7 }& p) g
  238.         olds=(*p).second;
    3 \  E" a7 W' h4 d) }$ V$ g
  239.         olds->vers=file->vers;
      j, f; V* C  C7 d1 d
  240.       }
    : d2 R- i% o- r/ @1 Z5 `5 k) s
  241.       else) X! f( d4 O% d+ m6 Y
  242.       {
    9 L# l; J6 f0 l; t5 x$ R
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));7 e: _" O$ g0 v0 k2 {+ S
  244.         memcpy(olds,file,sizeof(UPDATEFILE));
    ) a( ^1 K. M8 r6 @/ H% o
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));2 C2 n9 o( s) f8 M0 t; K
  246.       }9 o7 |) ~1 F' \* {; {- d. B8 q+ N5 s
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");
    ! {4 W7 D9 h: ^2 O) L
  248.       sprintf(filename,"(%s)",file->file);
    , Z) d7 w3 r. y- f7 `
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    , Q1 Y) d0 s0 m6 X" G; n
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }
    2 D: |) ^* J7 K1 Z
  251.     }" ~7 w. c# A& w# ?# T% Y  Z3 j
  252.     dwCurrFile++;
    3 v$ [: T' p" S& ^$ q5 a
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())1 D; ~+ N" {5 Q2 H9 ?* u8 ~
  254.     {
    5 r( A( U9 ^. J
  255.       bSilentStep=FALSE;) C; m; j8 B$ h0 l
  256.       bCompressed=TRUE;
    ) O9 J* C; a' Z# i/ Y1 Z
  257.       strExtLocal.Empty();; O* j0 p2 [: e3 |% C  p) Q( i
  258.       strFullName=(*i).second;; D# v( T3 H0 n' I! Y! V
  259.       dwProgramState=AP_CONNECT;; @+ q/ ~: h# M3 o" V0 i
  260.       return TRUE;' U: f4 o7 [+ D  O6 L
  261.     }* A6 E, [( }$ t" X  c
  262.     if(!bRestartUpdater)/ z3 G: I, Q0 n6 f. [9 Z4 @3 o. T
  263.     {
    & V# `& o& N+ p$ Z2 U; A: b
  264.       int iCurrSize,iFileSize;
    ; a# b8 V5 W/ P1 G* Q) b4 L
  265.       iCurrSize=0;' t1 p# Y1 X4 i8 l/ u; g
  266.       iFileSize=UpdateList2.size();
    4 y# S- ?' o. @% `$ F# v% r9 {8 O
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");
    # }- d, j9 A( E( X+ U
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");
    & J& }) J7 @9 O8 M. U8 y8 E
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");5 k" F9 N$ k4 i9 u
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    6 M' [* {& m3 i$ j
  271.       Fclearf(".\\update.dat");
    ( v# \4 @' v: `& Y! Q1 {1 \( C
  272.       Fprintf(".\\update.dat","Bloodyf\n");& L" e# L) s5 K- z5 j1 X7 f8 S
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)2 j+ H9 y% X/ H( N! ?2 u
  274.       {" w2 ]4 b! J4 ]6 H
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())# \5 B: u# u1 w  I! t. u6 F6 o+ }& Z
  276.         {
    3 M/ P  j& o) m1 O# Z
  277.           file=(*p).second;0 O$ u0 |+ z- r0 C0 V# n/ z  U7 F
  278.           sprintf(filename,"(%s)",file->file);
    ) D: n  P$ D0 C# z; N8 i
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    & a+ Y  h7 }: x( v8 n
  280.           iCurrSize++;
    , I0 @3 o) t% |5 G/ U
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));2 t( S4 \  L  |5 o5 ]% W- x
  282.         }$ U1 M, e+ Z7 P! T' C+ D
  283.       }# m! J; b  m9 v4 X* |
  284.       unlink(".\\update.txt");$ x5 Y. w0 E+ I' H
  285.       unlink(".\\update.tmp");3 P  N2 L0 s( \/ o9 z  k  f5 e
  286.       Fclearf(".\\checkversion.dat");
    9 v0 T! ^) I$ S2 D# }
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);/ I. v: e1 u5 Q1 o0 Y
  288.       if(UpdateLocal.size())3 F* r1 B# R9 c/ R
  289.       {
    , L+ g5 Z8 b) G4 H9 a& C+ r0 w7 {
  290.         UpdateLocal.clear();
    4 O$ Y& H( n& M( i. H4 ^
  291.       }# m) b6 Z+ Z% U  i6 }% H
  292.       if(UpdateFile3.size())
    1 Z- r# L9 Y2 {( [# f+ W# v- O" H
  293.       {
    6 ?2 @7 ~! u# Y, S" q( H' ^) l4 p# c
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)/ h" H! t, u, ?/ U. T- {! m
  295.         {. w2 l9 ?  B( g3 ~: e
  296.           file=(*p).second;' o9 e( c0 i3 |  v3 W( o, A
  297.           free(file);! ~; r& Z; j- ?- r3 }6 _, P
  298.         }
    2 g5 t  I. [% P
  299.         UpdateFile3.clear();
    9 E6 r2 r. y- \  A: l
  300.         UpdateList3.clear();
      D& d+ Q, X! J3 C5 q8 w
  301.       }* q" b; Y9 W* g; ?
  302.       if(UpdateFile2.size())+ v0 ~  s. v% `1 c, m4 w
  303.       {
    2 ?( @0 G7 l- ?2 ?2 P; [6 F  ~6 ]
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)% t  U3 g. u+ x4 R
  305.         {) a! `. K2 H& ^5 O1 v, @0 i
  306.           file=(*p).second;  E# w9 u+ D; T- [& _
  307.           free(file);3 e+ o  G2 V0 m' e; U
  308.         }
    / H( k- f. t* u7 S2 Y
  309.         UpdateFile2.clear();" A2 ?, G6 G9 ^7 ]. u
  310.         UpdateList2.clear();
    * x: w) n- b: f: K& C+ u& ]
  311.       }
    - x7 {) [* O$ k5 s: P2 h
  312.       if(UpdateFile1.size())
    * D" f( W% n2 q4 F* g3 i6 ~( ]
  313.       {
      K4 ~. }6 G7 f; y
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
      R; ?; v4 P( K, @2 ]5 |
  315.         {
    8 A' ~8 ?9 H8 v/ _
  316.           file=(*p).second;
    ' B: s5 S  a/ A
  317.           free(file);
    - }% u% I; b$ v' `' N0 F0 C
  318.         }1 B, f7 h8 x8 E+ ]0 C( r
  319.         UpdateFile1.clear();
    $ t1 H, k, p- k5 f* u  y' N+ S
  320.         UpdateList1.clear();
      [" q2 t/ s3 A! o' ?. X0 i. B
  321.       }
    # S* H' b9 ^6 K  M
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
    ; |: S6 m  t1 I3 q0 i. i% @
  323.     }
    * L1 C8 T" |6 [- x: j: r
  324.   }( q+ L! K0 x. l# w
  325.   return FALSE;; a' T0 y  g1 ], g; ^. y% |
  326. }" d0 f2 n. q  x' B1 g3 d

  327.   ?- i) ?0 G2 e* ?& S% w+ P
  328. void CRevAppApp::ClearAll(void)1 n* k$ n4 Z- v1 P: T
  329. {( l, a8 v. ]% d! Z
  330.   LPUPDATEFILE file;/ d' c1 v- M6 j5 p, w5 y
  331.   std::map<CString,LPUPDATEFILE>::iterator p;
    , H+ s" p$ G$ w) c" C$ h  j

  332. # v; p) o- O9 G* H1 k' U9 v! e
  333.   if(UpdateLocal.size())
      j" h; c  j9 F! V* Z2 F
  334.   {
    8 ?4 P: p4 o+ p
  335.     UpdateLocal.clear();' `7 y9 R- B( m
  336.   }: e# \+ Y) A  J' ]0 T2 c: L
  337.   if(UpdateFile3.size())- P- J! o$ f* @. |
  338.   {
      n+ \7 Z! {- ~0 \( c0 y
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++). z, u( L! D4 C8 U4 Y" Q
  340.     {" _7 z& h* U. l( A( n' j
  341.       file=(*p).second;1 B8 d  E5 z- [# Q' r
  342.       free(file);
    ' Z9 \* I, R$ c5 N7 _2 z0 L
  343.     }
    * ~: f4 i* S5 p1 M8 @
  344.     UpdateFile3.clear();
    ' x3 r3 F+ ^3 @( i/ p. d
  345.     UpdateList3.clear();
    * I# n) L1 Z3 [! j' [1 P* C4 I
  346.   }4 f+ E' O" D; o5 H* w& ~8 [
  347.   if(UpdateFile2.size())
    7 \4 o% g5 ?# t( b; S3 l0 Z. r
  348.   {) \' n5 j7 l6 K9 b8 B. D4 ~
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++): e% l$ c. T8 j% D9 D
  350.     {
    , ^2 h  m6 W7 B4 X
  351.       file=(*p).second;8 \+ a' @# @2 l0 f; V! @" U
  352.       free(file);) L0 ?# E, {' T5 Y  _
  353.     }
    $ Q) H  R! d$ \' B. e7 V
  354.     UpdateFile2.clear();+ y7 H  g! c, @; c* P; _
  355.     UpdateList2.clear();$ b, x3 W8 M7 `$ c
  356.   }
    / B- ^% G& z! {  b
  357.   if(UpdateFile1.size())
    0 m- c" l0 H9 Q
  358.   {
    # o2 V" Q9 M) i7 i  F/ a3 `3 t) D
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    ; X8 c+ h0 u7 L2 R, V  a
  360.     {0 w$ k: \9 C3 U: R4 O
  361.       file=(*p).second;/ F7 G- ]* X# l
  362.       free(file);
    ) Y# `5 j3 S3 A' k0 |4 u, L% G! \  ~
  363.     }
    ) `/ Y/ b* \5 y) l5 K* A$ C  \
  364.     UpdateFile1.clear();+ k- n9 b* ]. `1 `
  365.     UpdateList1.clear();
    . k7 T9 V' o( }1 Z
  366.   }
    8 U( D4 V  U+ h3 \
  367. }  
    2 {1 r0 }0 P5 d* B; f) U# e( {
  368.   ' k  F  G) O+ [7 n) g0 m; C
  369. BOOL CRevAppApp::CheckLocalVersion(void)' n" L2 }' V, M4 |4 [
  370. {
    ' I7 K5 ~- O: `+ s3 t/ R
  371.   int c;
    , m9 D  T1 L' ?4 w  O& M( o
  372.   LPUPDATEFILE file1,file2;3 |% j3 ^' }$ l4 E
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;, f) o+ N8 [/ |! a& h6 R- m$ T9 ]4 D4 t
  374.   std::list<CString>::iterator l;
    ; Z7 w$ E( A( L' O5 _

  375. 8 X  E; c' K$ @+ J
  376.   UpdateLocal.clear();( o$ O1 f* s3 e$ j3 X  E
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    % W) Q. n& Q+ Z4 }2 N6 R
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);8 u* R3 ~1 _) @: T
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);
    * _0 {# s0 x, p$ `0 f
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    ! K& g4 F. f2 q4 _: t6 T
  381.   if(UpdateFile3.size())3 z7 t+ Q, C  b  D9 Q
  382.   {
    ( [/ j' f! f0 U! N, ^' s
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)) e! R! G' `. m3 C$ `$ Z) N
  384.     {9 v9 w  K3 Q- H; N% s! C3 A: a
  385.       file2=(LPUPDATEFILE)(*i).second;
    0 m8 i. y; j: v9 R( `1 A
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())7 u! B5 q; }8 `' M
  387.       {$ U# S- @- b2 W( V, N
  388.         file1=(LPUPDATEFILE)(*p).second;% f3 v8 f$ L6 T0 Q& n- F$ t
  389.         file1->vers=file2->vers;2 `% s6 A/ f" O0 t1 F; h
  390.       }6 n; Q  S* ]  |; F8 p
  391.       else
    - D1 D  f$ \: b! }
  392.       {
    2 O3 g9 d' o% {1 w/ [; I( n
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));. w9 e+ B0 O7 [5 q
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));
    ' X& m7 G* g: J' h7 ~: N+ A# ]
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
    $ J8 E. d: q9 y
  396.       }
    ' U! H' O. X( c- C
  397.     }
    ( l; r/ N* O* [- Y  H9 A! Q5 ^
  398.   }2 i* j  N3 |6 ~: r0 |. v  t
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)6 v4 J2 A% r' {& n* M- H5 O
  400.   {" Q4 z8 H% U* X- |
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())" d+ c, U" g9 ]. J( F
  402.     {
    4 {/ A9 I  r3 s' R* w, D
  403.       file2=(LPUPDATEFILE)(*i).second;
    1 a9 L5 i5 A) l  q. a& _2 n0 O' L
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())! n* p! n/ Y0 u; r- Z' v
  405.       {
    $ ]' ?- `4 G- q+ v
  406.         file1=(LPUPDATEFILE)(*p).second;+ U$ b. u# `7 m; w
  407.         if(file1->vers!=file2->vers)
    9 {* @+ U3 V7 ^8 q+ i- y2 T5 e
  408.         {3 e$ {$ I. l: Y" g/ E$ m8 |9 Y% P
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));0 q  o0 R8 F& u: d
  410.           c++;
    % y  x2 ~; B0 N9 a" P; D
  411.         }
    ( [6 k* `% K9 @- T' b; A2 R
  412.       }
      E$ o: I5 K! l
  413.       else
    # m( \. v0 z2 G
  414.       {$ H8 r6 j6 E: Z" u/ ^4 |
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    4 P' c/ q0 Q' L
  416.         c++;  E5 e; G* l1 d- n3 e
  417.       }
    * V7 |! h6 ~# K% ^/ `3 w: B
  418.     }
    5 ?( y* `* I) _1 m7 X
  419.   }- O( l3 U% e/ {0 Z
  420.   unlink(".\\DownLoad\\update.txt");  h& L: n* P2 E2 }
  421.   if(UpdateLocal.size()) return TRUE;
    0 }) q# a- v2 c) A; C. x, j5 J
  422.   else                   return FALSE;
    . X6 Q! {! T) [- N# b
  423. }  c7 U+ o" e  b) X; o8 B

  424. % e4 b3 L5 v6 C* p$ P. {
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"
    1 w7 x9 h9 ~* S* A9 A+ k
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"
    & n+ X  ?9 ^+ |8 Y

  427. ' F/ ]+ v4 }8 W; B3 ^2 D
  428. - i# M0 F3 d/ @

  429. + K5 \6 s+ N4 a- X; E; }* Y: w
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)5 c) d6 M% W. Q* x8 _* R2 G$ U8 E
  431. {7 P; G/ X( V- P. _' `
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;' V" @3 B" g. }5 _! j% |5 ?2 k
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1): h- _$ K- k0 L7 d
  434.   {
    / r- h8 C2 x, g/ J3 g" ^
  435.     char szLanguage[50];
    % r# ~5 S  s8 s6 k4 e
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");! g6 D9 s8 |: k# S2 X3 z# J& f- ^
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    % Q1 Z5 I" Y8 C; T7 Z
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;) f. q) w: N& u! {, b+ R/ R
  439.     else                                   m_iLanguage=ENGLISH;: i2 I1 Z# h; U$ k
  440.     char szRegister[100];) S2 N5 v7 _3 k
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");) N5 n6 t% h* N; U4 G
  442.     strRegsName=szRegister;- l1 o6 N2 s  G! ~6 F/ A
  443.     char szPatchURL[100];+ J$ @# ]- P% B
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");2 h7 @& l! K) }! b1 Q' k
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);) d4 S+ @, @" p/ F7 V+ t( f
  446.   }
    & ~# u5 e8 c; s# M( f
  447.   else
    5 c( w0 ^5 S  v1 N# v( O* D8 G
  448.   {& y' ^/ Q" S$ o4 X$ P
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);% O7 F5 U; S# Q9 ?6 _! G1 M
  450.     strRegsName=DEFAULT_REG_URL;
    , |  q/ e& E2 G- b. x! w
  451.   }
    9 i) z" }# i3 q$ K
  452.   if(GetFileAttributes("hosts.ini")!=-1)6 Y- N/ h! r# P+ ?, [1 P
  453.   {
    9 C+ V! e$ t9 |9 H3 M; {3 m0 U  l
  454.     char szIP[50];+ h0 r& V* _& n6 M( R
  455.     char szDIR[300];6 K1 Q( O: C! `3 k$ V! u
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
    ( x: C) \" M) f7 v4 B; E/ I
  457.     {
    , [+ Z1 l# A0 w
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");9 S! J; C! o9 K8 U
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
    % [; J. V; x+ \/ i
  460.       strHostName=szIP;
    1 N/ B# g0 }/ _6 Y
  461.       strHostPath.Format("/%s",szDIR);
    + s- x8 X0 g: g8 J/ _
  462.     }/ F0 u6 H- O: ^5 W
  463.     else
    0 x" I3 T# Z$ P1 w0 e8 A& l
  464.     {/ l* ], y# }5 J
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)7 C/ _- ~2 e1 K9 [3 z) s: X- d/ B
  466.       {$ L1 `5 h: Y4 w* ]6 t0 ?
  467.         char szLanguage[50];
    4 {) y6 ]' C" F5 T& g  A
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");9 f# W; x- N' N3 X3 g, V6 D( i
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ) ?# G1 w( }9 o* B( R# S
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    : h3 p7 P& n+ ~! S7 H- y; G
  471.         else                                   m_iLanguage=ENGLISH;
    # v9 J' i! L# S7 m; N) x* Q
  472.         char szRegister[100];% I& k+ _, k+ {  {( _
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    3 z7 i1 D7 V* d3 z4 c4 |
  474.         strRegsName=szRegister;
    ( n! v! ?+ |# S+ ~! o
  475.         char szPatchURL[100];, U7 |% }' w; D& R1 G7 F3 O& l
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");* s4 L' V7 w; O
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);  m1 Q/ F  Q; @
  478.       }
      O0 n% D, Z8 F8 i
  479.       else$ i# F# j  e+ x% Z
  480.       {
    3 d5 S, R4 m8 E# v
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    6 `& j6 e1 X+ P) @1 W1 \
  482.         strRegsName=DEFAULT_REG_URL;
    * K/ D! q' K- J; N0 ^7 O
  483.       }
    - ~2 X$ _( W1 Z
  484.     }
    , }& L1 }7 @2 V9 }
  485.   }' ~2 B# F# H8 U, r
  486.   return true;
    & w! c* N* `: }; K  u4 |7 j
  487. }# o* f3 v5 H' J6 c1 f

  488. / E1 n7 _% M8 {1 ^$ I3 I
  489. #include ".\ZLib\unzip.h"
    & G4 f0 f9 ]$ O+ y2 u' n
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    0 @) ^$ `3 i0 J
  491. /////////////////////////////////////////////////////////////////////////////
    4 N' v6 k. g6 w/ w% m  Z8 g
  492. // CRevAppApp initialization
    1 I9 y# C/ m. u( M" t$ o1 z: p

  493.   S. q, L1 J0 T
  494. BOOL CRevAppApp::InitInstance()2 A, C5 C8 @9 \4 A( ^
  495. {
    9 R; G/ T" f2 {' N9 S
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    2 K0 P; E/ y+ O8 \5 c4 {# l

  497. " v  v1 u3 D# F% O& ^" p: }
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);
    7 Z1 X, r' Z. l% i) }
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))+ r! \; z2 u! h, v
  500.   {
    0 S' k% _- Y0 P/ \; [
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");) c5 T- Q  ^4 N- Q
  502.     GetPathFromFullPath(szPathTarget,szPathSource);9 s! W3 H  D$ ]$ y+ K  g8 F
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))* ~8 f* z* w$ R! c
  504.     {4 K8 u- v9 _" L. m' L" E
  505.       strcpy(szPath,szPathTarget);) {/ m* d' c* y' F
  506.       SetCurrentDirectory(szPath);- o- y2 z6 ]9 z$ f; K' ~) C
  507.     }; a: F  s: g3 h! S; }1 A
  508.   }
      P. v$ W. u- I# F/ M7 c# l0 ]
  509. #ifdef _DEBUG
    + M0 A% f7 l$ O. G0 x% e9 F
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))! B8 F8 V8 q3 l( T
  511. #else
    6 u' K9 V5 i+ O% T
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    ) W% W0 a. ]( l5 m% T# q7 Z; a
  513. #endif
    4 }: b: x: @5 H5 B
  514.   {
    0 J* s3 t& z) c% c$ [2 `$ r# h! w
  515.     char tempFileName[MAX_PATH];
    6 B& Z  ]- j. z
  516.     strcpy(tempFileName,szPathSource);' T6 v/ n/ b0 S  o0 w
  517.     tempFileName[strlen(szPathSource)-12]=0;
    , h% h( W. E/ O- B; k
  518.     strcat(tempFileName,"\\$CSUpdate.exe");7 d  q* F  t1 `- @$ T) a* u+ _5 E
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);
    * @0 U  f% E: B3 ?+ b
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);0 F" p2 U# z6 i% W' `% X
  521.     return TRUE;' o+ O* D" ^$ v
  522.   }
    3 }* |9 \% x2 ?- z$ T7 o
  523.   // Nuke 0118: Delete run.exe
    % O, t' c' |, \1 z' a3 d, S- b
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );& r' {' Q# R1 U- v) k
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");
    / E5 X6 D" _0 S- r5 _3 V" C4 t
  526.   if(!ReadCfgFile("Config.ini"))
    ; p, f1 K" {$ _. l
  527.   {
    ' G% u9 M2 I+ T; M
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);& N$ U" F/ o6 ]! O
  529.     return TRUE;, B* V5 Y4 m- s: x  Q1 O
  530.   }* ~+ j1 r- V* [, ?- l- a
  531.   HANDLE mutex;; x! t, z0 K; r! c* x; c; P2 @
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))! a& ?( k9 r" z1 {3 T, R! {( X% U
  533.   {' ~% G; k2 ]1 q2 ?( D7 g
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)0 A& e+ N' }! a. B, Z
  535.     {  _9 U' _+ Z2 p" `( M3 w1 M" \- O( Y
  536.       CloseHandle(mutex);
      r9 a* J1 h8 z4 P7 A
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    & H- B: b* P* N
  538.       return TRUE;
    ! ~1 K& }2 Y7 N: b+ |4 A9 [: }' W: G+ h
  539.     }5 T0 _# z- U3 b. b% R- Q3 k3 M7 G: D$ c9 h
  540.   }  
    : G- Y: Q0 a; \( I9 Q, i% @
  541.   CloseHandle(mutex);
    . E; U, r& V5 x
  542. + b. N& O; C. Z/ j3 A2 G
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);
    " H! S( }3 Z8 v# j- n
  544. ) Q) i: y! f* ]0 m3 p3 j, p
  545.         AfxEnableControlContainer();
    & D+ `8 M+ O2 i: k% _, Q
  546. ! W7 r# N6 j. g  I8 h+ ~
  547.   bCanUpdate=FALSE;8 o: `" U% o4 R+ ~8 Z$ s* e
  548.   dwStartUpSteps=1;
    7 {- ^+ ?5 ]9 [2 ]5 i* O: f
  549.   dwProgramState=AP_NOTHING;2 K% J. ]; b- V, u$ S" n
  550. & @1 H( Q: n5 \1 S6 @8 l
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);% L  }, b3 F0 G! G5 Q
  552. . `3 h3 u& o  S6 g* c
  553.         // Standard initialization6 K6 Q" I& u& r: V8 _: ~0 x
  554.         // If you are not using these features and wish to reduce the size6 X9 W2 a) T$ C$ n" Y9 Q2 ]
  555.         //  of your final executable, you should remove from the following
    3 w0 i4 t6 t. |1 b! U+ j9 k7 M
  556.         //  the specific initialization routines you do not need.
    # y6 C3 g1 [6 o+ V, `: [$ w) k

  557. 9 N$ n; C! |! N5 I
  558. #ifdef _AFXDLL- }( x# a  h  v+ M8 N2 J0 d
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL
    4 n1 U, b8 Y* f, v5 \
  560. #else
    + Q. C8 m* J2 C0 D; z4 I: ?
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically
    7 z% w( v) I2 q9 M# ]. Z' o: q4 H
  562. #endif) g- A: C+ L! j2 k  F
  563. ' w7 o: j6 o1 R8 Q% O  x
  564.   dlg=new CRevAppDlg;
    ' k" c3 d9 m5 R+ Q, g7 ~1 a
  565.   dlg->Create(IDD_REVAPP_DIALOG);
    ) ~* C# _% }; Q# ?- Y
  566.   dlg->ShowWindow(SW_SHOWNORMAL);$ ?# j$ z* n, y5 l! l
  567.   m_pMainWnd=dlg;0 z6 V' R* ~* O" N- [

  568.   }4 X( V- A# p
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);
    ( Q9 _* W% ~9 G; I* X: f. ~- h' R
  570. 2 `9 [' g3 w& F7 L6 c) [) N
  571. //  GdiplusStartupInput gdiplusStartupInput;2 s% K: M$ c2 p0 f. p) u- W
  572. //  ULONG_PTR gdiplusToken;
    ) m3 B- D: d0 z. E9 P
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);
    . Y% S+ j: I, r( J5 f4 j+ r% n

  574. ' C. F) n+ G3 U- N: l% T0 a
  575. //        CRevAppDlg dlg;+ X8 Y3 N- i1 @8 s
  576. //        int nResponse = dlg.DoModal();
    1 b' p; l. |& Z: a
  577. //        if (nResponse == IDOK)& P, E0 O1 G$ U
  578. //        {- q2 S5 V( ]# C& U. [
  579. //                // TODO: Place code here to handle when the dialog is
    7 k- A% v9 w' f
  580. //                //  dismissed with OK
    ; f0 o. P* d' s9 @
  581. //        }
    . F1 S+ f% c+ {( J0 ]
  582. //        else if (nResponse == IDCANCEL)5 t+ M1 K- h- M
  583. //        {
    6 G9 `; ?5 K3 Z6 a
  584. //                // TODO: Place code here to handle when the dialog is
    4 b0 `6 \3 o7 k0 y
  585. //                //  dismissed with Cancel
    & Q3 c( b& ~2 D. d
  586. //        }! p; ?5 u, O- ?, ~) N7 z
  587. 0 g& w; A6 e( |6 X2 L
  588.         // Since the dialog has been closed, return FALSE so that we exit the
    8 Z: D# T, r* N# v* v* Y
  589.         //  application, rather than start the application's message pump.
    & {; g4 x9 n% i7 {. S5 y4 g% G1 b
  590.         return TRUE;9 o) C" v# h# O' i. o" b( S$ \
  591. }
    . [9 |3 ~! c1 ]) ~. W( x$ r. N
  592. ; J7 N' }1 t: P: `) ?/ }: P
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    : p& R; s/ J3 Z9 G
  594. {- k( N5 c$ V1 G
  595.   int i;
    6 J$ r" [+ Z: F1 l3 \9 R4 e, c
  596.   char *szRet;
    1 m/ D2 q* W$ |9 u* a7 F& e

  597. " ^. L5 ^/ G+ k
  598.   if(pSource) { itoken=0; sztoken=pSource; }6 Q1 B. }0 f/ x* G2 K6 a( s9 r
  599.   if(sztoken)/ [+ n& ]: j' ~8 I8 L
  600.   {
    2 C  L$ o# |, G
  601.     szRet=&sztoken[itoken];) X" `4 ^  y. h3 j  _& }
  602.     while(sztoken[itoken])" p& s6 R. v: P* F9 b4 l" C: S2 ?
  603.     {. G( A# W3 C" J# S8 X3 \/ f
  604.       for(i=0;i<(int)strlen(token);i++), L1 Y; |* s& [; K, O+ G% Y
  605.       {
    2 I1 t2 R( z( p) \. Y
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])
    . m. p' [# O, J* `
  607.         {  l% t$ o  I1 ]# y* }5 N" R6 k$ Z
  608.           sztoken[itoken++]=0;
    * e, j( T4 p1 \: d4 O
  609.           sztoken[itoken++]=0;5 H5 @  W, E% d! ~7 I, Z4 \
  610.           return szRet;  y& u4 z" [6 Y4 m; x5 h
  611.         }, k3 v* @& p& a0 @# d: J+ ^3 O
  612.       }- S. Q# x5 R- ^, H1 n
  613.       itoken++;
    - |! n8 s4 L6 `$ I! x; z1 Y
  614.     }% w, w9 |6 Z! X8 P
  615.   }
    , }  X% @+ \: `- ^* ~! n( x
  616.   return NULL;
    / ^2 Q: U4 U2 g( }( M2 S
  617. }
    8 O8 W, l$ V' l- |

  618. 3 s2 v8 \. b* }8 w
  619. void ProcessProc(long Total,long Current)
    5 \" s; _# \& J& n, g
  620. {
    8 N/ {  i1 y1 {2 T' q
  621.         MSG msg;
    + l  h0 q; D3 m. ^) ^# c
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);
    # A" Y2 j. O& j, ]8 F9 \5 b
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));3 `4 n- T5 W' H+ ]7 n
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
    ! }8 p& V  u6 j5 v2 J( D
  625.         {. Z! H. ]! H! q5 u
  626.                 if(!GetMessage(&msg,NULL,0,0))1 q# H8 \9 Y1 |# T/ H
  627.                 {
    , V' Y1 z# c& J. u5 `$ Q& I2 C+ l
  628.                         return;
    , r. W" ]3 ?: q% z( r# p8 j
  629.                 }1 T/ P1 q; F  F5 h
  630.                 TranslateMessage(&msg);0 u2 ?) z- T( _0 ~/ |9 m
  631.                 DispatchMessage(&msg);
    5 j, I" i+ x! M3 Z. w7 g/ X
  632.         }       
    % l; }2 T* M- u: Z
  633. }
    # V) J* @( R0 _3 f8 ^0 ^' k# I

  634. ' M+ [1 F- `% z7 |1 y
  635. BOOL bFirstChar=TRUE;
    7 r# ~; k5 U# J2 ^( o

  636. 2 F& M/ B7 v" o( d3 l$ D; Q: Z
  637. BOOL CRevAppApp::OnIdle(LONG lCount)/ E2 r# _( T- b
  638. {0 @8 l& f7 U9 `4 ?; C1 ^- @- C
  639.         // TODO: Add your specialized code here and/or call the base class( ^3 u# }9 L; ?
  640.   switch(dwProgramState)5 I! i9 t* B9 H- b, v& o1 n
  641.   {
    / d2 [, Q# N* V7 J0 a4 ^
  642.   case AP_NOTHING:8 p) G9 @6 X- k1 v
  643.     switch(dwStartUpSteps)
    . ^9 ^" N) q6 w& X- X' r$ O
  644.     {
    ( B1 n& c4 o$ L. q  {' N" _
  645.     case 1:
    7 `  l& r, Y) |7 e: a- ~1 C) W0 S
  646.       {
    # C# C+ `, W9 t" J/ r
  647.         int i;9 @/ M2 F: ^7 F/ d. b
  648.         CDC *pCDC=dlg->GetDC();& Z- D5 I9 k$ g/ Q. y" |
  649.         HDC hdcwnd=pCDC->m_hDC;! O2 O3 `3 P# I) A) e$ [" l
  650. //        Graphics graphics(hdcwnd);
    & c2 k# n" U) E. A# P: k
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");+ j1 ^  R- K! V0 _2 \
  652. //        INT iWidth=bitmap.GetWidth();% f5 r! z/ l" S3 \2 c. @/ _( L0 ]
  653. //        INT iHeight=bitmap.GetHeight();3 H! S# c2 W/ G' d* z; e) x
  654. //        Color color,colorTemp;
    & S4 R6 e; T* J6 d, F. l
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)
    - L3 u3 \. v. ~
  656. //        {
    6 G: U! T6 [1 B) L# n2 P: H
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)7 Z, [0 P! c# _4 B9 R. c1 ^' P
  658. //          {
    ; ]; v* I$ q1 l' G: p( |" Y8 O2 |; W) a
  659. //            bitmap.GetPixel(iColumn,iRow,&color);( u( g- E* o$ p4 {$ h& x
  660. //            colorTemp.SetValue(color.MakeARGB(
    . X: h+ o- E1 {/ [: q0 S) y
  661. //              (BYTE)(255*iColumn/iWidth),
    & f5 B" p/ g- O# X7 m
  662. //              color.GetRed(),0 c3 V9 e' j. N1 O5 O) R- \, W
  663. //              color.GetGreen(),6 V, I( q- b/ N
  664. //              color.GetBlue()));4 O/ R# {6 @1 A* D6 V1 r- s
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);
    $ M" i( ~; D, {/ u. D3 f; P
  666. //          }2 X- }! `2 m: ?5 ?) }
  667. //        }
    3 D. V) N' Z$ C( U
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    2 {* U% L3 ?2 |
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    , L% g. u# r) k8 U
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    + {( v9 Q5 Y1 a3 ?4 U
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");: [: V; e& b* r% @' i
  672.         for(i=0;i<240;i+=8)! W" d9 c( m' z& h1 }
  673.         {5 W3 H) z/ g3 b) x$ U
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    + [  B( j- G  g  P/ |0 O5 Y
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);$ p5 L. O7 h" q8 g5 Z( ~
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    2 ^1 R4 W0 P" ^# ~$ x
  677.           Sleep(33);0 ]6 d  ~5 f5 z  p. k
  678.         }
    2 i6 D, ?2 a; p( ]6 T* r* Q( \6 h
  679.         Sleep(1000);, V3 L) i# I3 S( u4 |2 [( E0 f' v
  680.         for(i=240;i>0;i-=8); G7 ]2 M( l3 l& ^
  681.         {% p7 c+ Y7 k5 F4 `& t0 l" C
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);( X" w  W/ u5 D- h& j' e; r( g
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    1 ]3 o7 i3 r. I1 C) L5 B
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);+ z$ j+ Q/ v6 P& f5 J5 N2 l2 q
  685.           Sleep(33);, P8 |7 Z; ~( F
  686.         }
    ( N! Y8 J3 ]; ?# \9 Y0 [
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);6 |/ p3 _# Q8 C* i- a( l/ D+ q
  688.         dlg->ReleaseDC(pCDC);- t9 `* y0 D4 ~  Q
  689.         DeleteDC(hdctar);; B' I( m. {* ~) f- `8 ?
  690.         DeleteDC(hdcsrc);7 M+ a# Z4 J, \7 L7 p
  691.         DeleteDC(hdcorg);
    5 _0 C# e( N9 k5 E  @+ g, |
  692.       }
    ! G1 b: Q) {/ G2 p. c0 y
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);
    % [! b! P$ C) I5 g! Q9 n
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");$ g3 d) O$ t& |1 v& k, k4 \) b# s
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");
    * M! \  ]) f  W3 @# x& _/ L% S( A
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");
    , p6 ]- d7 j' g
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    , l& t7 r6 o) [; z  o
  698.       if(!Dn.Connected())
    8 S5 L, j( \8 q2 n8 ]( f2 f
  699.       {5 G( D( x# Q1 i6 [
  700.         dwTotalFiles=1;; R" M7 a9 A! g4 Y: G& [
  701.         dwDownLoaded=0;2 p; [1 y3 D3 d  q5 }/ M8 B9 j% {& k
  702.         bSilentStep=TRUE;
      a6 X$ S6 O1 m. ]3 {8 b6 P
  703.         bCompressed=FALSE;
    , n0 B* \' k5 W* C9 W7 q3 I: Z* C
  704.         strExtLocal.Empty();4 f8 w0 R1 K' o& N1 S
  705.         strFullName="readme.txt";
    ' l; f3 r& k# A( W6 T  X1 z2 k
  706.         dwProgramState=AP_CONNECT;
    # P5 c. Q* T5 T* y- s0 U& L
  707.       }; P8 G7 ]6 O+ n1 w
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();
    5 s5 o- h9 O7 }* z1 z3 s
  709.       dwStartUpSteps=2;
    5 ]' [, }4 }+ k5 ^/ _/ v
  710.       break;
    " D9 b' @; o# n6 u' g) ?
  711.     case 2:. F* u7 G. X. n8 W: Z
  712.       {
    & N- u' t+ k! z6 Q3 K
  713.         int iEOF;) g1 {1 O3 d, B8 n& ]$ k
  714.         FILE *fp;, z: ?% U- ]) }
  715.         char szString[512];
    3 f" }; A% J2 F0 H& X6 x
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");( C  a3 J& g8 z5 F
  717.         if(fp)
    & {1 n% E( |4 p
  718.         {* r: d3 t4 ^0 E3 }2 {
  719.           do4 ?' k+ O: Y  s" j+ C
  720.           {
    ; {* l$ @: W: r9 @0 n
  721.             iEOF=fscanf(fp,"%s",szString);
    - W2 `" Y! f9 C6 f5 A) y7 r! B
  722.             if(strlen(szString))3 Y7 `2 x, U4 {4 q  e/ Y
  723.             {1 E( E/ n0 A) G- p' h- h3 g$ P
  724.               if(bFirstChar): I. J( O/ s# x
  725.               {" f: `; Y  @, o8 e$ T
  726.                 bFirstChar=FALSE;3 v4 L; w# @8 K) @) h
  727.                 bConnectIsBig5=FALSE;
    , v0 [2 W8 z  ?" m) K
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;
    ) I, C' L% O0 n1 _; `  _3 C
  729.               }1 G/ `* e: U( B7 m  J' f
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));) U  V/ A( v1 |4 M, W
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));
    3 ~  m2 n% ~9 h% N0 p: O! f
  732.               dlg->m_ListText.AddString(szString);5 I$ i1 n# @1 h% I. h
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);) ^# S  U' a3 j7 n* K8 j
  734.               *szString=0;
    % L, Y3 |1 e* }6 M
  735.             }6 ^- G' R5 @9 y2 U% ~
  736.           } while(iEOF!=EOF);  @# i2 u$ g) S
  737.           fclose(fp);( s# {8 s% Z0 L; b0 x
  738.           unlink(".\\DownLoad\\readme.txt");
    ; t+ u1 M8 t- r! _" M8 \1 `
  739.           dwStartUpSteps=3;
    / Z, Y& X& w; r4 S
  740.         }
    % X% B9 K/ q3 p" ]2 ?6 Y
  741.       }3 U3 L* r7 M" v- U' Q: h
  742.       break;
    , o5 Y! }- n- t. q+ m
  743.     case 3:
    6 h( I* a) H6 ]4 ^  r
  744.       if(!Dn.Connected())
    + z. C# `. l0 l" B/ I
  745.       {
      z4 b( A& t; `) e5 A/ z
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);
    ' d6 X1 r% s/ V" ?  @
  747.         dwTotalFiles=1;, \4 `$ B1 w$ y/ @% `1 b# h
  748.         dwDownLoaded=0;
    & h- L4 [) j7 C# n' l" Z
  749.         bSilentStep=TRUE;: G- U3 C1 |3 u* T# Z& ?, J. n
  750.         bCompressed=FALSE;1 [5 E) [: j$ T) b) W6 ~
  751.         strExtLocal.Empty();
    7 n9 p7 A5 h- w1 D" L9 g
  752.         strFullName="checkversion.txt";8 s( [+ a/ g# j4 `0 ]" D& {/ ?
  753.         dwProgramState=AP_CONNECT;
    ( n8 h6 E% w5 D* f# d4 S1 H- }
  754.       }3 _+ J6 P5 ?0 S
  755.       dwStartUpSteps=4;
    . m* k" y3 _6 ~% o- }6 k
  756.       break;
    ! |3 }+ q6 K6 T  F% b- G* r
  757.     case 4:
    6 T9 B8 g* j1 d3 V4 H, ?% N
  758.       {& l7 s6 |+ p8 o( G  [
  759.         FILE *fp;6 m& T' ]. g* L
  760.         char szString1[128];+ o* c9 T0 E4 D0 J$ _! k' t( [3 ^6 T
  761.         char szString2[128];
    ( p. a" [0 Q; T
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    5 k: h) F9 Q; |7 l) i: K5 ^
  763.         if(fp)
    ( q. P: p8 o' z+ h# r2 [
  764.         {; L; ^* T. _: E
  765.           fscanf(fp,"%s",szString1);
    ! F6 t7 E- X6 [, a. n! T
  766.           fclose(fp);5 O7 V6 @) D4 D5 ~  `/ p. q1 V
  767.           fCheckVersion=atof(szString1);3 h  g. \: r4 N# P7 Z! o+ V
  768.           fp=fopen(".\\checkversion.dat","r");  `/ d4 u6 b& Z! b" z' I
  769.           if(fp)
    # }/ `' P: X8 E; ?& u
  770.           {
    . f' t! t2 ]  Y: B4 f# A
  771.             fscanf(fp,"%s",szString2);/ O  [8 A! U- {4 x
  772.             fclose(fp);$ g$ e. n! j# l6 g% b! l" @" Z
  773.             if(atof(szString1)!=atof(szString2))
    2 H9 l, A# s7 i+ Y# _1 }
  774.             {
    + S! X4 L# X5 m& K) w. n2 G1 {
  775.               if(!Dn.Connected())# y9 O. P1 p8 p' k! \
  776.               {, B$ J" w# Z) [& f! k! j" Q8 y0 O
  777.                 bFirstUpdate=TRUE;
    ! z* d' A: r8 F+ P
  778.                 dwTotalFiles=1;
    & D. U$ _# j; ~+ z8 ^
  779.                 dwDownLoaded=0;
    8 `) s- b# Q# u0 y* x" p, p% P  `
  780.                 bSilentStep=FALSE;
    1 ]$ ]+ r/ M- d! o/ A
  781.                 bCompressed=TRUE;& u0 k! \/ W4 Z9 [$ O
  782.                 strExtLocal=".\\DownLoad\";
    ! K6 h1 N: `) o& ^( w$ c7 l0 j
  783.                 strFullName="update.txt";3 y/ V" A! |: A9 K4 E1 |
  784.                 dwProgramState=AP_CONNECT;- J- W+ f3 Z7 ]
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    1 r0 z$ ^+ j3 D: W4 c, o) d
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");1 [0 K& r" E0 e! B& V& {  ~: R+ [
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");
    $ V/ s; t6 P; l7 ?& w+ C

  788. " Q3 f2 f: q; k4 O2 M
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);4 |; b" x- G8 B
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    1 a7 A$ U/ k# t$ N9 Q
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)
    ; D2 B; `4 Z# K0 I2 Y# }1 c. D
  792.                 {! D+ }6 X  l) j: J* [
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
    : C4 f$ C: u2 K) [+ ]
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");
    7 ]3 y  {+ f- }& O# ?5 {* b& }! n
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");
    ( {1 a& b7 d- l( J( {. E- E. v
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    # u5 H8 u+ M# J
  797. 0 |6 C" J9 j- P. [
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");" R, ]! B. P4 ^+ s! R! I
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");. F( S) ?3 m, G% _: b3 O+ N* |; B
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");" u! j9 h" N8 v2 i" j4 {
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    * ?9 H* V( n: m& w: Q
  802.                 }" T8 s% P$ N" x7 o; ]1 f1 T
  803.                 dwStartUpSteps=5;5 i/ R. |+ H6 {( p4 e, Z
  804.               }: J& L! Z1 y0 C. {% l4 z' _
  805.             }4 o  z" e- w2 s9 D2 s3 M3 N- u
  806.             else
    * g7 I  t6 ~: g
  807.             {
    ; M2 R2 Y( Y! g/ ^! f/ K
  808.               unlink(".\\DownLoad\\checkversion.txt");( @! D5 n4 @: W. J) l$ X
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");( |9 g* h+ a9 e5 a9 V
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    & P4 ~  N, d4 C/ D8 f3 X
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");2 y, Q' Y6 e3 `6 {; N  q
  812. 6 \. u, Y4 _+ K4 b% L
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ! K% c7 E8 A% r' L& u
  814.               dwStartUpSteps=99;
    8 a; n0 G$ d1 x
  815.               bFinishUpdated=TRUE;
    # V3 L7 s% h* a$ B
  816.               bCanUpdate=TRUE;+ l5 h- M$ a/ q$ s3 u
  817.             }3 G8 o4 Q2 a5 U9 s/ m  E8 {
  818.           }
    ; J7 k9 A4 ?* W8 \8 B; u9 w3 _! @
  819.           else8 s# }7 \# d  z, |( ?
  820.           {. e' ]  f6 d* a* H) w8 n
  821.             if(!Dn.Connected()). I% b$ r; B* \# S
  822.             {$ A( a- I) L! Z# M2 `. |
  823.               bFirstUpdate=TRUE;$ l  u  |  M) i9 Q# j" W
  824.               dwTotalFiles=1;
    2 m1 S; t( d1 E- Q
  825.               dwDownLoaded=0;+ e, R0 Q! s0 P$ M7 z& Y
  826.               bSilentStep=FALSE;3 \; {9 L! P: P9 f+ q
  827.               bCompressed=TRUE;6 q5 D; E% l. ^/ n$ d
  828.               strExtLocal=".\\DownLoad\";7 U& _, ~" K. s$ U8 S
  829.               strFullName="update.txt";( ~9 n& V8 l( k: t
  830.               dwProgramState=AP_CONNECT;: t( p+ v" u: j( q& |7 a9 f/ m6 A
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    ) G3 V) w, G: u4 \# Y
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");2 `# f: n6 n0 c
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");3 _8 @( L0 W& \. [4 N1 K
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);$ G' ?/ l7 u6 W8 V% }
  835.               unlink(".\\DownLoad\\checkversion.txt");" L" Y- ^, Z  j  q
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)$ E* c8 M. u( n  T4 @& V
  837.               {
    & W" p' Q" L4 h6 g4 t+ n
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");
    3 d8 s3 D  J: Q! t/ T3 D
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");) B; P0 C! ]: s: Y9 I6 G2 H4 Y' G
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");
    8 O9 \; W0 G1 n# J2 ^& C$ N
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    + ~8 I/ m4 _- F; G' `
  842.                
    3 b0 R" @4 c4 y; b- n
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
      H( Z7 N. P9 |/ }& V- k
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");% P& o; r6 F- O# W% i# @6 \
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");- Z' [+ G4 p4 k1 R# ]- W$ h. Q& I! a
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    & N. y  O( _& L, ?
  847.               }! j0 F4 S' [! i# Q+ ]4 f- w9 J9 s
  848.               dwStartUpSteps=5;
    1 Q, }9 U4 ?4 r! _( m
  849.             }
    ! u1 J1 u: Z1 ]6 o" g1 f
  850.           }! D) S. s, j" c" ]. n# \/ o7 ~
  851.         }( V, d6 [! b; _1 f1 B
  852.         else
    3 u# ]4 g: ?% @& f( P8 f' Z8 w& \
  853.         {
    ( S7 \- W+ C- O  ^
  854.           dwStartUpSteps=3;
    8 B3 l8 C+ I' u
  855.         }8 n( I/ j5 b+ i5 \& U8 }
  856.       }6 m, I" A  Q/ B" S/ G6 J, U, }
  857.       break;  |4 v  f8 d! ^& H) n  L* P
  858.     case 5:5 F! \- N7 C5 f
  859.       {! P6 E, ]6 Y- f( x! n
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)4 ~" M) @0 z4 m- h& i
  861.         {
    0 ?9 |6 A: \$ M. [: d
  862.           int opt_overwrite=1;6 B5 f4 Z5 \' ]7 N. t4 B5 [
  863.           int opt_do_extract_withoutpath=0;7 P/ m1 E  Y; V! Q1 |
  864.           unzFile uf=NULL;
    # R) k/ L( f" X# A7 x  Z3 b
  865. - l0 G! F" a9 q; v; s
  866.           uf=unzOpen("Wsa.zip");7 L5 b0 ?0 Y! T3 V7 e, \: @0 K4 ^
  867.           if(uf)
    ( m8 W4 c6 |# g
  868.           {
    1 l* ^; H  o: x) d
  869.             do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
    ' p! D5 p; k0 w" a" t& L
  870.             unzClose(uf);
    % g4 @5 d# |( |) D
  871.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃ЧΘ.....");
    , O' `1 ~- n0 [0 Q2 Y. l
  872.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压完成.....");0 q8 g9 m7 i' p6 _. T, ~; ^8 M# n' B% y
  873.             else                                                      dlg->m_ListText.AddString("Unzip OK.....");9 |2 [0 l6 R7 r4 [* B5 q( M$ T
  874.                                           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    , Y+ ?" T/ M2 B1 h8 |5 {5 N
  875.           }1 N9 V4 W* \# a' w! g; I: r6 j# v
  876.           DeleteFile("Wsa.zip" );7 s$ g# t- Y/ M% f3 _9 _
  877.         }/ W3 {8 b4 i+ E! ]) _) k( d

  878. % }7 o$ t, @: I; c' l  G3 E, g. B
  879.         if(CheckLocalVersion()): n& n9 p0 B" \' c* i5 t
  880.         {# C$ Z) z7 N# L# a3 s& p  K- Z9 r  a
  881.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫磅︽絬穝戈.....");
    : n" g( }- L; [4 r* Z3 i& Y
  882.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请执行线上更新资料.....");
    $ D0 R2 @) A6 C* E& }
  883.           else                                                      dlg->m_ListText.AddString("Please update.....");/ b% @. J8 Y* r& v
  884.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ Q3 u  I+ G, [, s0 {
  885.           SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);
    9 _9 d7 d% T0 Y* O6 L& W1 Q1 `  H, [
  886.           dwStartUpSteps=99;3 m/ J4 t4 q! K+ v$ M+ X
  887.         }- ^* t+ x' M$ F
  888.         else
    2 g4 p* x$ @1 |. ]  c8 H
  889.         {
    / o9 }1 n6 o% P/ K; W
  890.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");- F0 O2 q2 L! Y; M+ `1 ?
  891.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    9 {" C' @! B  N
  892.           else                                                      dlg->m_ListText.AddString("no new file update.....");% X) w; F* @- U7 ^, a, W

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

評分

參與人數 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客服返回頂部