找回密碼
 立即注册

CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閱讀模式

* u6 O4 F3 m( S) l& l
  1. / RevApp.cpp : Defines the class behaviors for the application.1 o6 `1 t6 [9 o$ Y- r# V9 G
  2. //
    9 `' e9 ]$ x9 {, W7 z! ?
  3. 7 w' k  v2 C# F. j: ?3 x
  4. #include "stdafx.h"" ]2 \- d: I8 J2 B/ D

  5.   w! f* f( ~3 F
  6. //#define UNICODE
    4 K) E& N( ^, H( Z, z/ B% @) s2 ~
  7. //#include <gdiplus.h>
    3 Z/ q) q# g& J# N
  8. //using namespace Gdiplus;
    8 K: `9 c, y) r4 O* e3 w- B+ ^

  9. " }6 s; g, r: K0 B
  10. #include "RevApp.h", C% t- J4 g/ ]' k# |  v9 p& K" n
  11. #include "RevAppDlg.h"
      E! h$ }8 V1 ~5 U; A7 ~
  12. % d; [, r* B9 }$ B; \
  13. #pragma warning(disable:4786)0 ~/ J9 Z7 M5 S) a
  14. #include <map>
    ( d6 l# B8 {/ z* s3 S8 w, v
  15. #include <list>$ v. N' u1 L4 A" |3 t
  16. #include <direct.h>
    + y# h/ K# }3 j

  17. 8 S9 g" P3 f1 k. Z
  18. #ifdef _DEBUG
    6 t8 {7 a+ X) M6 v9 }% Q" n, E  _
  19. #define new DEBUG_NEW
    % ^- W, S4 n; W  ^- ?( ^
  20. #undef THIS_FILE% r8 U8 W' ~3 ?, `4 y; @4 U4 }. U* ~
  21. static char THIS_FILE[] = __FILE__;/ m$ ]% a1 ~: S: O5 z' M
  22. #endif6 g8 g! B& \8 o- ~+ }: E0 x7 c% c
  23. #include "SkinResDef.h"
    . l+ W  b8 x1 s) J6 p9 a% v# n7 [
  24. #include "ChangeBG.h"
    $ R3 [1 s* h0 `2 o2 X2 u: W
  25. #include "AFXINET.H"
    9 A! L$ e) {. f$ [! J: Q
  26. # j8 T! u2 Q' z" {# P4 H" D# y( u
  27. #define TRADITIONAL_CHINESE 0! r) A. g4 l- v8 g* G- P
  28. #define SIMPLIFY_CHINESE 1
    5 d. n, q' J6 s" j$ s# }( L$ R( V
  29. #define ENGLISH 2  K  h2 W: h) K( u0 O
  30. int m_iLanguage = ENGLISH;! U3 C9 ?- x, e* `) r& g8 K; \
  31. /////////////////////////////////////////////////////////////////////////////: G+ _& ]. o: Z0 I# m: l3 ]7 S
  32. // CRevAppApp+ t; y$ K' p3 [9 s1 R; b

  33. - u% S: x* o+ t' I
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)3 v& y& V$ e/ V, |: ?& @& {* m
  35.         //{{AFX_MSG_MAP(CRevAppApp)
    & k$ }+ B* {4 B- L3 T. e# H
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here./ m$ x" @; \; n" P' K! V
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!( W4 n  s6 l( G1 n4 P  P: m" N
  38.         //}}AFX_MSG
    ; z" w1 z* S5 p, V' w4 k/ v- G0 ^
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)
    ; P% E6 Z2 [  R+ N9 X
  40. END_MESSAGE_MAP()
    * u; v5 }/ u; R* n) }

  41. 8 F7 R; a9 Z" P3 O6 r
  42. /////////////////////////////////////////////////////////////////////////////
    ( M$ E  t3 e  n2 g, a8 I
  43. // CRevAppApp construction
    0 T, N1 }* B/ {( u- ^) D7 I2 f

  44. $ m" t7 ^' ?! _7 h" P* h
  45. CRevAppApp::CRevAppApp()& _, w, @2 t% h0 P. G( V6 Z
  46. {* G* p  k) t# ]
  47.         // TODO: add construction code here,1 w# R. _9 b+ u+ G/ J3 b
  48.         // Place all significant initialization in InitInstance" M& K, ]+ h: O4 g; A4 S
  49.   bDisplayIsBig5=FALSE;; B% y$ d2 b8 Q4 U" D1 F, M
  50.   bRestartUpdater=FALSE;1 Q8 Q$ O9 p# f& F9 p
  51.   bFinishUpdated=FALSE;5 R! r( k: J& A$ k' Z) B
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;. u7 Q% {9 k5 @7 [- k$ A6 d" j
  53.   InitChangeDataBig52GBKS();
    7 y2 e: g0 v: J1 G4 R) X7 p
  54.   InitChangeDataGBKS2Big5();( y# `6 c3 ^, M$ C" l
  55.         //4 M9 O% B2 f2 M7 r
  56.         bClickRunExe = FALSE;# y$ I7 Z0 |* ]1 n/ \
  57.         //& J9 O2 c9 c' U4 q; B% d
  58. }0 ?/ l' Y* c% y+ e5 U% X
  59.   ]5 R4 f! x% q
  60. CRevAppApp::~CRevAppApp(), `+ Z4 h7 U% \' n; [5 E
  61. {; m- x) E, }4 x; y
  62.         // TODO: add construction code here,
    $ X# K) P% h$ J6 o5 d* A9 ]
  63.         // Place all significant initialization in InitInstance* e2 |: Z$ V# }% t2 X
  64.   EndChangeData();. j9 T/ v5 C. `
  65. }
    $ T0 K# y) z# r, Y
  66.   S9 O4 e" @9 i" p- Z+ I# @
  67. /////////////////////////////////////////////////////////////////////////////4 J# u: u% k& G+ y
  68. // The one and only CRevAppApp object
    & L; @7 c6 C4 a1 H5 ?/ R3 \
  69. 9 H1 l% ?# n% Q( u- @" F4 M" h
  70. CRevAppApp theApp;
    8 o/ Y" Y2 o. O6 Y+ Q
  71.   u" Z8 Y1 i4 O' J4 h0 W
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)# h( I- N6 A& t. H1 m  e$ M
  73. {
    # e3 d+ p5 C8 t9 |/ _: z! y
  74.   int iEOF=0;
    ) K+ `. \  U( a5 @7 H) s
  75.   char szTempName[MAX_PATH];, m- l6 V& V( V, f! l# M
  76.   *szFileName=0;
    7 N! m7 i# R; p0 ]  ]9 \# N( |+ Z
  77.   iEOF=fscanf(fp,"%s",szTempName);4 ]- v5 O6 q0 M
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    ) N, k3 }8 a0 b5 b$ }
  79.   {
    , i7 Z+ i( ~4 o. \6 j' P6 \+ }" m
  80.     strcpy(szFileName,&szTempName[1]);
    1 u, X7 I7 T6 c1 }1 k4 V% o
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    ( c/ {8 _0 h' J, R6 T
  82.     {& ?/ d' E& z* X) V9 }
  83.       iEOF=fscanf(fp,"%s",szTempName);* G! E- f& x% G, o& ~
  84.       strcat(szFileName," ");# V: }# P0 o: d9 z9 B& K" s
  85.       strcat(szFileName,szTempName);
    4 x  Y+ P/ p" r4 u' V
  86.     }
    : H5 X' ?3 T9 P2 A! E. m) C
  87.     if(strlen(szFileName)>=1)) s1 t/ s9 C( S# j+ y# Q
  88.     {
    ! {- z8 A; |  o9 i/ l$ I. r
  89.       szFileName[strlen(szFileName)-1]=0;
      B( M. L; N: t
  90.     }
    . X/ E6 ~) |) F& \& E# q! R
  91.   }/ w7 p3 O1 ~5 l
  92.   return szFileName;. u. C& k1 c4 Y( \1 A  @  n) o
  93. }  E6 i$ i6 T7 c! h, T* J& R
  94. # X  \8 U  G% E$ S* g" c* |
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    2 u: t! u$ ^2 r6 W
  96. {
    + ]$ P# M* z" H) U+ Y
  97.   FILE *fp;* j2 y3 J! A3 R
  98.   char *key=NULL;9 G9 V- N: O8 q
  99.   char version[MAX_PATH];6 C# @9 a1 t' J- x2 {: U' ]
  100.   LPUPDATEFILE file,olds;4 G  u  {* m* x5 N& Z
  101.   std::map<CString,LPUPDATEFILE>::iterator p;
    ( w" {4 r9 v: p' S; \
  102. 5 w% P8 g* P1 |
  103.   UpdateList.clear();
    : x$ T. \; w& ^, Q7 O
  104.   UpdateFile.clear();& [. q" s+ i) u9 z4 ?
  105.   if(GetFileAttributes(filename)==-1) return false;& F$ U; ^5 |: T$ l
  106.   if(!(fp=fopen(filename,"r"))) return false;
    ! d- f& K9 C% k
  107.   fscanf(fp,"%s",version);
    / ]* M8 O( b" ]- R1 X
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }
    & ~: ^, g5 i7 M6 U9 m$ F9 V8 {
  109.   while(fscanf(fp,"%s",version)!=EOF)
    4 [- ^5 n0 ^- ~: m8 F+ ~
  110.   {& r6 z) j' c6 H0 {
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    " w' c& [# g# g6 {( ]1 n- O
  112.     fscanf(fp,"%s",file->path);
    + c" j' O6 e% ]& C
  113.     ReadFileNames(fp,file->file);
    " s( L9 e+ i8 p7 o) [
  114.     strcpy(file->full,".");1 V" u3 q9 z' R& q) j" F- T& K
  115.     strcat(file->full,file->path);
    # [) C+ ]0 z6 m/ F( @" X
  116.     strcat(file->full,file->file);# o' h9 ]" \+ d
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())% H" N6 K; z9 r5 x+ E9 A6 {0 _, ?. R
  118.     {/ N; Z, _, U8 l" g8 ]
  119.       file->vers=(float)atof(version);
    ( w! b: N, K" g3 p0 n3 K
  120.       UpdateList.push_back(file->full);
    % u' H8 b9 Q7 L9 `' M
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
    2 T3 F* ~* U5 x9 S* q+ q6 u
  122.     }
    2 v* s" o0 N4 ~5 F6 ^& B" I
  123.     else
    ) |8 s3 d' ]5 V8 c! ^
  124.     {
    $ X- Q* R) `+ L. D! c
  125.       olds=(*p).second;- _' [8 M  q! F" t$ T7 h+ A
  126.       if(olds->vers<(float)atof(version))
    3 [5 d' L  _. U
  127.       {9 |; T4 ^; b9 w' i5 ~" L
  128.         olds->vers=(float)atof(version);
    : U( ~, {5 |: |5 ?
  129.       }! s5 C, a! w7 P- R( j: e3 P
  130.       free(file);
      X5 T+ n, v) }5 R7 }  O2 w
  131.     }
    " y$ r1 w  _3 J% F- n- `
  132.   }
    ) p4 t0 H3 P. g& `( z
  133.   fclose(fp);8 G/ K+ o5 h; V8 S' Y0 P
  134.   return true;+ i/ U8 J6 t9 M# v
  135. }/ A# Y; ]# Y0 X. P: ^0 m

  136. 7 i3 X" A, r5 d2 k+ U2 j
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)( L$ L0 H$ M% Z5 C, `
  138. {
    / p. {3 P' S8 C  J' Q/ v
  139.   TCHAR  szFull[MAX_PATH];
    $ s8 _# n, D. ~
  140.   TCHAR *token,*inter;; P. K1 W* a: g& ], f* M
  141.   *szPath=0;1 P# b  P/ H: _' H# y
  142.   strcpy(szFull,szFullPath);+ M8 b% q5 p1 b- _( G, X
  143.   token=strtok(szFull,"\\/");1 l, w. V8 @" a6 l6 @
  144.   inter=token;
    & U1 K5 O2 a! ?4 i  k$ b: x' Q
  145.   while(token=strtok(NULL,"\\/"))
    - J6 K% z0 ^% {5 f/ ~
  146.   {
    # W, A# G" H+ J3 {
  147.     strcat(szPath,inter);
    ; o! e8 H. _( O1 z! T
  148.     strcat(szPath,"\");
    ; W& G$ ^5 b  n0 e, X5 E- S
  149.     inter=token;+ t/ ^9 \' d+ ?
  150.   }
    3 L3 |  `! o% H  n) g6 C
  151.   return strlen(szPath);
    ! A! ?) f2 Q) ^7 w
  152. }& z" i9 A& C5 j) r- X8 j# B

  153. ; D5 l  T; Z( u' K, c7 ?$ m
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)* K% h% }1 K3 [  K" ~1 J
  155. {
    , X# b; g- c1 [
  156.   DWORD attrib=GetFileAttributes(Target);
    . f* j- x! H' [
  157.   if(attrib!=-1)
    3 O& f# t! p' `* W
  158.   {
    9 ]# {' j5 L' B2 ?% @$ x
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    # g0 L3 G: t: K! `# w
  160.     {
    $ \( [3 P" \- f
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);2 B& X. m, f1 o+ g# E7 L
  162.       SetFileAttributes(Target,attrib);0 J$ ?2 v0 ]& l- D4 g
  163.     }
    % W7 q5 V% X3 ?- B& u! ]5 ?- Y
  164.   }6 I5 u0 S; l# Q# r2 }9 Q8 I
  165.   CopyFile(Source,Target,Erase);
    ; [- L: e2 f* |' f( h* V
  166. }) c' H8 f3 O+ `6 u+ U; `' Z+ b
  167. . e* Y' H! z( O* h/ w& k' R
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)6 w" v# O# e; H& d, V7 u
  169. {
    ( W, B2 t4 Z$ j& ~5 t
  170.      FILE *fp;
    2 I- V8 |+ `8 Y& g
  171.      char  szBuffer[8192];: C0 Y5 e1 `' _5 K1 j2 P% a
  172.   va_list  argptr;
    4 ~. h, m( w9 _; b; W0 ^) J) p8 ^1 N

  173. 7 e' F. M0 w; ~$ H  q4 N
  174.         va_start(argptr,message);, k+ f! U. E! f" w5 F% ~* Q
  175.         vsprintf(szBuffer,message,argptr);
    0 r4 [1 w6 r& v+ J( k- i/ w
  176.         va_end(argptr);  l8 |. A* y% M( V* M
  177.   fp=fopen(FileName,"a");
    1 r# g! C3 z" T4 Q* Y" }3 |
  178.   if(fp)
    # w* Z2 `0 p8 `. C  d8 E# \
  179.   {
    % P9 \+ _# ^" H9 t9 d
  180.     fprintf(fp,szBuffer);. {7 x4 b7 f( r/ i0 j& c) }  h
  181.     fclose(fp);% U, S$ z6 k/ \* c% a$ C& u5 U
  182.           _flushall();6 c: R" Z# n. M! |2 O9 [( a) G
  183.   }- Q2 n) k/ b1 I" D. B( w4 {
  184. }+ H: _3 u. {1 s4 G  X

  185. 2 h' k4 G! Z/ E: P8 u+ L/ I: o4 q* F
  186. BOOL CRevAppApp::Fclearf(char *FileName)8 M9 I7 \( C6 }$ }4 B; ?# ]
  187. {: g- J- W8 Y) u7 L% g1 d
  188.      FILE *fp;
    - S6 c$ w6 I$ E& K3 q/ z* z
  189.     DWORD  attrib;
    & V1 k3 ]* t% z, a" y8 M
  190.   attrib=GetFileAttributes(FileName);% _* @" b8 A0 P. K5 m
  191.   if(attrib!=-1)- `7 b9 P' T4 L
  192.   {( \' \5 X  G( J: B9 k
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);" j" q& F3 s9 o2 B
  194.     if(!SetFileAttributes(FileName,attrib))
    6 r3 h# H' m% ~
  195.     {+ Z' `4 ]2 W9 D5 _" H; D1 N" ~' }' T
  196.       return FALSE;
    5 J/ W' L* b3 L
  197.     }
    - t+ U( a8 R- c
  198.   }
    / Z) r9 i2 O" ]" \9 `) v; D& a
  199.   fp=fopen(FileName,"wb");3 F0 m7 n* O6 q
  200.   if(fp)
    $ G* \/ ^+ C. d  k/ a1 s
  201.   {
    , m, G" G. G# R" v; U) X; j% L2 S
  202.     fclose(fp);
    8 G1 W9 ^0 q6 z8 w" @: ^9 B  T! R7 X
  203.   }
    ) j1 _7 e: e7 O: y. O
  204.   return TRUE;
    / W( e4 y7 E. b& R! P3 y2 ]0 V+ I) i
  205. }+ N6 H  B( Z, t9 S. q

  206. $ p7 _1 O" u" B- ~8 q2 t
  207. BOOL CRevAppApp::UpdateLocalVersion(void)+ F: x0 _% k6 k  ~
  208. {9 Y( u) \' L5 z' @6 _2 R
  209.   char filename[MAX_PATH];
    ' q- {% ^# }9 z6 B+ S% }
  210.   LPUPDATEFILE file,olds;* V' ]0 ~, X7 S) q3 `( w' z5 L
  211.   std::map<int,CString>::iterator i;
    " E% t) z% G( f" c1 y
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    6 N1 A2 r0 @8 s3 r" r
  213.   std::list<CString>::iterator l;
    & P1 q  B! N4 Y
  214.   }* M" z% n; ?2 ~; f+ K
  215.   if(bFirstUpdate)
      _0 C% O( O& ?3 U/ u
  216.   {( L/ F: e- L  b# {2 B; ?
  217.     dwCurrFile=0;
    $ @9 D& |& F3 V. N+ X
  218.     bFirstUpdate=FALSE;
    ! Q. \) K9 Y& e! A3 h/ O
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end()), ~" c- }2 K* g
  220.     {7 \: p. |' ~7 c2 k. F
  221.       dwTotalFiles=UpdateLocal.size();. |2 ^  ^% `. U7 N
  222.       dwDownLoaded=0;# p# ^% L& B. }% V
  223.       bSilentStep=FALSE;
    1 {' ]' t  ]4 o' j# U1 d. N3 J
  224.       bCompressed=TRUE;, Y# p6 V+ d% {8 \  T$ k0 S
  225.       strExtLocal.Empty();  I+ H+ V; Y8 ?# q9 w, s9 |1 g( `
  226.       strFullName=(*i).second;
    8 A" }* V& x- d+ d2 i9 r- r
  227.       dwProgramState=AP_CONNECT;
    - }8 c' F. x6 d1 x* a; l. y# \
  228.       return TRUE;6 ?% n: `" {$ n& J$ w. v3 t" W  r. @
  229.     }
    1 v/ q; r: r1 E* @
  230.   }
    # S& G# ~3 h$ q1 o: V+ ^% ^5 W
  231.   else if(bRestartUpdater==FALSE)! @9 h) K8 Y  A; @! i
  232.   {% b; i0 r/ n6 F8 i. {6 J6 u
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())5 u/ ~  P/ c$ @+ w
  234.     {& v5 o' o: h6 |! U9 `0 f
  235.       file=(*p).second;
    # e& ?+ m: w: e
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())
    2 d( I0 W5 o' X4 e! h7 M
  237.       {
    - e7 Y6 K5 b5 e5 u* p: E( M/ g$ a
  238.         olds=(*p).second;
    ' A. e5 U" f. ?+ t; Q9 G4 b1 s
  239.         olds->vers=file->vers;* f5 i- q) z! @$ n! g  U9 g
  240.       }& S, c$ B7 ?; R, Q' f- A" @
  241.       else
    ' Q% e2 G7 D! E
  242.       {
    : W! E- |& A, L7 k/ D
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    - O8 r0 ?# y* m1 G* r0 ]
  244.         memcpy(olds,file,sizeof(UPDATEFILE));% {  f7 g. x* g, k( g3 ?. X8 O
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
    . C* q: V! |( w- R* {1 D+ V. `
  246.       }3 w+ e* h  W7 P; G& G
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");9 g6 ^6 {) t" s. S7 @
  248.       sprintf(filename,"(%s)",file->file);
    " h5 @( Q+ O+ ~5 r- ^  W/ R9 m& U
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);* `$ e5 `/ U. b! i! J
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }/ Z6 V* g' H  N5 R8 E$ q+ L
  251.     }
    $ b9 x8 H9 w- ?# R
  252.     dwCurrFile++;
    , D) h- V5 ?. m3 D4 X2 }: Q
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())' Q5 C7 F1 ]1 S4 v8 ~" E
  254.     {
    ( i! [3 A) r# G! p! w, g& m
  255.       bSilentStep=FALSE;
    0 G& }3 V% y9 ^
  256.       bCompressed=TRUE;
    ( T2 }3 F9 C( P( p
  257.       strExtLocal.Empty();8 G9 u8 g# A3 m) z6 J
  258.       strFullName=(*i).second;
    3 p4 {3 ]* v' e$ R6 ]8 S9 U6 D8 p+ l, T
  259.       dwProgramState=AP_CONNECT;* R2 {/ T5 o, E# \7 P/ Y# n" d
  260.       return TRUE;
    5 I# f4 t! P( r% L/ g
  261.     }
    % R  p6 P1 S  d5 u; Y# ~4 T# \0 J; h
  262.     if(!bRestartUpdater)
    1 S. V+ Z3 a" c3 i
  263.     {
    7 Z5 E. e* N" p# `/ U
  264.       int iCurrSize,iFileSize;
    % U8 W5 s) t) Y) L, G: D- J
  265.       iCurrSize=0;
    ) ]! h: C1 d6 @
  266.       iFileSize=UpdateList2.size();
    2 y# r9 v" G- s9 k
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");
    # G4 o5 Y1 Y, L8 z1 G" }
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");
    0 J0 `1 `* S# j: N% ~% f
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");
    7 k# h8 R9 ?; i/ ]
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ A1 m" a* r6 }& i% c# D0 s4 f- f
  271.       Fclearf(".\\update.dat");
    8 M$ Q7 p" \& I4 ~+ A+ g
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    ( p8 C- Z) H2 g5 H; ]: R" ^
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)! l, J  K1 ]/ }" F( E* Z$ x+ s
  274.       {% K. R/ l$ u; k
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end()); q) s* k- J! f, i
  276.         {
    ) K7 ]: p% c' t4 v9 c+ h
  277.           file=(*p).second;5 a! G( u* y4 S& N0 r' f
  278.           sprintf(filename,"(%s)",file->file);
    7 p9 u: G, v' ]8 ]7 k
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    " Y2 |) N1 o, u' e0 Y: n, F
  280.           iCurrSize++;! |8 |1 X" o1 o( A5 U3 A
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));. K* P1 E  n5 e: O) j1 ^
  282.         }
    ! w, ~# g" S# @6 ^( A! O2 W7 E7 d
  283.       }! H: o' u6 _* Z& A
  284.       unlink(".\\update.txt");! H: L( `! k9 `6 w4 r$ g- J0 K
  285.       unlink(".\\update.tmp");
    9 Z2 ?& o& b3 [2 n% O
  286.       Fclearf(".\\checkversion.dat");
    ) f/ k" p* \% y* u& L5 c) G' L
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);3 B( e/ V6 A5 @( w
  288.       if(UpdateLocal.size())
    * E4 C9 J, k5 u9 q3 g0 {+ }" U
  289.       {
    7 B! \; j) Q0 g9 W
  290.         UpdateLocal.clear();' _: u! l) a* S# I2 N0 {4 _
  291.       }
    : B2 p; M* G' C, U( c2 G/ m
  292.       if(UpdateFile3.size()). S: |, l: a- I/ h
  293.       {
    3 @9 \1 ?1 p7 w5 O, ~/ Y# G
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
    2 {: G- a" T! X# s0 @/ i
  295.         {
    3 B$ F, k: R5 _9 P) f5 @0 {8 I
  296.           file=(*p).second;
    . x$ Z$ ~; a' d6 Q- e
  297.           free(file);) r$ U! @& J# l1 x
  298.         }
    ' m1 L6 a+ Q5 i- G+ `; e7 p
  299.         UpdateFile3.clear();' |+ Y, s  A/ p5 c
  300.         UpdateList3.clear();1 A) v! b0 a% n$ y  @: D( {
  301.       }' s0 |# H4 {3 I' h' E0 Z  Y
  302.       if(UpdateFile2.size())0 x+ E9 D9 m& b) r# C" ^# ~7 E
  303.       {: [0 u" H1 l0 d
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)9 v. X; y' B4 h& h/ F. K/ W8 M+ [
  305.         {
    & U5 ~% T, J$ a7 x3 _
  306.           file=(*p).second;
    $ M$ G& V9 G# T- D( Q
  307.           free(file);5 m5 E8 B( a: E& D' [3 t2 k2 w
  308.         }1 [6 W9 N5 O- l
  309.         UpdateFile2.clear();
    - ~1 z& i! E1 k- P' ]- k/ G( ~
  310.         UpdateList2.clear();
    1 V1 q( |( D0 l
  311.       }
    1 o; ], n; _* J8 S. V
  312.       if(UpdateFile1.size())+ t! R, t# R7 K! C* C- l
  313.       {0 x) S' t# F8 c4 m5 `% C4 q
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    + D8 d; x1 i/ w: O, x) v' G
  315.         {7 o& ~2 m+ n+ W/ @
  316.           file=(*p).second;
    : ~) u0 P% k9 A" p9 O( R
  317.           free(file);
    8 O2 A1 G/ P/ R- W
  318.         }6 R# w8 S6 P6 \
  319.         UpdateFile1.clear();8 O) ?) O/ }* U+ u
  320.         UpdateList1.clear();3 ]; F  Y# h# X( ]' o  q' \, u9 r
  321.       }
    ) r" f* J8 G2 C0 Y; O9 u( }
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));1 e3 U* \; p& x* y6 `3 ^! X. H
  323.     }  p5 a: {2 o# }* V
  324.   }
    + F. `3 H$ e) i# V: k+ L
  325.   return FALSE;
    9 q# D  l( Y  {3 @+ y- T2 i
  326. }( @7 _& G7 T  r+ [2 u
  327. 4 J: n8 E9 q# B$ V  a8 t4 p
  328. void CRevAppApp::ClearAll(void)
    - e4 G7 f. A. u8 B$ P2 q
  329. {
    8 Q1 A8 \; e! h
  330.   LPUPDATEFILE file;* @  \% j7 Z4 d  g# ~( y4 w& l
  331.   std::map<CString,LPUPDATEFILE>::iterator p;% P* o& _/ z8 x2 z
  332. 3 f6 U3 @. f# w" @' _
  333.   if(UpdateLocal.size())9 l" x0 s- q2 i: t
  334.   {3 h' @3 N4 e1 e0 D  b" Q
  335.     UpdateLocal.clear();
    8 A  `& @' a! f* o9 S6 U1 t
  336.   }. H( T) t: I& [( P- l
  337.   if(UpdateFile3.size())  S! g; W: \! s) n
  338.   {2 _/ N7 i5 X% \6 L
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++); C8 ^! m3 E( [
  340.     {
    0 A. b9 P( @! h- N
  341.       file=(*p).second;+ k/ x" R# h2 f: c: J+ ?
  342.       free(file);
    : J# [. x! \" B
  343.     }- F* P: @1 ^  S
  344.     UpdateFile3.clear();- c& R3 I( q! B8 `
  345.     UpdateList3.clear();: E/ G6 y$ _0 C! x' ~) Z
  346.   }
    ! {( M  r3 n$ a# h, d* _
  347.   if(UpdateFile2.size())
    3 N2 S- m7 T0 E$ s, q( e- q
  348.   {5 V* y- a6 B1 a6 ?
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    , C4 n1 l& K6 R0 v" g% A1 Q, m. w
  350.     {7 w% |& ]( ]" b6 d- z, T5 [
  351.       file=(*p).second;9 Z+ e9 D9 Z7 W, l! ]
  352.       free(file);- s" p1 y6 j4 n! s, H2 ^( [+ B
  353.     }
    % b' K% h, x( V- |, S* Y
  354.     UpdateFile2.clear();
    # ~& G+ v" K5 q: O6 H2 e% W  o
  355.     UpdateList2.clear();
    3 t! f, z# }% x( R4 s8 y0 p
  356.   }
    : h3 T- y( h8 k  C5 G/ U
  357.   if(UpdateFile1.size())
    ; K$ A% l4 |8 f2 L9 @
  358.   {
    ; F) W2 l3 n9 `
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    & t& V. r/ a5 q6 ~
  360.     {
    2 X& b$ P. A3 t% F0 n0 E- T; K
  361.       file=(*p).second;
    5 N5 Q: _& V" N3 N! b. S* ~9 _
  362.       free(file);
    ' c/ D  A: f" J+ _! Y
  363.     }( Y9 T3 J4 S% ?
  364.     UpdateFile1.clear();6 X4 t! H! S  N4 z5 z% U
  365.     UpdateList1.clear();  j( V% {4 {! P7 z* E! u, Z
  366.   }! ]0 u& c) d0 q/ l& V0 r
  367. }  0 ?1 U" B) \. n" b2 X- j) v
  368.   
    ( @: A3 B: U& M2 f5 {
  369. BOOL CRevAppApp::CheckLocalVersion(void)* C7 o6 s- ^/ A
  370. {
    ) ~2 ], \4 V& v- o( T, g
  371.   int c;0 U1 k" E- C3 c1 g
  372.   LPUPDATEFILE file1,file2;! t1 E# w' v2 S: \7 ~: Y
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    ) a6 t8 w* c& Q* {5 K/ T
  374.   std::list<CString>::iterator l;8 M0 r0 |0 P3 C9 |2 O$ }
  375. 1 K/ r" V* w8 M3 E, m
  376.   UpdateLocal.clear();/ _. ]- ^: @$ |" M& L, Y
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    " o$ F- c# s# S  c1 `2 W: C1 x5 j; G: F
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);
    # h( \& n$ T8 ^
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);
    4 [9 [1 l* U6 N5 z4 r9 Z
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    ; a- z& e4 F4 c: g( i, ~/ {; g" e# b
  381.   if(UpdateFile3.size())
    2 q8 W4 Y' u0 D5 M; y
  382.   {( V1 O/ J: j: x" P8 A
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)
    # T/ x2 u% A, a0 ~
  384.     {, l! i6 {" W) G0 X
  385.       file2=(LPUPDATEFILE)(*i).second;
    $ s7 D5 g4 J  p8 v. G  \0 ~
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
      U/ w4 w1 @+ r/ n7 u
  387.       {
    0 A6 R! F3 u, [
  388.         file1=(LPUPDATEFILE)(*p).second;8 G( g) \* d; a
  389.         file1->vers=file2->vers;4 R8 D; A# w6 ^( g6 H
  390.       }0 z- a, t$ M. ~
  391.       else
    ) E. z: v: F( [3 Z1 J% _9 V  K2 Z/ f
  392.       {
    / i$ [) u% I& `: W
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));! V2 v& e# A: h+ t' ~: u0 G' J
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));. \9 q% p/ G3 I: M* o% o' q
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
    " ^/ [) A' Z  m: D
  396.       }
    0 b; }8 A5 n# d4 V1 @( W
  397.     }
    " D1 z  H3 |; |1 ?8 a& Q: J
  398.   }. ?6 Q: M+ X2 g
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    2 {( K, N8 q  R* u9 f
  400.   {
    7 r/ D8 c! Z% I' C
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end()). h0 v; t3 o; A8 C. Y$ b
  402.     {
    ( D8 i( g$ C& ~0 x1 s- _
  403.       file2=(LPUPDATEFILE)(*i).second;, v7 S+ C- j+ ^0 K
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())2 s5 _& Q) @6 i1 ~
  405.       {
    + l% f, y* {0 j
  406.         file1=(LPUPDATEFILE)(*p).second;) F% Q# d" l7 F5 V) V
  407.         if(file1->vers!=file2->vers)* J! h+ a- w0 U5 `! r1 p8 x6 w8 }
  408.         {
    % f( h( O' P1 B8 B7 \7 }4 I& K
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    : ]& G: ]2 r) G5 _# s
  410.           c++;
    " ^0 v7 R, I% t0 e0 g; V
  411.         }
    0 T8 o% l2 l/ i) N. [( I8 e$ q
  412.       }8 y; ~" l6 ?; `4 y0 k
  413.       else
    : k" I8 H) g$ D0 c9 u
  414.       {" m6 g. L1 U' T" O
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    & j% {/ x7 U/ B9 u
  416.         c++;7 j/ j1 l3 _  R) s' Q+ u5 B/ z, o
  417.       }& o, u/ V. P2 n# D& w8 P- c
  418.     }
    0 i/ R& |5 k5 \. T7 P2 j
  419.   }( n8 j4 v$ L( R$ M1 g
  420.   unlink(".\\DownLoad\\update.txt");
    ; i" ]" M4 M# V1 A! h4 _
  421.   if(UpdateLocal.size()) return TRUE;; ]0 g) Q: X, Q" L; R4 k: `
  422.   else                   return FALSE;- |7 y' f7 p, `2 d
  423. }) I1 [( z+ Q! l  E  \/ _5 H; O
  424. - \& Y& d- O0 T. f+ Q- r
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"
    & ]4 N4 j+ X* ?% W3 J6 _2 B- S
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"
    ! {- {6 ^& n3 x( {- t9 T+ Z& O
  427. 0 _+ \3 I, F; e; h( T
  428. / W+ A$ C$ x9 t" [6 @' J& C3 K
  429. / X2 Y* k/ q/ H" l
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)
    2 A; h, G6 \3 E
  431. {/ A% j! R. |# e& @* p/ C" r
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;) `4 n- _8 ]% n6 i7 H  b
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)9 r, s$ {# E. H( t2 |
  434.   {; c/ r% ?* q+ C- y6 A
  435.     char szLanguage[50];
    2 P' H/ o* [" S) h+ d( z6 A8 [; D
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");5 y. |% J/ G9 [4 ~/ J" ^
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ( W: Q& e1 m% W# @/ i/ j7 U& N( |: E  T
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;9 {5 U0 J) H* r0 N2 V( c  ^% l
  439.     else                                   m_iLanguage=ENGLISH;; h4 m6 ]( [/ {$ ^- C
  440.     char szRegister[100];
    2 N8 q0 b6 k& S
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    & c! t- Y9 j. _, i
  442.     strRegsName=szRegister;
    : u1 B2 T) N, Z6 @1 s; M
  443.     char szPatchURL[100];$ i3 i( X* ^" K! c. ]1 _
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");5 \; }9 Z5 F+ H2 b
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);: I% b4 I( \9 n
  446.   }
    4 r( s" P' q; z4 e0 }& f, I  L. @
  447.   else0 \+ R. x, a  W1 N: g# Z. s; r
  448.   {, K( _* ^2 c8 j/ v
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    " X2 E3 B. K3 l9 n- y
  450.     strRegsName=DEFAULT_REG_URL;
    9 i2 f3 x7 P$ d' a0 U# c: q4 c) e
  451.   }+ y8 l' ~& p* a8 R
  452.   if(GetFileAttributes("hosts.ini")!=-1)
    4 j) @* |% w- f5 e4 w
  453.   {6 T- p+ |- i$ K/ z' O" S
  454.     char szIP[50];2 Y5 H& h3 E; E2 g5 }
  455.     char szDIR[300];
    & E/ l6 G2 ]. S5 j- l
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
    7 Y6 f/ S: P. l) w& t
  457.     {
    ) P6 }" W( r# z/ x8 p0 i1 n
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");" Z. A- M; z6 D6 {3 G# K0 b' u* F
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
    + t* k# a1 C5 s  {5 Y! [+ ^( d: \
  460.       strHostName=szIP;
    9 p' o- m" L, |( p( O: l8 q
  461.       strHostPath.Format("/%s",szDIR);+ e: l1 N! s) E, x
  462.     }
    # s" S$ e8 m- M7 ~5 z' L: ~+ j6 q2 z
  463.     else: s7 R& n* J4 Q$ z' Z
  464.     {
    ' j9 N$ G9 v9 E
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1). J  M5 ?6 ?& z
  466.       {
    . b1 [5 P# l! R8 D3 K
  467.         char szLanguage[50];) _% ?6 l! p4 w# ?; x( m) D; E
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    8 [! t8 w4 v! t6 u' X2 D+ u
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;5 ]3 h. `. b8 A
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;: [9 p/ }' o; `" K/ a6 N
  471.         else                                   m_iLanguage=ENGLISH;
    6 A; b9 q2 y% z, y
  472.         char szRegister[100];
    3 Z- ]5 ~4 r) w
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");+ M3 S8 e" z- x1 V
  474.         strRegsName=szRegister;& R$ _" h$ s( l# ]' [
  475.         char szPatchURL[100];. Z! ]1 L, B: M" @
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    7 A3 v' ^0 v7 C; w
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);7 e* P( e) p. u) u
  478.       }
    ; ?- o3 d' {  Z1 a& d7 j" M
  479.       else: l( e7 N! L" L0 V
  480.       {
    ! ?6 g  v2 n2 L* W/ ]
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);8 q3 h5 X& e1 `) K" D
  482.         strRegsName=DEFAULT_REG_URL;
    ) M7 Y: C# \2 H! l7 j! R3 y' T5 x
  483.       }3 @' F7 z! O0 @% r
  484.     }
    7 X2 t9 W2 Y; f/ H$ L  g( r) b
  485.   }
    / q; E; ^0 m" e3 X
  486.   return true;
    0 `/ @% ^! {8 M  l6 K+ k
  487. }
    & E- o, m3 h# Y2 i* g( p# t5 `

  488. & ^! o7 C( i- h3 G2 L- g
  489. #include ".\ZLib\unzip.h"
    2 ^, q1 V5 T& ^0 A4 \$ A
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    % m$ }$ g7 ]: S" P/ x* y
  491. /////////////////////////////////////////////////////////////////////////////
    8 n  F: I3 S; `
  492. // CRevAppApp initialization1 j6 n6 o( R3 V% Y: q( j

  493. + g7 `( E8 R8 ~' V9 j
  494. BOOL CRevAppApp::InitInstance()0 Z& I$ q5 ]; u
  495. {! V! B+ R5 ~# i# O. H
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];# S% o, d$ M) u9 H
  497. & c8 p0 K( e" }9 Q# e& r0 A
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);9 {9 y! t9 T& x) Z
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))
    , T  `5 S& @% `7 x5 L
  500.   {
    + V1 p: G5 a# M+ g# b/ R3 W1 ^+ i0 U
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");3 x5 n6 D5 J5 j6 w7 j- g5 v7 e1 O
  502.     GetPathFromFullPath(szPathTarget,szPathSource);
    ! s% f( C3 f, ]% G& a- _
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))
    / f* h8 w+ n7 ~7 q( Y
  504.     {. _( s2 ~, [" ~9 l, v4 J
  505.       strcpy(szPath,szPathTarget);4 B; W- u. a- ?6 A; P
  506.       SetCurrentDirectory(szPath);* e( }( ]4 e( i& {$ F
  507.     }
    ; P" W2 ]6 M# F0 @; Q% ~
  508.   }) n+ h) N" a* N1 ^$ h- s
  509. #ifdef _DEBUG
    - k* n+ X: o% X/ a# o
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))& ~0 L# E; Z+ z/ Y/ C, u
  511. #else
    1 @( r  K  U  M! b2 Y; R8 W
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))1 b& _' K" e( v0 ~, Y
  513. #endif
    - l: A; I) Q5 v$ l/ S
  514.   {
    % F5 \; \1 k5 U" _! b& q- M
  515.     char tempFileName[MAX_PATH];7 E5 d0 W  ]# f
  516.     strcpy(tempFileName,szPathSource);, ]0 `$ m& |% \% u
  517.     tempFileName[strlen(szPathSource)-12]=0;% r- K# N! ?3 `. ~
  518.     strcat(tempFileName,"\\$CSUpdate.exe");0 |7 Y% `/ ]5 x9 @$ w: R- \
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);% T  v9 r! d2 _% S
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);
    ( w' B7 }! t2 S  ]3 o
  521.     return TRUE;
    5 ]& s  }$ N# J3 O# Z
  522.   }
    8 M/ V' l2 s6 h' K
  523.   // Nuke 0118: Delete run.exe
    # M/ y" z" S$ {7 e
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );' Y, ^% ~8 C$ ?7 T2 l' l
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");
    / ]7 Y7 p: C0 D
  526.   if(!ReadCfgFile("Config.ini")): K  h* k4 d/ G! m2 k* x
  527.   {
    2 D  P1 j, j/ ^
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);! U0 d7 O9 X& R$ N$ \
  529.     return TRUE;' V" u" u, D. {  C
  530.   }
    * P! D; v6 R# }
  531.   HANDLE mutex;
    . `7 W# y; K- R/ }  W& `
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))
    / y$ y+ i6 e; l9 d# @
  533.   {
    0 Y& E9 n5 `. z. r) X+ ^+ p3 b
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
    9 ^" n# n. u5 r7 ?; v
  535.     {
    8 |( v: }0 ^5 G* h6 q0 k
  536.       CloseHandle(mutex);- y) A3 z" B0 `! R+ Z* t
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    5 H0 x1 y" p' u$ U! z1 ~
  538.       return TRUE;0 {& [: X1 b: R, D  z& Y8 D. B" \5 l
  539.     }
    1 w' B1 W5 {* l% W% J( d
  540.   }  % c% ?$ t' [+ S. A  K' I% P) N: h
  541.   CloseHandle(mutex);  Q; A2 H( y0 i3 x

  542. 7 \" k% ?3 k0 u# `
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);0 L. n; O6 j6 c2 R  E

  544. 7 p' V, n" F- Q; D5 p9 L
  545.         AfxEnableControlContainer();! Z, t5 E" @. U7 X! K6 k
  546. , X+ j$ l3 [4 }4 i* M6 v
  547.   bCanUpdate=FALSE;
    : }! s- j: @% _: k0 E
  548.   dwStartUpSteps=1;' T1 e+ ?+ @# d/ f. O
  549.   dwProgramState=AP_NOTHING;
    7 A0 J) D% q4 ^# X6 ~) D

  550. ) m$ u( {( A+ Q
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);# |1 b) T- g5 m5 E5 u' [6 V
  552. # p! l2 N  X$ h& a/ s' f: [6 ]' T1 j2 M
  553.         // Standard initialization# I: k' S. v- r, ~' i7 d6 q
  554.         // If you are not using these features and wish to reduce the size4 n& k9 G# {9 Y& G7 q  [
  555.         //  of your final executable, you should remove from the following3 c5 p2 @6 X  P8 j$ m( ?3 C
  556.         //  the specific initialization routines you do not need.
    # F0 @5 m" O9 {
  557. # o: h7 n" D# p+ `0 [; T% q' g
  558. #ifdef _AFXDLL
    # ]" l  U: i' v* S- a/ ~
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL# Y5 ]( ]1 V; U$ I! M1 {# g
  560. #else. e6 V( i4 a3 R  d# S" Z8 q
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically
    & F! h8 D8 ]2 `2 F. v
  562. #endif) g2 @4 H4 N6 V* b* J" T" f
  563. ; |, n7 {6 O1 a7 Z3 \
  564.   dlg=new CRevAppDlg;
    1 f7 ^' [; ~) x: I$ L9 P  \4 @
  565.   dlg->Create(IDD_REVAPP_DIALOG);& x) V2 H6 L& ?3 i  K; J) I! T; A
  566.   dlg->ShowWindow(SW_SHOWNORMAL);
    ) q& e; c' {5 g
  567.   m_pMainWnd=dlg;
    7 W+ _0 o$ ]! q5 z

  568. 7 m* \% G2 a! m: i
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);8 a/ R8 w4 _, S/ d* J# q
  570. 0 s0 w) T3 W0 p1 k9 F
  571. //  GdiplusStartupInput gdiplusStartupInput;
    : _! _' x+ L0 G1 _9 [% Y; w% d
  572. //  ULONG_PTR gdiplusToken;- `1 c: }9 n4 q& [+ p
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);
    ( ]& h+ F6 Y- f8 w( p, ~/ u

  574. % F7 D2 Y: w) W5 X& i
  575. //        CRevAppDlg dlg;' _5 C% K7 e+ r
  576. //        int nResponse = dlg.DoModal();
    5 Z) u6 }: g5 [& V
  577. //        if (nResponse == IDOK)
    ; [% O+ m7 B5 \& q; T* |2 f1 ~7 @
  578. //        {
    $ v7 `1 c: J& i( L0 V2 x. y) H, i
  579. //                // TODO: Place code here to handle when the dialog is- @; u3 v' U  P3 T2 i3 P6 }
  580. //                //  dismissed with OK7 t: @. Y1 [$ W5 a6 Z0 q; |( e
  581. //        }
    1 s3 q* Z7 v+ Q* _* c; q
  582. //        else if (nResponse == IDCANCEL)
    4 c3 J. t1 Y+ {5 Y+ b0 C. q4 B6 B
  583. //        {
    # n; Z$ s$ B! V+ n8 h! O5 h
  584. //                // TODO: Place code here to handle when the dialog is
    + G3 N5 p$ o7 n/ j  k# ]4 D
  585. //                //  dismissed with Cancel% ^5 J/ S% Z3 \
  586. //        }+ ~4 ?. N. g2 U- J0 @

  587. ; l1 X( i& n7 J; ]8 Z/ k2 V0 V( N
  588.         // Since the dialog has been closed, return FALSE so that we exit the/ S6 U( F3 }2 L
  589.         //  application, rather than start the application's message pump.
    $ A$ v+ N$ C( T7 W, @
  590.         return TRUE;% R, m9 o3 X4 }' Z2 O
  591. }
    - {4 N7 N4 F# E4 [/ V8 {8 t9 U9 ]

  592. ; u; c9 H. B& K
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    " `8 Q, H- Z" G$ q9 W
  594. {
    . H$ I( u, d" N
  595.   int i;
    & ]; k: V! A/ Q- d* }& D( V
  596.   char *szRet;
    , ]! Z% ]" ]7 S6 }. t

  597. / ^$ U9 B% E- N
  598.   if(pSource) { itoken=0; sztoken=pSource; }
    ) \4 j$ ~' a! V
  599.   if(sztoken)3 h# m4 t% ~6 s; b2 B# q- D4 ?) x
  600.   {
      g' W, m* A8 h( F
  601.     szRet=&sztoken[itoken];& g5 x" P3 S) E! K- V
  602.     while(sztoken[itoken])
    1 t: G1 M0 e! ?) m3 i& d
  603.     {$ B* w9 h1 ?& G) \8 ]- t0 S
  604.       for(i=0;i<(int)strlen(token);i++)
    0 V1 w) `" j; K
  605.       {
    8 o; z2 H. K  C# g9 p$ b
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])! z; K" r  b7 Q# ]9 ^* r, D; e5 u3 Q+ ]
  607.         {
    * N. t$ c' C7 u6 q/ i
  608.           sztoken[itoken++]=0;
    % g2 Y; R) l+ I+ S
  609.           sztoken[itoken++]=0;
    . o5 ^8 B9 T. v" a2 p
  610.           return szRet;+ K( T) H5 O8 l# K; a. Z
  611.         }
    8 |5 w: \. j1 Y6 L& a
  612.       }7 j' j- Z  M- P. F  F6 \* Y" L
  613.       itoken++;& X% W8 c9 x/ O3 q5 ?+ R# F
  614.     }! H3 P' b/ y1 d+ U- n" |
  615.   }
    8 h; W* G  l4 N1 s) s
  616.   return NULL;, c% `- V6 P# G8 `1 ^( ?
  617. }
    : Z  o+ {9 D( p
  618.   {1 w( i' j; P, P9 O4 e+ k' f
  619. void ProcessProc(long Total,long Current)& R' p  e' q  T! e4 j) p+ D; F
  620. {
    ) p- B3 p  f7 {$ Z
  621.         MSG msg;
    ) b/ m1 [6 z  ]; u/ K. ^
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);' V0 Y( o4 ]* k+ T/ N
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));3 |$ ^2 y* `3 N# I3 }; }
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))" [! a& K( A/ s" y
  625.         {
    . M6 n3 }+ q  A" {+ l- p% P
  626.                 if(!GetMessage(&msg,NULL,0,0))' Y+ e; K- D# a8 S
  627.                 {
    2 S# E5 o' o; y: R; C
  628.                         return;  W& M, O# o8 R( \! {5 n
  629.                 }
    $ [# p2 g& M7 `1 ?
  630.                 TranslateMessage(&msg);
      W! ^1 \) G( C% O7 K8 Z2 V& P
  631.                 DispatchMessage(&msg);( q6 w' y0 S" w+ P; G$ h! y: e
  632.         }       
    ; u1 H# f# M0 H8 G8 I" M( m' z
  633. }
    ! v- g& W: z2 `1 p( V5 F
  634. % ?) _. ^7 N, z4 Z  H
  635. BOOL bFirstChar=TRUE;5 C5 q, d' R3 w
  636. # X: T9 H6 j: t' B
  637. BOOL CRevAppApp::OnIdle(LONG lCount)
    * p' t- e7 V8 o8 Q* `9 L5 Y3 h( ~+ K
  638. {3 e3 y9 G' ~* k* |$ l( `( K
  639.         // TODO: Add your specialized code here and/or call the base class
    7 q9 W" O' s3 u; |3 c& Y. ?
  640.   switch(dwProgramState). J9 l% I- f) y+ e
  641.   {
    ' m- b3 l& x/ q& O) |& C
  642.   case AP_NOTHING:
    % f* t' O" B  `# x" G8 m
  643.     switch(dwStartUpSteps)
    # I- z% P* O( E, @5 e4 U. L) t0 D9 I
  644.     {, G# z) E4 H) m6 B, K
  645.     case 1:
    3 ~" k; [0 u0 i; }8 b( |& e5 V* }6 w
  646.       {$ w* Y3 r. X+ h7 T
  647.         int i;8 l- s9 ?5 d2 R2 @
  648.         CDC *pCDC=dlg->GetDC();
    4 e3 K- F: K3 a' I3 u! {
  649.         HDC hdcwnd=pCDC->m_hDC;1 w/ P' M+ U. n4 J/ Y$ V2 P
  650. //        Graphics graphics(hdcwnd);. k3 d; ?/ r7 Y9 \* g! G' G
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");" _( N+ p8 a9 f0 g( n
  652. //        INT iWidth=bitmap.GetWidth();
    & _0 z- h. e! D: q/ U
  653. //        INT iHeight=bitmap.GetHeight();. S/ [; x5 O- O1 V" t
  654. //        Color color,colorTemp;
    / m2 U, ^7 _; m  n# J% T
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)
    2 S% @6 S# @) y6 h7 U" I: o) ~
  656. //        {8 D; ^( L9 m: W% v3 e
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)8 C9 G' ~3 s9 M3 c
  658. //          {
    ; ~# v( b3 m, i; {
  659. //            bitmap.GetPixel(iColumn,iRow,&color);
    0 c* W; J' J, h# N3 c/ w
  660. //            colorTemp.SetValue(color.MakeARGB(
    ( u9 ~4 t7 K1 Q( O/ V
  661. //              (BYTE)(255*iColumn/iWidth),1 a1 z9 S6 f2 ~# p$ y: S- R' P
  662. //              color.GetRed(),
    ) e6 {* b; W" ^; T
  663. //              color.GetGreen(),
    3 a$ |, u. w% A) F1 u( S- v
  664. //              color.GetBlue()));" J0 Q/ `4 s, m9 v- G+ P
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);* W; \: p2 W& ?
  666. //          }" y: q/ R9 c4 m9 x
  667. //        }1 E% t7 v. j; W
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    ; k! [6 I4 Z9 C  M
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");9 Z+ u' y& U7 l: V& I
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    8 Z+ \: c5 d0 d  T
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");% N* s! d# @4 @% Z
  672.         for(i=0;i<240;i+=8)
    7 Q1 T1 m& j4 \: H7 |+ v. k1 h
  673.         {
    - l$ U" W1 h4 m* A9 {, e
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);7 ]: v5 p7 D" c7 y5 O, w7 S
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    : n8 c2 A% e1 O* j
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    ( t- |* V' [+ d8 u  B( n
  677.           Sleep(33);2 `8 C4 L) ]: o# X/ k5 b
  678.         }. O3 x6 z' G4 L9 ?5 V# b
  679.         Sleep(1000);1 W3 ^" \  |8 a; D4 {$ }. X
  680.         for(i=240;i>0;i-=8)
    / `7 v: K6 g" E  `, Z/ x4 ]6 @
  681.         {4 e+ B& _0 ~. W3 X. S
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    ' d/ R3 |( z7 T9 O+ q$ M
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);; b6 V3 s+ S8 z& d( F
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    - E" P/ x/ L8 k9 ]
  685.           Sleep(33);& w! R/ ?) S1 U6 C) N
  686.         }6 ]7 \, `9 L: Z. o5 y3 v
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
    + U; [- o  A/ T- @% R
  688.         dlg->ReleaseDC(pCDC);" a* b& \. ^  B$ I! s# |( }: p; U5 d
  689.         DeleteDC(hdctar);0 h! q8 y* D" B; m( \
  690.         DeleteDC(hdcsrc);+ [% M/ S8 c& C+ e: g+ z0 o# I
  691.         DeleteDC(hdcorg);8 E7 k( [$ W- _; W/ p
  692.       }: }$ L4 G; f0 W0 |# F
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);8 [  W9 o# h) v( R5 ?
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");( F* ]4 T- [; s/ h( o6 C( w8 G
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");' j' K6 s/ U0 Y2 E6 q5 X
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");; o( A/ z! Z  ^0 O4 D. z; Y5 B' w9 T
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);4 A$ U- @" e! [6 |
  698.       if(!Dn.Connected())0 o& z$ l, g7 O* ^: D
  699.       {  I4 ]7 _  ~( i+ @1 d3 I# W
  700.         dwTotalFiles=1;1 F3 A# U$ c9 q: L, V2 |
  701.         dwDownLoaded=0;' Y+ C, ~, `+ ]+ V* u5 ]  O" P
  702.         bSilentStep=TRUE;
    * ?% |% s" t$ p" a
  703.         bCompressed=FALSE;$ h3 e; K- \# O* _" K4 K; `
  704.         strExtLocal.Empty();+ a* U6 ?, I0 P, ^1 O: {
  705.         strFullName="readme.txt";
    5 \5 E1 _& Z9 ~9 l
  706.         dwProgramState=AP_CONNECT;9 F( T$ I9 K, G. Z7 U1 U: F: b
  707.       }
    , l5 [% t6 O: c) t+ R5 V( h2 P
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();
    ) j% k% l9 r4 Z$ v- m) B* {
  709.       dwStartUpSteps=2;3 l: ?! ?( k5 L) B
  710.       break;9 ?6 }- P) V+ A' p7 i3 |$ p
  711.     case 2:
    ' w( W& Q7 ~! P! a5 ~$ U
  712.       {6 R% s/ [0 O' \0 t
  713.         int iEOF;4 e, D/ h0 Q4 s
  714.         FILE *fp;. T' K" w8 w0 y1 x+ c0 |+ _* s# M) }
  715.         char szString[512];
    6 @- y$ ^0 X. \& o- z
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");6 Q# D+ f5 G8 X/ y8 E; Q0 c' a4 C, K
  717.         if(fp)
    & \  f; \1 v. @5 o/ L- j
  718.         {; ?, t; p& r5 R: z* {. F
  719.           do
    - v5 e/ ]/ m+ y8 x1 J7 }# W
  720.           {
    7 @( O( O: k& J% ^  K, a
  721.             iEOF=fscanf(fp,"%s",szString);
    ; p$ r, h2 Y% ?2 V& z  S
  722.             if(strlen(szString))1 x1 m5 r- p" D& q
  723.             {
    2 x1 Y8 c' n. Y# z3 [6 J+ o
  724.               if(bFirstChar)
    ( H- x# _. Z  _" n
  725.               {
    ' y# E$ X6 ~8 R) Y- L. J
  726.                 bFirstChar=FALSE;/ b  h  ?$ \  H' Z$ Q, T2 m
  727.                 bConnectIsBig5=FALSE;, ]/ _3 a: b6 u3 U0 H3 P, e  w
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;
    * a  R+ }6 A7 I6 G  Y
  729.               }5 I0 k# q4 k/ B. `3 d! p
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
    ; p2 u( p, |& P$ X$ g4 X; F& N9 v
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));
    , _) h5 T/ f) d0 g8 v4 X* K* y4 F
  732.               dlg->m_ListText.AddString(szString);
    " S- k( Q/ t1 A$ H! t1 g
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    , d# A" l: g$ f5 O) ~' w
  734.               *szString=0;( s# ~" f  F$ A9 g) ?% m# E* a
  735.             }& D$ s( B% F5 O
  736.           } while(iEOF!=EOF);- z4 K- m/ }: _. c2 r
  737.           fclose(fp);
    & n: ~; I, ?2 w3 K
  738.           unlink(".\\DownLoad\\readme.txt");$ q, F9 v! \9 t7 V; R
  739.           dwStartUpSteps=3;
    . r% F0 ~8 e; J3 `
  740.         }/ s; z" Q0 `' C# o& l
  741.       }0 o( {: L9 W/ V* _
  742.       break;
    " m, @8 `2 \( M7 |# y$ a  O
  743.     case 3:, {5 ^; y9 c+ i. t5 H
  744.       if(!Dn.Connected())' e" l! K8 F) E: e- P
  745.       {
    + d" d+ ?6 V: `. V0 ?1 D
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);+ V% P7 S7 @2 Z/ r
  747.         dwTotalFiles=1;
    3 H2 U7 O7 k. i6 h* ]
  748.         dwDownLoaded=0;
    + k( D' m4 \( S0 O
  749.         bSilentStep=TRUE;7 \( y$ ]7 C& E  }: S& Q/ R6 T
  750.         bCompressed=FALSE;
    4 W. [% D3 z0 E6 L( N8 t1 }
  751.         strExtLocal.Empty();
    # g9 ~6 D( `2 d9 }; Z
  752.         strFullName="checkversion.txt";6 m% @- E. J. ~4 S0 h% d
  753.         dwProgramState=AP_CONNECT;
    ; f1 w# Z% w6 `) ?( T9 F
  754.       }
    0 V4 m, a, R" s5 R. m' K
  755.       dwStartUpSteps=4;( \# q6 \5 L0 C% S2 f7 ~
  756.       break;! e4 [1 U& R: m+ |
  757.     case 4:
    8 m% A1 n: e' ~( S
  758.       {
    / ~! P) [6 j% M* M* V6 d2 G' Y
  759.         FILE *fp;
    : o: q8 N" e9 `0 g" _8 R% [' M
  760.         char szString1[128];
      B* d- T9 N- ~$ V  @& G- n- U
  761.         char szString2[128];
    * T+ u8 y" U! L8 [$ ~: _5 `4 p0 j
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    " Y0 L7 Z, A) k" K: d
  763.         if(fp)6 t7 M+ h' f8 }! D9 W/ ]/ e( @
  764.         {
    9 K  _/ r! V  y, O3 H
  765.           fscanf(fp,"%s",szString1);3 @9 ^( m8 {1 X8 |: b# K; I
  766.           fclose(fp);
    2 T: ?0 m$ R6 {' ^/ R
  767.           fCheckVersion=atof(szString1);
    ( K* t0 T3 {2 M9 [
  768.           fp=fopen(".\\checkversion.dat","r");
    $ t1 ^( v# p$ _; b$ w1 V3 i& E
  769.           if(fp)* f3 _+ [  |# t, W' w
  770.           {  @5 C" G4 u: G+ K+ l$ x
  771.             fscanf(fp,"%s",szString2);
    . o8 I* U; T( j
  772.             fclose(fp);
    % w4 {( Y0 a; c. V& P5 M
  773.             if(atof(szString1)!=atof(szString2))
    8 i! _% C; I$ L% t4 g
  774.             {
    , c- e+ E7 m4 C9 ^
  775.               if(!Dn.Connected())- h# C" X' q5 o! i9 I$ i- @0 d
  776.               {
    9 G0 m& z+ t& y4 N4 o; r, b
  777.                 bFirstUpdate=TRUE;5 H2 o0 ], |2 ^6 Z4 ^& t
  778.                 dwTotalFiles=1;5 h) J0 |3 f; f2 {
  779.                 dwDownLoaded=0;- D0 m( \0 X) a
  780.                 bSilentStep=FALSE;
    5 Y& W% B& s3 U  o( d6 ~. }
  781.                 bCompressed=TRUE;( F9 R8 [2 W- v, l, ?
  782.                 strExtLocal=".\\DownLoad\";$ y) v; [) N9 N% d& J1 L
  783.                 strFullName="update.txt";% ?7 W& H( {% u$ Z: E4 E7 H: l
  784.                 dwProgramState=AP_CONNECT;
    # I# }: ~: t% t3 D5 b4 j
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    8 m8 K) @- J& [3 t# f6 N" z
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");  h- @9 H; Q8 h
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");/ ~$ C. F9 C1 ^# N- b. R. v

  788. $ K- Z7 _& u/ n
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);& U1 O( t7 u6 u( h+ u* l: y
  790.                 unlink(".\\DownLoad\\checkversion.txt");% w3 a" a6 U! y
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)9 {! p  p1 O- t+ T- O" @
  792.                 {
    , k: D' D$ Z/ ~; Q; i
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");7 O, ]& t: D2 h3 a" C: P
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");
    ) J) ^0 h) \' L2 L, ]
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");( w* w) Z  h3 n9 m
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    $ X+ q8 d0 p% Y! ~1 e/ d
  797. : y& ^3 W# i( N: Y2 \  f8 p, {
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");1 Y7 q: G4 _! L& X7 J
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");  p4 x9 a+ A/ |+ f. i
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");' w+ u- j3 A) L5 V* V" q5 b
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    % P. Y! p0 x9 j) p# v) I
  802.                 }4 B% g8 M1 a6 l  L2 z+ l. f+ M
  803.                 dwStartUpSteps=5;1 Z/ H* }% `$ k; E6 a' P
  804.               }9 `6 i3 }; s; G+ t* u" `0 E
  805.             }! h$ d0 J, H+ v; M) {$ z" z
  806.             else
    7 `  B$ X" P) r2 b8 c6 M8 X9 }5 _
  807.             {2 q5 `" J7 P5 n
  808.               unlink(".\\DownLoad\\checkversion.txt");
    5 r' p- g9 k1 J" ?) B  d& g# g
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");  ^% F1 p) E1 x- g2 S& x, f* G! C
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    : X, o1 z7 n' ^2 Z5 K2 s9 a7 v
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");
    0 |0 l" I3 ^4 a" V

  812. 3 G/ |4 y4 ]  [; S
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);$ |4 J" B. q7 g$ Q$ Q: O* b: P! g
  814.               dwStartUpSteps=99;7 |! t6 L5 ]; n! x; x( @/ s6 C  b
  815.               bFinishUpdated=TRUE;4 N& K! C* I; e
  816.               bCanUpdate=TRUE;7 O7 R) ]/ b0 K; S3 q& B
  817.             }+ E# j& X0 G$ J- \" E% b* W0 n
  818.           }$ J2 R5 e+ ]( I* |1 }: u/ _7 m2 t/ j1 F# _2 `
  819.           else! k! H6 i, x; b5 X& U5 E' G" y
  820.           {
    1 f! A0 d( e3 z2 u6 u* i
  821.             if(!Dn.Connected())
    5 W  ~- g* @1 Z3 n
  822.             {6 K3 x, H7 }. S9 x5 u. A. Y7 l- ?
  823.               bFirstUpdate=TRUE;
    & S% E; w. l2 }' X9 L. x
  824.               dwTotalFiles=1;. t& V: [: G4 X% y
  825.               dwDownLoaded=0;2 P! H9 e8 E1 k: C% ]5 i/ R
  826.               bSilentStep=FALSE;$ z& s. l, f0 H! t3 f8 Y
  827.               bCompressed=TRUE;
    . s- _, \: z" `8 g: ^$ g
  828.               strExtLocal=".\\DownLoad\";- d- n# O# K% t
  829.               strFullName="update.txt";5 f0 _3 N. A  V2 }- Z' t$ a6 C
  830.               dwProgramState=AP_CONNECT;
    2 C9 Z" r) {2 G: X0 Z' [
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    . s5 }- Y3 Z1 u
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    - C  H" w7 A! [( J( h
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");
    - k( _% H5 V0 Y9 R; R0 ?) @  S/ Q
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);" S( q1 L# [# \$ h
  835.               unlink(".\\DownLoad\\checkversion.txt");
    ' b# `9 X0 l. N& ^+ [; y
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)
    . ~! C* V* x* X: e$ c. _0 y
  837.               {+ @0 }8 u$ S9 v- u% S% S
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");9 l: g! y2 D9 T+ y2 C: K' o; v
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");
    2 L8 l1 |* S9 X: D# u, y' h4 D+ @# E
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");' V' ?" O. G- m! \# u4 |
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    / |+ [" Q2 A; I, @5 }# p  D. E
  842.                
    - P: P2 }) f! ?1 [7 Z  i* m
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");: T! e/ \% K2 u+ U/ w% ?
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");  E; \" r2 O- }( f1 @2 j1 W
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");5 T# M0 X$ Q' `) z: K
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);' w2 k. k+ V6 r& o
  847.               }* {, L* u( R, K: G2 z
  848.               dwStartUpSteps=5;
    # |' f/ s2 {& R; a. x% h
  849.             }
    * |- z  d( u) L- [4 m
  850.           }
    6 w, N% g' w1 b8 [7 r/ T
  851.         }9 U" P9 n0 Q5 M4 M
  852.         else- H: S6 Q' P/ C* O
  853.         {
    ! r( h2 N( V9 w8 d) i: K+ A
  854.           dwStartUpSteps=3;0 @1 w- ]) [" p
  855.         }
    ' s& ~! k* @; A0 ?0 e& I4 j
  856.       }. Z7 S4 {# w( `3 b. J
  857.       break;! r; N' e& o* g% B+ a* ]
  858.     case 5:1 c7 G2 h) f* {6 E' _6 v) A; c5 |
  859.       {+ N& `6 t2 _: L& A1 D' j% _
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)$ v3 W" c2 h) I, V- N
  861.         {8 q( [! \; D" c: ~
  862.           int opt_overwrite=1;: O- v, o2 j7 ]0 @
  863.           int opt_do_extract_withoutpath=0;
    - \3 q% l+ ?  H, i4 j5 [
  864.           unzFile uf=NULL;
    * u5 H2 K: ]2 |# @
  865. " W5 I7 a2 ~3 z" m
  866.           uf=unzOpen("Wsa.zip");6 R' J. v$ h+ N
  867.           if(uf); m5 n3 e$ F7 w% z% V, b
  868.           {
    - h4 d# Y% L  L1 B% A# \! u' W
  869.             do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
    + A0 m4 |8 ~/ R- _) D
  870.             unzClose(uf);
    5 G' E4 S) F1 a2 R3 ?
  871.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃ЧΘ.....");
    0 z& b- V# s: R: t( s4 L& p
  872.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压完成.....");
    ' m# R2 ?$ p. P. x* \
  873.             else                                                      dlg->m_ListText.AddString("Unzip OK.....");
    & A! j- H2 ~6 W/ t
  874.                                           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    * r$ p2 f8 M9 r% ^8 m2 {& r. p
  875.           }
    & M9 c6 E8 h1 i' G3 h
  876.           DeleteFile("Wsa.zip" );$ f# L( |3 D; q# t' I/ ]5 @
  877.         }
    # E# h: c, K2 v. ~: [9 c

  878. % r: \  A1 K' p7 T, M1 [* o  Q( U9 `
  879.         if(CheckLocalVersion())" t) Z" u; y  ^5 Y, q
  880.         {
    * Q8 s* l6 m) \7 h
  881.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫磅︽絬穝戈.....");
    , J6 H% c4 {. N1 w/ {
  882.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请执行线上更新资料.....");
    * E& k- i- o3 y; F* x
  883.           else                                                      dlg->m_ListText.AddString("Please update.....");) g0 R% W1 ?" \0 O. |7 s
  884.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);; W1 s3 z% b- ~: b8 M% v
  885.           SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);
    . F, u, d, u5 V, O$ p. _6 d. e
  886.           dwStartUpSteps=99;
    - C: I/ B' n9 k, q9 ]) J1 R
  887.         }9 Q" J: M; o. [- J) L3 b/ M* C) ^
  888.         else
    8 J& [2 n! ]( @* l
  889.         {
    & L$ O. L6 M; ?( b$ g) E9 k! Z
  890.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");& c. i. Z/ D! o2 k1 h$ f; ?; k
  891.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");5 X" W3 C1 N7 c
  892.           else                                                      dlg->m_ListText.AddString("no new file update.....");( t, ?4 B6 ^- N2 M$ |2 I

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

5 J5 W+ G% b2 w# }  @

評分

參與人數 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 來自手機 | 顯示全部樓層
东西不错,只是现在研究的人少了。wechat:lang_wechat_threadmessage
回復

使用道具 舉報

寂寞在_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
回復

使用道具 舉報

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

本版積分規則

QQ|Archiver|Mobile|Disable|About|Facebook|Discord|叛逆家族論壇

GMT+8, 2026-2-13 08:38

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表