找回密碼
 立即注册

CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閱讀模式
% `4 Y" o' W7 M- E% `, p* d, d( @
  1. / RevApp.cpp : Defines the class behaviors for the application.' b5 m+ ^, X+ l6 e
  2. //& I1 p$ z7 M0 g4 v

  3. 5 {, C  F! F) ]3 ^
  4. #include "stdafx.h"
    6 l: h( L' M1 L7 N( C

  5. . |5 w8 e2 ^( {) Q' n: s) o4 Y
  6. //#define UNICODE* A) z8 T8 s- ^3 c! u
  7. //#include <gdiplus.h>
    , c1 r" Z7 _+ J' I( k, ^' i
  8. //using namespace Gdiplus;
    6 H7 T( Y: W: U: U

  9. . U* N4 Z5 z$ ?+ L/ }' x8 b3 K& [
  10. #include "RevApp.h"
    : d* ]( q5 o! m0 r
  11. #include "RevAppDlg.h"+ u! Y% l& X6 r! J5 k; L$ U7 f
  12. 2 x% n: o8 [, n) Q0 X) O- p3 @1 d) L/ W
  13. #pragma warning(disable:4786)% y/ a( P/ Z3 A7 P: Z2 W
  14. #include <map>3 z6 E3 q, v  ^  `& x
  15. #include <list>( H% z) y3 @3 Q2 |7 n
  16. #include <direct.h>& {! T' C% ?  ]& J1 Y$ a2 y

  17. " W0 }4 j( K( D$ b; W
  18. #ifdef _DEBUG
    # x& }$ p0 P6 Q- B- o# p7 E7 i8 [6 Y
  19. #define new DEBUG_NEW
    0 X& E  }" H3 ^  Q8 h* [- w
  20. #undef THIS_FILE
    & H  s- f  Z! e( e2 E, t/ p0 D
  21. static char THIS_FILE[] = __FILE__;5 ~% O. E! l! _1 K2 j
  22. #endif3 B( c5 @% W2 j9 D  W6 i4 h0 T) k
  23. #include "SkinResDef.h"
    * |1 ^# R: {: G( a+ F# W
  24. #include "ChangeBG.h"# a: ?: b8 B) K, ^2 ]0 o
  25. #include "AFXINET.H"
    9 F! H; A* Q: Y$ H7 d) v

  26. $ U: N' _1 ?% n
  27. #define TRADITIONAL_CHINESE 0# ?. t, x; ~+ {" z  y2 s/ |7 Y
  28. #define SIMPLIFY_CHINESE 1
    : B( [& G, G& j4 T
  29. #define ENGLISH 2& [5 f3 g$ c) N& N+ S9 e  Z
  30. int m_iLanguage = ENGLISH;( @, }! u7 J; x3 ?( j$ Q. f# E# g
  31. /////////////////////////////////////////////////////////////////////////////
    8 a8 t# E; d+ g' s  l; d
  32. // CRevAppApp
    + c+ g& k* J% W+ O
  33. 2 R& Z/ [! a$ F; ^
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    # Y  P2 g) m: {  L/ M0 g
  35.         //{{AFX_MSG_MAP(CRevAppApp)7 O, @! R" b) L$ s2 ]
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.3 U  Z" \* }  F6 K
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!
    ; x& h1 t& S4 t# _% x3 J( V
  38.         //}}AFX_MSG$ h3 P! ~8 N" a( G, e6 g, [$ r3 r
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)" W7 ]5 [; W, _& o, R8 R
  40. END_MESSAGE_MAP(), c+ K* f; O5 d7 d
  41. 2 i' k5 ~8 q7 I% t7 k6 u, }" Z
  42. /////////////////////////////////////////////////////////////////////////////6 E$ D& m7 g* P% G( J
  43. // CRevAppApp construction3 b# I$ B0 d  B! i) g& r( g

  44. , d0 O5 A8 S" x7 M- S* t$ J
  45. CRevAppApp::CRevAppApp()
    " m; b* D0 S: N
  46. {6 j2 @2 E) g( v$ k, o+ }+ f
  47.         // TODO: add construction code here,# H- P  r! Q: o$ \. ]
  48.         // Place all significant initialization in InitInstance' o3 W" E) t2 i1 Z
  49.   bDisplayIsBig5=FALSE;6 g) o  d; O9 D
  50.   bRestartUpdater=FALSE;
      a* L1 f4 `5 W. I
  51.   bFinishUpdated=FALSE;
    2 o6 ]6 t8 a% j9 M3 {' s8 i+ z
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;1 y8 C- {1 p- W! A# {9 D, e
  53.   InitChangeDataBig52GBKS();7 u1 C/ ]) E  e, M% d$ f- u; \
  54.   InitChangeDataGBKS2Big5();1 ~( c+ {" o8 T) J+ a/ O
  55.         //
    ; I: U8 `5 H9 m$ m9 K& E
  56.         bClickRunExe = FALSE;( G; E/ V, ?: s
  57.         //
    . e% o' F2 [5 V" D
  58. }
    - h( H% ~2 T+ V$ @4 E
  59. . [, O' l- }0 k
  60. CRevAppApp::~CRevAppApp()7 [5 d5 d1 v! D, t6 H+ E; m7 p
  61. {
    4 F& g& G- J/ K. E0 t6 i
  62.         // TODO: add construction code here,
    0 b( F: h. e* L& z7 c
  63.         // Place all significant initialization in InitInstance
    9 z  N; c/ |; u- D, q/ c+ [
  64.   EndChangeData();
    " ?8 p) U% m% W# A* t
  65. }# D0 L( V5 F7 n8 Q, Y3 M/ f
  66. # r( Y' Y6 o% G; ~4 O% R' M+ f
  67. /////////////////////////////////////////////////////////////////////////////" {0 f- N0 A, G. O6 s% [5 i; W
  68. // The one and only CRevAppApp object
    / a1 d# T! J- U

  69. ' `1 B% b8 e% b7 }
  70. CRevAppApp theApp;) S1 S5 D3 X+ Z3 W

  71. : l7 |9 ]# s! \' G7 K# y$ i/ C4 a& x( Z
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)
    5 A# T. G; B" j
  73. {
    7 W( e, j0 ?% W3 V- o; l, @
  74.   int iEOF=0;# `$ \9 l* Z2 v  j1 G) `
  75.   char szTempName[MAX_PATH];
    6 R8 Y+ k" u! f7 s& m# _+ N
  76.   *szFileName=0;
    # A8 }+ N$ Y/ M( F2 O( a( T$ H1 @
  77.   iEOF=fscanf(fp,"%s",szTempName);# [5 @& m1 Z% B
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    : y. z# |0 ?! P. W# L  b
  79.   {
    6 h5 e0 d4 {/ p* ^0 B( s: Y* U: E+ J
  80.     strcpy(szFileName,&szTempName[1]);
    . q5 L! ^" b5 I1 L
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    8 l8 O4 p+ K' u( H7 I; O; l/ f9 o) N, I4 T
  82.     {4 `% T2 L2 n* x, d
  83.       iEOF=fscanf(fp,"%s",szTempName);
    " r8 I+ p, w. d, [8 @3 k, C
  84.       strcat(szFileName," ");' G$ E0 x2 e" A3 y$ Y  h4 W( k) Y
  85.       strcat(szFileName,szTempName);7 Z9 V: b0 }' t# B3 q
  86.     }
    . K' m. s% j! @% E, c. w
  87.     if(strlen(szFileName)>=1)
    : [! ]' L' F% d' Q( R& S  O
  88.     {* [. A( i% m+ m, U7 M3 @
  89.       szFileName[strlen(szFileName)-1]=0;& r+ X: @$ y0 v, m9 k; f
  90.     }1 ?' r6 B, T- `1 E$ |
  91.   }1 N' p! T* B* r. W
  92.   return szFileName;
    4 l) O$ p2 U4 j6 b& v4 ~
  93. }
    9 h. V9 `, D0 U# D

  94. ! x1 Z9 l. j3 h2 i
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    , i0 l4 C0 d# c# H
  96. {5 L9 U9 J- U- a* R2 r7 v
  97.   FILE *fp;2 j! Q5 d; f# l2 h9 _7 K: h
  98.   char *key=NULL;
    ( O3 f' U- s' \' {3 j9 v; w
  99.   char version[MAX_PATH];
    + C. x% M. M' s( \  y
  100.   LPUPDATEFILE file,olds;4 F# J  E7 @; O$ u6 c% C
  101.   std::map<CString,LPUPDATEFILE>::iterator p;
    $ p; H0 j$ b( \9 Y/ K* f3 r

  102.   V- j9 D& H, T8 }+ U- ?% G  D$ e
  103.   UpdateList.clear();
    8 H9 F4 Q. t: h
  104.   UpdateFile.clear();
    $ t2 z% \) c7 D2 x
  105.   if(GetFileAttributes(filename)==-1) return false;
    3 z8 R  o" d& i% [8 L% J
  106.   if(!(fp=fopen(filename,"r"))) return false;& {  y' g9 |/ z* y
  107.   fscanf(fp,"%s",version);
    6 A5 A3 o  S+ i/ K5 O2 N" B: H
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }. C) U. u  I1 z$ Z5 u
  109.   while(fscanf(fp,"%s",version)!=EOF)* I, R5 J+ e, x( r
  110.   {
    - e1 S& m& f3 }4 E
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));* A. z" l; |+ |3 X) |6 p
  112.     fscanf(fp,"%s",file->path);8 W" Z( X, }8 T$ z) h( l0 G  i
  113.     ReadFileNames(fp,file->file);+ p4 p. M" E* p. j4 N0 Q
  114.     strcpy(file->full,".");% ^$ V, r- ]- k$ L
  115.     strcat(file->full,file->path);; |* q1 V# f7 e3 T
  116.     strcat(file->full,file->file);  B' O7 A% o. i6 X' K
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())3 u5 u+ M  F& @! n% c: _" Z
  118.     {
    3 o( |0 h' p; V1 K( B- p. X
  119.       file->vers=(float)atof(version);
    ; z) }- b. z. [/ I" p* q: K2 u
  120.       UpdateList.push_back(file->full);. u' o4 k" y5 k. W- ?
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
    # Y* X5 Q7 L6 }3 b
  122.     }* |4 F: s6 j; u* ~* V" V2 z
  123.     else
    ( H$ R, s0 e( C, S$ C! p, W# d
  124.     {
    0 B0 s- q/ k; T9 _# a
  125.       olds=(*p).second;- q8 B8 c- U# S/ j
  126.       if(olds->vers<(float)atof(version))
      d+ |- r, V3 s4 _) ]; U
  127.       {  ~- z/ E' R" x  d$ v
  128.         olds->vers=(float)atof(version);
    . P3 w) @/ M  a
  129.       }
    . U2 @- t1 G3 O  Y
  130.       free(file);
    7 O! g! Z2 Q' j& f% X& y( j) @
  131.     }
    % i! ^% y, `( C
  132.   }
    9 i# P/ S4 }0 e$ _' G
  133.   fclose(fp);
    " o; l& w- e8 J5 G: _5 x
  134.   return true;+ d: M3 L! F0 J; n0 C6 P& ^
  135. }
    6 D! B9 n) ~) O

  136. ) |' a, T8 E2 @9 N1 O
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)
    - l& x# m- ^- ^5 p! ~0 _
  138. {
    ; d# h/ C9 `8 F  g7 k. O
  139.   TCHAR  szFull[MAX_PATH];
    % R3 G8 P, T. Q
  140.   TCHAR *token,*inter;
    " J- c  D! q# D* W, d6 V( Q9 V
  141.   *szPath=0;+ H) Z: O& ~, \2 Q* V' U) C
  142.   strcpy(szFull,szFullPath);2 w: K3 J: l2 H: i# x& Z* G$ _
  143.   token=strtok(szFull,"\\/");
    4 k2 ^2 @, X; t) S9 Z$ o" V
  144.   inter=token;
    * }7 n4 k5 X+ H+ e! d8 I% B% i
  145.   while(token=strtok(NULL,"\\/"))
    - ]/ a, W+ g3 H
  146.   {
    ( |. j/ L$ M/ Q/ p3 V
  147.     strcat(szPath,inter);
    . O& D9 E/ r( ?( |4 H- J
  148.     strcat(szPath,"\");
    - Y" @! t  h% q! k
  149.     inter=token;7 v5 `6 {1 N. j
  150.   }
    6 Y4 b# n  d0 T# E) l9 R& s$ j
  151.   return strlen(szPath);  _2 P: W. [2 q. Q, _2 E! v/ Y
  152. }
    3 C3 A1 B0 k$ t  P. M! F: l: w

  153. 1 G/ y3 u8 ~( {: f1 n
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)) S, B, j; Z3 q2 Y: n  x, c5 d
  155. {
    & O, x  i% E5 q
  156.   DWORD attrib=GetFileAttributes(Target);
    : i( b& |, v) O5 f) W* J- V
  157.   if(attrib!=-1), M0 D4 Q/ l9 D2 q$ Q
  158.   {. c' j+ y0 z; q! n+ y8 s  l
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    0 i, v, c1 d. T1 A
  160.     {0 n" d1 j' J" t. ]' j$ s9 J
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);
    9 O: b# z# N- E  V; ?6 [
  162.       SetFileAttributes(Target,attrib);: T( g$ M# Q& L! r! p2 S) z
  163.     }" b) U. ^5 _  n' C" f5 a
  164.   }
    $ V$ F  Z1 p4 G0 a+ ?* k0 L0 A
  165.   CopyFile(Source,Target,Erase);
    9 \9 K# O6 [# Z2 x3 I& e, |* ]
  166. }
    & m% A  b: p1 X" j

  167. 8 G' s1 c+ ?! e: i1 s5 |4 G9 x
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)
    1 h/ e) E  t) b: ?7 U" l* V' s+ f
  169. {
    4 o' R! {: n! o( p, D0 y
  170.      FILE *fp;
    7 t) ]: o% g( {- [) b5 p
  171.      char  szBuffer[8192];) Q2 _  y- v' [. X/ A! {3 h
  172.   va_list  argptr;
    * w* P- _  R6 S  U
  173. 1 t" n% j- q; Q$ l- o, X% P4 a
  174.         va_start(argptr,message);8 m1 Q$ U3 R9 z. t; P# q- X+ s
  175.         vsprintf(szBuffer,message,argptr);
    0 `7 X9 P, j' _
  176.         va_end(argptr);! j8 U1 l1 Y2 L3 Z/ z% G0 g
  177.   fp=fopen(FileName,"a");
    2 B: u7 b3 V- H
  178.   if(fp)- _3 U" T( w" i$ N
  179.   {
    ! `% r$ `4 c; [
  180.     fprintf(fp,szBuffer);
    ) Q$ b3 W  E) {% @! K
  181.     fclose(fp);
    # f0 s$ @. B; J* h' E3 Q
  182.           _flushall();
    ; W* x6 p& ], W
  183.   }6 f: Y) X: @$ P& _
  184. }
    0 y, U& B$ M% {5 Z  I# R
  185. + R$ @9 I6 T/ D, k9 Q( d) w: O+ B
  186. BOOL CRevAppApp::Fclearf(char *FileName)" u2 r8 ?( ]9 h, A5 K
  187. {
    ! M* |  H2 |; h
  188.      FILE *fp;/ [+ G* L; u* N0 V0 g6 V* v
  189.     DWORD  attrib;
    3 @4 L: H, t8 R7 w, d4 w' r& g9 G
  190.   attrib=GetFileAttributes(FileName);
    7 X2 ^( }; R; T8 q( M7 r& u  B
  191.   if(attrib!=-1)
    * Q* j& |5 o% @8 m
  192.   {
    . k- }0 i$ ~' [
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);* W8 {- \0 t* s* D! q
  194.     if(!SetFileAttributes(FileName,attrib))6 @4 G: [: X3 M; ~1 t
  195.     {# Y; h; o3 v( y7 R6 Y" [, i
  196.       return FALSE;( c$ l# d4 G5 B
  197.     }6 [+ N. u' e! w# t. g- o" @
  198.   }! C& U0 D7 v; n1 `, h9 ^
  199.   fp=fopen(FileName,"wb");
    & W7 }! s) t7 {
  200.   if(fp)
    6 O4 K0 p3 L) M& U* W) T, U
  201.   {7 g9 s5 _9 [- I7 L8 C% e
  202.     fclose(fp);' i2 ]1 G& X( _  M: o6 l$ F
  203.   }
    1 |. ~. k: E, n5 h
  204.   return TRUE;, p0 ?5 ?% j! ?& m$ J# c) M1 P: h% t
  205. }- j% e  m* t+ q) T, T: m$ X: C

  206. * `; L. l6 o9 J! Q
  207. BOOL CRevAppApp::UpdateLocalVersion(void)
    3 R% j2 ^1 i! q
  208. {9 ^& N& y/ l( }! k' F( s% ~
  209.   char filename[MAX_PATH];" k; e7 J& j+ h1 I( \6 |' A
  210.   LPUPDATEFILE file,olds;, L2 @5 e0 G6 ?1 v, O' N
  211.   std::map<int,CString>::iterator i;1 t% W5 t+ O6 ~! i
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    0 G6 P: d' x- [# `2 V! y5 |
  213.   std::list<CString>::iterator l;
    % T. Z  M+ I( e, N' L* d

  214. " J4 \; H8 t* q( K
  215.   if(bFirstUpdate)
    % O6 J+ I6 @3 A  @) R
  216.   {
    % h/ ^( V- d, W- h, u, b
  217.     dwCurrFile=0;" }3 \7 j$ U1 n" U
  218.     bFirstUpdate=FALSE;( ?  G3 u& Z1 q' e
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())
    ' ~$ P$ D+ ?0 f3 A- I' D) V
  220.     {
    ' f# ]6 b3 B* R% ^
  221.       dwTotalFiles=UpdateLocal.size();# Y. E6 Q, K2 s. n* y
  222.       dwDownLoaded=0;! K/ W3 Q% l" w+ a% S
  223.       bSilentStep=FALSE;; U0 x7 r# p) N( g% V+ i) k
  224.       bCompressed=TRUE;
    8 W5 z$ X8 O, O% f) H( [
  225.       strExtLocal.Empty();
    3 |+ f, A3 ]$ J! ?! a6 t* D
  226.       strFullName=(*i).second;# E0 ]5 ?0 V( [  z
  227.       dwProgramState=AP_CONNECT;8 G4 F3 ]) H) x4 P7 c. g* t
  228.       return TRUE;8 K$ l% G4 a$ f3 r  ]5 J
  229.     }
    ! {5 y) Y4 B) M7 Y& a* P" r: ?9 r
  230.   }
    * Y, b8 s* p$ V' b/ ^1 r9 c% V% [
  231.   else if(bRestartUpdater==FALSE)( v( d& t  b2 Q( r6 a
  232.   {# p) {1 I7 ?1 \" b. W
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())8 \) \! @; i$ K' V& O$ l$ e
  234.     {& z( c; N3 U' \( D: f% t
  235.       file=(*p).second;" T/ E8 a2 `- |) P/ S
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())8 p, J1 A2 Y5 D/ r5 Q5 W% f; n
  237.       {- b  T/ p: I* D1 _  V$ W
  238.         olds=(*p).second;8 c+ C! ]" g( Q. y: X
  239.         olds->vers=file->vers;
    ) X1 |& `5 y1 _5 Z
  240.       }
    3 q2 R% h& }5 \/ p
  241.       else
    # b! V  \" |5 E- i! X
  242.       {' {7 J, q+ D) o8 W% \+ y1 b6 {# x
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    8 r3 l9 u* ^8 ?3 ^
  244.         memcpy(olds,file,sizeof(UPDATEFILE));
    , t$ P  z' _& P7 A# b5 ?
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
    9 I" g& f8 h/ ?" A" [
  246.       }# L7 `; |; X( {% M
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");
    6 ]: s" e! H% J' I0 n! ~
  248.       sprintf(filename,"(%s)",file->file);
    + O4 s' h# V  k4 @& |, z
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    $ h" S7 Y3 K, S) @
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }
    2 C$ U3 |  H% G& K7 S+ i! r0 i$ I
  251.     }
    / ^" @3 u" P, f' S: D
  252.     dwCurrFile++;9 [) F: a! P# L% t4 u1 v  y
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())% C; G8 U. ]" b% `. u
  254.     {
    , `$ ]' F1 b# c: ^# F! W
  255.       bSilentStep=FALSE;
    ! H5 p- r/ H; ^
  256.       bCompressed=TRUE;3 ?. K& g4 Z$ ?- t
  257.       strExtLocal.Empty();
    * U" |) |5 o8 Q/ K: ?
  258.       strFullName=(*i).second;) D4 z; ?) O( M) n& @' x
  259.       dwProgramState=AP_CONNECT;
    ; j& V. z& K: s, L4 \- G4 B: p
  260.       return TRUE;
    + x- F* D8 p; P0 }3 W- u" [4 X
  261.     }
    ' ~" l( |- ?/ q
  262.     if(!bRestartUpdater)) @7 y1 W: ]! u6 l# p
  263.     {6 J$ ?# S* ~- Z2 S2 z+ w/ m  Y* @
  264.       int iCurrSize,iFileSize;
    % F: G: b0 y" U
  265.       iCurrSize=0;
    - ~4 K# B7 `: k7 t
  266.       iFileSize=UpdateList2.size();
    2 O) j5 o$ u7 t4 C) s
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");* J4 ?$ }. e% V' `, ?
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");$ w# k5 J) M& w7 F5 c# ]- d
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");
    & |9 x: B+ P3 }2 \- v/ J3 y, U
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    & N4 Y+ Y2 x* I5 i: f, x9 i
  271.       Fclearf(".\\update.dat");
    * H9 K+ Q+ ^& k: b$ \& @
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    $ U1 e0 F6 h( P# g2 L& f* u
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)
    % {1 d$ I6 b* t/ l" m+ D0 X5 J
  274.       {" C7 k3 o1 g5 O
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())$ A( y* g; G" @2 Q* P
  276.         {
    4 b$ h/ M- I' r  @9 X4 C
  277.           file=(*p).second;, q( {' T! z! O! p  R
  278.           sprintf(filename,"(%s)",file->file);6 a) E( m& u, Z. S+ H
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    7 F7 v8 q6 F! F+ h! p# ?
  280.           iCurrSize++;: e% O5 L7 O0 V) J% ?: ~0 c
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));5 ]0 l3 w9 ^$ d7 z
  282.         }
    3 U1 k/ o9 y( u8 e. g  K
  283.       }/ n4 M% f! @0 I& ^2 p0 h
  284.       unlink(".\\update.txt");
    , c& }4 A# ~) Z; a
  285.       unlink(".\\update.tmp");
    . v- O1 f* w: P+ S: Z" c5 i
  286.       Fclearf(".\\checkversion.dat");6 x* R9 X4 J' d4 W. z1 c
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);( U3 ^) P9 j0 @1 P4 |; M6 _: q
  288.       if(UpdateLocal.size())/ r+ ~8 A7 H) c) J. o
  289.       {$ J2 u" V' X2 ~5 B  @; z  y0 H* |
  290.         UpdateLocal.clear();
    8 m3 t. u9 p: Q  T
  291.       }; _1 S$ O  W8 }) c2 I) R( k$ D
  292.       if(UpdateFile3.size())# l) }# K- C" Y% H* A
  293.       {. m$ }9 l1 U% T5 B
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
    1 k  s9 w! a2 E4 J+ S# ^
  295.         {
    9 v+ ^: B9 I3 j5 g1 C0 w( Y
  296.           file=(*p).second;7 v4 F; Y( d5 x% q; U
  297.           free(file);
    3 X% @3 D* q7 E3 a$ I5 C. K
  298.         }: S+ I# o. N( j. S
  299.         UpdateFile3.clear();6 s% L9 b% U, Z; D8 N0 K$ d
  300.         UpdateList3.clear();! P# |, U: h% }8 u: T
  301.       }
    ! ]! Y7 S4 P; U* p  ?% t. H7 t
  302.       if(UpdateFile2.size())0 S* J9 ?! A5 O: v
  303.       {  ^7 O/ J0 S1 t; P8 K  e$ Y2 ~$ a
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    2 Z6 X' r# Z0 `$ m7 X2 f
  305.         {2 g) n! h) f4 Z- J$ v. N( u
  306.           file=(*p).second;( |- S# D9 s' |- `2 G+ K
  307.           free(file);) M$ @: ?5 b. c/ }8 ~: }+ n  g/ L
  308.         }7 B0 I7 G1 z; l' n
  309.         UpdateFile2.clear();
    1 l5 R' }4 P6 P0 R0 q& z
  310.         UpdateList2.clear();0 a6 r- k0 ^& @1 r3 z
  311.       }
    ) s  u; {0 \! M) x7 O
  312.       if(UpdateFile1.size())  J& P! e- Y- ]8 m: E
  313.       {
    ; @0 W, \/ U/ r$ \8 @. @7 j
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    " c2 e6 B, a: r  j
  315.         {
    3 f8 J5 O& C8 _- w1 D  d: L* G
  316.           file=(*p).second;
    ! K4 C% E( z; ?, _. w6 D! N9 x
  317.           free(file);* J* c  t1 l* Y) L1 [: s+ x
  318.         }% g5 o, ^  O- v, j. H
  319.         UpdateFile1.clear();
    7 H3 V% O; n3 j: j! E, ]
  320.         UpdateList1.clear();' g) Y# w. Z  e% c" \4 g: @4 [: @, |
  321.       }
    ! ?* A$ J6 y3 o# R* Y
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));8 J% A' I  A- e% W! Z2 i$ ?( w
  323.     }" z% Q3 P; r: d6 e) q# c
  324.   }
      c+ N$ {# D) n& a5 `
  325.   return FALSE;
    9 Z# E7 |9 W) @& Q7 g5 X3 H
  326. }
    % M4 f5 G# `( [2 o6 T" u! N9 e

  327. 0 t. J0 `& C! _. A; l
  328. void CRevAppApp::ClearAll(void)
    9 Z# \( q6 [% k
  329. {
    4 G" E" g0 m6 R5 N
  330.   LPUPDATEFILE file;3 X9 }: n- [9 |5 L( p0 v2 x
  331.   std::map<CString,LPUPDATEFILE>::iterator p;
    ( E8 L# k- t. E7 P6 _5 m

  332. 7 [+ @$ E* X3 g" B# g2 L3 ~  K
  333.   if(UpdateLocal.size())
    " M. S$ N9 T; s1 G5 d, W
  334.   {
    5 m7 U3 Y' A8 `' i
  335.     UpdateLocal.clear();- \& X. k6 r% J! W0 r, a8 T; [
  336.   }' Y- q% \. t3 t, g
  337.   if(UpdateFile3.size())7 A2 C! H. P8 v# P2 a  c. _
  338.   {
    0 P* t/ z7 u) z- R
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
    # S- i5 G9 {' `' n
  340.     {
    4 {( E- R) ]( p: G/ Q
  341.       file=(*p).second;% s0 i; }0 w4 ~
  342.       free(file);
    ! v" ~# D* i1 s1 y1 M1 ]6 p
  343.     }
    - g2 B& G# s8 r5 H: M1 u5 i
  344.     UpdateFile3.clear();
    1 |$ k0 H4 V7 ]8 w! ~& {
  345.     UpdateList3.clear();
    5 {: D# n' [! q6 q2 E6 X
  346.   }; g* f0 Z' d. A# i* R
  347.   if(UpdateFile2.size())
    7 L* Y- S8 y" z, F- q; S, T
  348.   {
    $ Z- U( J  I6 w/ P
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    1 v9 A' ?1 U2 K  U" }
  350.     {
    3 J; l- H4 L! Z- v; g
  351.       file=(*p).second;
    5 g: G8 B: d5 [9 n/ M/ B
  352.       free(file);3 e8 D' N& {/ S- ?
  353.     }  d  c2 @$ g) q2 }- O: j5 V
  354.     UpdateFile2.clear();) I% }9 o7 v( t4 N3 ~( u
  355.     UpdateList2.clear();
    $ D/ `6 n7 \9 S+ u
  356.   }5 ^! m3 P/ c( T: k. n
  357.   if(UpdateFile1.size())  u1 A, [+ B5 N* L! b8 Y' G
  358.   {. s% ]; {  F% H7 x
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
      ?0 K2 w2 b$ z3 P$ G, Y9 r! d! H
  360.     {& ^6 m, ?. }" z5 Q' U: U4 b
  361.       file=(*p).second;% f/ l) h1 n6 Q* n
  362.       free(file);
    8 G. m+ [( N6 ~+ O4 y. w
  363.     }
      l1 I4 t2 M4 i6 U
  364.     UpdateFile1.clear();
    3 r* T% }' y2 U' I' L; ?
  365.     UpdateList1.clear();
    / f" o- `! ^$ e
  366.   }( S2 I# e, m5 ^8 S
  367. }  % D5 o5 ?3 T0 m! l: I
  368.   ' ]! p4 c7 Z8 h) a2 ?
  369. BOOL CRevAppApp::CheckLocalVersion(void)
    * D4 l6 ~& v( ]/ W
  370. {0 q6 K" r/ O; x. I
  371.   int c;
    $ v& c( y" i) X9 h0 L
  372.   LPUPDATEFILE file1,file2;
    / H7 q2 Y# j  G! F# G, ~3 w
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    3 a* b& D) p% m. O4 t7 I6 |3 w
  374.   std::list<CString>::iterator l;# k) y* s+ ^4 E0 p8 B
  375. 6 g1 {) X8 ^6 n3 n, A# T+ G+ J; [- d
  376.   UpdateLocal.clear();  O/ q/ }3 [: Q
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);. }- i& V$ @1 b7 Z5 n% j* n4 {" [
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);6 l$ \% E2 Z; ^' d  v
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);- b/ u8 M( Y0 Q! h1 }7 S% t8 e
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    ( o1 v. Y# b: O4 q2 r+ t
  381.   if(UpdateFile3.size())8 C& f, c1 }" Z* J, |: V' J
  382.   {
    6 f. {; d. F5 R( |4 s3 ?
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)
    * |! I6 q5 [3 @( w& [& p$ P
  384.     {( Y% r0 `! X3 q$ ^/ z
  385.       file2=(LPUPDATEFILE)(*i).second;( H5 H- M# V: G$ O$ Q
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
    5 w- Q( \" q3 H6 F
  387.       {
    7 R0 b( y; s. W& v7 z
  388.         file1=(LPUPDATEFILE)(*p).second;
    8 T! k! c, a* G0 W. D
  389.         file1->vers=file2->vers;
    4 P# i8 d' ~5 ]+ ^; N" e- b) x% V
  390.       }
    5 ^: L6 J4 p4 n4 w% b4 C
  391.       else
    - W5 O( P1 G8 k( Z5 `
  392.       {! U* A1 e2 m% n) W. F
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    3 p0 E/ [5 V1 s5 }
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));
    / M9 h8 R- a- s
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
    9 `! S% H+ J) v$ i) T
  396.       }, O" q4 s, A; h7 y
  397.     }4 }3 {9 t  f' D6 l* m5 `
  398.   }
    * W" T5 P4 m( i! S  r
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    1 O1 t- m: `# w" `9 e4 L4 {6 j
  400.   {
    % I' w* v. W- g
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())! t# y2 |, K6 u; \5 ^4 I+ s
  402.     {
    1 i& P+ y) P5 T  f" Y, W: Q
  403.       file2=(LPUPDATEFILE)(*i).second;( F5 t3 _, F! U
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end()), [8 f4 v' d7 C
  405.       {. }3 }3 }/ D4 k6 x6 l
  406.         file1=(LPUPDATEFILE)(*p).second;: X( E% f! M1 N
  407.         if(file1->vers!=file2->vers)
    1 R) k" b' J: `* C' I( D. {
  408.         {1 A$ K+ c6 Z$ L* {- u$ g
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    , ^0 x7 e3 L' r9 b0 y1 ?
  410.           c++;' o+ m, w8 S. i% G  u
  411.         }
    ; i7 u+ ?4 |" S6 ]1 f) f  a+ Y
  412.       }
    / [& H6 |3 A5 \. `
  413.       else
    1 x# {3 O. C6 K1 x7 Y  A: t' W; e3 Y
  414.       {
    ; U9 q( K( _2 n+ }0 E+ o" G
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    ! x# v. J& @; W5 Z2 o
  416.         c++;
    - E2 g8 e2 S! ~2 f( C! o% [
  417.       }
    $ F1 p% L' n+ N3 R! {' K
  418.     }
    ! h. R' B: u* I7 s# i( L
  419.   }
    + t$ |& J8 ]( ^' }2 ]1 o, j& V
  420.   unlink(".\\DownLoad\\update.txt");
    5 n8 N- @8 O3 m+ k+ ]+ M
  421.   if(UpdateLocal.size()) return TRUE;) D# v: ]) J9 Y& m+ B
  422.   else                   return FALSE;
    , [9 _. w/ I; p' G" r; F
  423. }
    / n8 N* A) _, g8 O
  424. * I+ F. b" E8 W3 y1 q" D0 J
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"/ @8 R/ N3 Z' t! M3 i4 t8 L' b4 [
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"
    2 f/ ~) X) j; x8 o6 o$ C
  427. % Q, Z0 B9 I: i" c( u- T

  428. $ k: w$ r5 h. z* Z1 b* t- B

  429. 4 C6 G3 O; P( b8 X
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)
    , F" d, O0 f  y  S
  431. {. X% |/ U' d; u5 O) E
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;
    7 B0 O1 b% X, M: w" e
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1): Y3 r7 b& j, q  G+ Q+ Z
  434.   {1 p2 J# u6 y$ v) Y) ^0 I, \, A& Q7 _
  435.     char szLanguage[50];
    0 y, y& b! c" F4 a( T! h, q+ g0 o
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    ) Q2 R- E, |$ V4 G5 E
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    * ]6 a5 ~" M6 ~" k7 D0 ]! j6 M5 F2 P( n) h
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;% b7 b9 U! u- y4 R/ A& |
  439.     else                                   m_iLanguage=ENGLISH;
    4 b$ [# U3 j$ x
  440.     char szRegister[100];$ {; G9 `. V5 Y/ S
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");- m/ d  j$ m& Z% U% |8 H  K6 Y
  442.     strRegsName=szRegister;1 r  K: n7 B# n; u7 T% n
  443.     char szPatchURL[100];
    ; K5 {* N) r* p) f6 R( z4 Q3 m
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    8 c7 C. \. [% m; H) |( j( J
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);) o, R/ b$ _$ o# U3 ^/ l9 l
  446.   }
    ! V4 E4 P. b' s- s- }
  447.   else
    / E9 }) p# l) M1 i
  448.   {0 v! l% o+ N  Y/ `( r
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    5 p; u+ _# ?8 A' G- {
  450.     strRegsName=DEFAULT_REG_URL;% h1 l2 x* o( o) e  }/ }; Z( g
  451.   }/ r3 C; T. |' O+ L
  452.   if(GetFileAttributes("hosts.ini")!=-1)
    ) B. y9 `  ~5 F9 V) t
  453.   {
    9 j" p9 ]5 o' |. S) g4 D
  454.     char szIP[50];- D1 w, V: p* b) z
  455.     char szDIR[300];  W  r# A9 |( A% e& ?, o  K4 Y
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))5 A+ t  v5 N* J5 {3 G/ E% w
  457.     {
    : p. p( a: V. o7 O3 F6 h7 C
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");/ Z3 E. h- ?6 z  o+ S7 U0 Z% [
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");" @' n, b7 i, A, [5 U
  460.       strHostName=szIP;8 Q8 w- V! }2 k  F  f4 D3 Y; o
  461.       strHostPath.Format("/%s",szDIR);
    , h1 \9 C! j* @4 T% m$ B
  462.     }
    " N4 c: M' `$ }7 |' S% O4 u+ j9 c0 {
  463.     else4 M/ a: ]4 S( B  Z0 }
  464.     {5 t! b0 i' t- x- a9 I
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
    9 m* l6 s$ X5 B- Y7 G2 {
  466.       {
      S0 J0 {) }4 C# r5 F9 C
  467.         char szLanguage[50];
    # D+ d3 i4 T6 e0 @5 O
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    0 a4 M/ V$ G: g
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ) U) i8 \2 y% K& {
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    ) K5 m# b( O/ ?$ ~, Y  V
  471.         else                                   m_iLanguage=ENGLISH;- W! b: N' n, z; v! }- b) ?; |  g
  472.         char szRegister[100];
    0 V  p& {9 L* S9 D7 N1 C3 i! q  Y! V
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    ; r; ]/ x% a: ^# s. V
  474.         strRegsName=szRegister;
    ( \- ~  \. M3 v3 m
  475.         char szPatchURL[100];
    5 o2 |8 h3 o6 @- a2 G, d. B
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");7 E6 ^; `1 \, n) ?0 j
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);' w4 D* c0 d; s# q, c: [' ]- \
  478.       }: q: F2 t6 N, R$ J& \' T$ j5 c
  479.       else
    - `1 G; c, h- R  d  N8 f
  480.       {
    8 ]3 O/ b1 @8 [  c- r$ p( r; T
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    2 J6 }2 S% F3 A9 K1 ]+ N8 e
  482.         strRegsName=DEFAULT_REG_URL;% [" \2 ?9 L3 O8 Q! R; b  }  j8 g
  483.       }
    1 z" C1 ~7 I$ M, ]
  484.     }
    ; g2 P3 R1 C; W# ]0 ?
  485.   }* ?% C! B8 G, C, L' X7 q8 D+ `
  486.   return true;
      _) z0 k8 F  `
  487. }
    2 t! N, X: Q' x$ G
  488. 9 u. _$ |% S7 E7 n
  489. #include ".\ZLib\unzip.h"& a; x% [3 P/ J1 Q* Q9 \% _
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);+ z* Y, ~" B6 y4 O( L6 ^0 H
  491. /////////////////////////////////////////////////////////////////////////////
    5 V4 w5 x( t, G6 _
  492. // CRevAppApp initialization
    : ?% |9 M, l: g* Y1 l4 I3 P. a

  493. 4 k: }0 b/ r, R( E. ?1 y! i
  494. BOOL CRevAppApp::InitInstance()
    2 f& S8 s/ `- _% k0 X
  495. {
    5 @# Z( j3 ]2 n! U3 k2 P: V
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    8 K# K! h2 V$ Y

  497. / |. z4 v6 S( E1 h' j' W# U% y  A
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);9 V2 t! P/ W/ F4 h& M
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))
    % @/ B4 v/ X6 P2 }' j$ ?: P, i4 ~
  500.   {
    + \( O# k! b# x, x+ _
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
    9 A. S  R  k  }& x4 X4 e, j5 p
  502.     GetPathFromFullPath(szPathTarget,szPathSource);
    ( x4 `$ O9 F9 _$ h! P
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))' B- \( j: `$ x$ b
  504.     {
    % o# q2 Q  V* T. w# D1 C( `* R3 N# v; v
  505.       strcpy(szPath,szPathTarget);
    8 ~3 z$ }! ~8 y$ z. Q" g
  506.       SetCurrentDirectory(szPath);
    * P0 L: y4 r9 g0 _+ O
  507.     }
    - K- a( ?6 x* ?  r2 I1 Q1 j. b1 y" a
  508.   }
    ) U6 r& K* n7 K
  509. #ifdef _DEBUG
    7 C0 S8 [4 B7 T
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))2 f" I* l: D2 O& X2 }7 W/ L0 F# |
  511. #else
    ' I( a6 r: c- p  ?
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12)). j* b1 Z# a% d
  513. #endif
    0 \# \) I' C' A! R3 F+ W- C. y* S, k
  514.   {
    " i' w% g+ `( X
  515.     char tempFileName[MAX_PATH];
    3 L$ b# m" e- e5 \$ Y
  516.     strcpy(tempFileName,szPathSource);
    - h! b8 @9 n# Q
  517.     tempFileName[strlen(szPathSource)-12]=0;) b) m: g0 ?! [5 J( H
  518.     strcat(tempFileName,"\\$CSUpdate.exe");/ Q( |6 o. d8 n- t& B, H$ G  |2 \: {
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);
      t, k* z2 z$ h4 P2 q/ h# V
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);
    . p. A' M( u0 G. ?! e
  521.     return TRUE;
    0 V6 E  A% b& i* q+ ^2 P6 H6 Y
  522.   }' ]9 ?9 e6 ~# T1 r
  523.   // Nuke 0118: Delete run.exe) ~6 B$ g7 e4 E  \, W2 k* M. I- u
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
    ! k# o6 t: n9 i- j  N
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");  j/ F# i. u6 @2 |/ ^
  526.   if(!ReadCfgFile("Config.ini"))
    - M2 l9 U; t8 x4 S: C- b
  527.   {  O. x& T0 v5 O" c3 d; o
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);
    - v9 a. {: g/ m- a
  529.     return TRUE;
    ( D! b8 h  i2 X3 u  }. k
  530.   }/ z  e+ `3 l) m
  531.   HANDLE mutex;
    ; g3 e$ F3 N+ L
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium")); H0 d0 M& Z: `0 W
  533.   {2 s% c" U, @  `8 Q+ ?8 e
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
    / }  y- {: |3 p. D2 D
  535.     {
    + d/ K: H2 N: b! C/ Y& |
  536.       CloseHandle(mutex);
    * _* W# h3 k4 l1 Y* A" w6 w
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    : @/ n) k3 T/ `* s6 S
  538.       return TRUE;: K! \. o# \3 c: s1 R
  539.     }
    ( z. e2 _  ^, g$ W
  540.   }  
    5 `1 |) I3 [% x- T% X
  541.   CloseHandle(mutex);: N- ]9 B# o: x7 l
  542. ) b  M  Z, X8 n+ e6 s6 e/ g
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);/ f: N1 ~6 ^0 p3 v; Z, R0 T

  544. 2 L0 x# y" g& |- n% I
  545.         AfxEnableControlContainer();+ j/ J# k' o: d6 R, J8 [
  546. 4 H8 \% {2 r* x( i( M/ Z% w& [7 M
  547.   bCanUpdate=FALSE;0 r$ ^1 |; k4 f6 U# R
  548.   dwStartUpSteps=1;
    7 @5 m7 ~- o9 `6 r3 u7 `: I3 A
  549.   dwProgramState=AP_NOTHING;
    : N7 A0 E, ]* L* Z

  550. 4 T7 t5 \* \  C3 h) Y+ B' ~
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);. I) x$ M7 E3 x

  552. 3 T- d- ^+ f( y8 A
  553.         // Standard initialization( T5 h4 }+ ~+ F5 |  h
  554.         // If you are not using these features and wish to reduce the size, X; v$ E# h: A$ P& O, j. P8 S
  555.         //  of your final executable, you should remove from the following
    4 `8 a3 p  s; l3 c9 H% @/ t
  556.         //  the specific initialization routines you do not need.
    ' B3 h1 |7 _4 U7 z/ W

  557. : c8 r  [$ |7 @2 a" W9 P$ A% m
  558. #ifdef _AFXDLL
    & x8 H3 ~0 Z0 S' v- Z* E% O+ l
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL* k/ P" P5 u0 k
  560. #else$ a" l. z! ?- c% x1 V
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically
    1 V6 K' V# o% l1 Z& b" G$ S. y6 D
  562. #endif
    ! b& n7 J) }% [* x: T) g
  563. $ N. ]4 h% S: f6 [) L
  564.   dlg=new CRevAppDlg;2 D7 a# ~6 h4 Q- t8 w
  565.   dlg->Create(IDD_REVAPP_DIALOG);
    1 Z% X. h- W. `. H' D+ S
  566.   dlg->ShowWindow(SW_SHOWNORMAL);) B& O; T& p5 T- t6 }. u
  567.   m_pMainWnd=dlg;+ k) G" P% x8 ~8 R6 z
  568. ; K& r0 F$ I) T0 v
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);. V) w8 _: k5 n/ D  y2 k5 O8 W
  570. ) U. S% j& ]% t5 T" v* r2 B
  571. //  GdiplusStartupInput gdiplusStartupInput;# L: o4 @, ]7 L$ H
  572. //  ULONG_PTR gdiplusToken;
    - u4 _! ~. i8 ]& K- @3 U
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);5 z5 N9 H( ^4 D4 Q: y! w' L8 g

  574. % p6 `+ f$ ?; l$ v* z- v9 A
  575. //        CRevAppDlg dlg;, x' W1 Y/ d( O
  576. //        int nResponse = dlg.DoModal();
    9 m% U7 Y! L" ~
  577. //        if (nResponse == IDOK)! j% s' I4 e4 l0 E; X5 V3 u8 d8 x8 \
  578. //        {, r* z" ^4 f( _3 Y/ Q5 M7 [
  579. //                // TODO: Place code here to handle when the dialog is$ u  U+ C- j( g" h* r( [, a
  580. //                //  dismissed with OK. R7 K, M* G; B  m3 f% C* ]  ?* M
  581. //        }3 i2 m. w- t- [0 K
  582. //        else if (nResponse == IDCANCEL): t* O2 \5 ~; a! q
  583. //        {$ E3 Q* X' I, b& N; e
  584. //                // TODO: Place code here to handle when the dialog is
    ) J) R- \( p! C# {9 p# X% C2 P
  585. //                //  dismissed with Cancel7 M" f: X  |0 z/ B- b) ~- L
  586. //        }
    . d1 a* W7 ?/ }2 Q3 J
  587. 4 Z- B3 W2 l$ V, F! i2 \
  588.         // Since the dialog has been closed, return FALSE so that we exit the
    8 K/ w6 t0 F1 i* t, ~
  589.         //  application, rather than start the application's message pump.# L4 _9 \5 Q0 [/ {& d
  590.         return TRUE;3 j* ^8 h) E5 {  N2 c3 [( l
  591. }
    + J5 ]4 M7 ^. Z+ b$ b
  592. ! u& e+ f/ s+ z
  593. char *CRevAppApp::strtok3(char *pSource,char *token)# J, G; t4 n- k8 A4 j
  594. {
    ! @1 F. |  H9 e& r; u/ e+ B
  595.   int i;  w; ~4 Z, o- Q3 W6 x( R+ R; a0 Y
  596.   char *szRet;% r2 k8 W$ I4 ^3 J6 S& G; K
  597. ( E4 l3 x- I: h5 y3 }5 g' V, z
  598.   if(pSource) { itoken=0; sztoken=pSource; }
    ; P/ }, G0 `& ?
  599.   if(sztoken), m  C& S  r5 P2 i0 v' X; O* ^7 w9 x
  600.   {* O. c/ z2 A' |3 |: f
  601.     szRet=&sztoken[itoken];1 ^" |; H+ r& R% l5 M1 h
  602.     while(sztoken[itoken])
    ' B$ l* c* F( U' [( Z8 w% n
  603.     {
    * |1 N, w! Q, R4 o
  604.       for(i=0;i<(int)strlen(token);i++)
    " a6 o4 w3 D: D5 }
  605.       {% Y0 o) V9 T( H" z/ `. ]8 h( u% V
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])
    7 x; h5 d. t. R/ {: I" [% `  Y+ v
  607.         {
    , ~  w9 A( P9 v$ g
  608.           sztoken[itoken++]=0;
    9 u) |/ R- D. j! D+ ~, Z
  609.           sztoken[itoken++]=0;
    & d) I2 @0 E: t: L, d
  610.           return szRet;
    4 B1 y0 M$ q/ ^
  611.         }
    4 b" R+ p, e3 E
  612.       }! V& x0 S  o5 D; o
  613.       itoken++;
    ; m7 J4 \) H9 w, r
  614.     }* q9 o: U2 N: N9 K
  615.   }  Y' w( A* J, }3 J0 V7 H* ]
  616.   return NULL;
    9 A2 r9 t- x' J5 s. Y# e2 N
  617. }. z+ p$ g5 c" z- Z6 P% u3 z

  618. 0 z( Y9 G. Q; y3 S6 g4 ^
  619. void ProcessProc(long Total,long Current)
    + {8 M8 e2 n/ ?, p+ g
  620. {& i* {( H# O  u$ N* U
  621.         MSG msg;
    ' A1 K& z* X5 M2 C+ Q' w
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);" p  y9 Q% c, z, P8 I" w7 S" O4 o
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));
    8 R4 m. r8 b* X/ h
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
    4 c+ B' }. h+ T1 P/ z
  625.         {
    2 v0 N' `0 x4 N$ a9 r+ J' u
  626.                 if(!GetMessage(&msg,NULL,0,0))
    $ w8 T( {" L; r- {, D
  627.                 {
    2 v. }6 r- q/ [- ~' K8 f2 F0 j
  628.                         return;% `; |# m7 k7 ?6 |% N+ ?1 k
  629.                 }2 z" |/ O- D3 s, n6 R: g
  630.                 TranslateMessage(&msg);
    7 o/ b% b5 O2 Q1 h
  631.                 DispatchMessage(&msg);9 M2 l  J1 Z+ W
  632.         }       
    ' I2 }% y1 v. u7 q  a$ N6 k2 W
  633. }
    % [4 s* ]9 R& T+ o

  634. 9 i# i6 j- Y8 V5 O0 n6 |
  635. BOOL bFirstChar=TRUE;. i* _! [( U/ q. A/ u+ L/ m6 D
  636. " {& _! k$ q9 c
  637. BOOL CRevAppApp::OnIdle(LONG lCount)
    0 }9 u9 E, f9 _7 Y; k+ q. @" h. Y
  638. {
    9 W7 W( o/ ?5 D1 B- U7 `
  639.         // TODO: Add your specialized code here and/or call the base class
    ! }8 l+ \( G' j1 t6 N  N
  640.   switch(dwProgramState)7 }* h- }/ s: A- e
  641.   {
    ' `9 P) m9 o! s" n& ]
  642.   case AP_NOTHING:
    * P- f3 p' S6 R7 b% [, b
  643.     switch(dwStartUpSteps)& n' s# Y0 z/ h( F3 I' y
  644.     {
    $ Q5 \' d8 `( R2 J4 S' h/ B
  645.     case 1:
    ! N9 i: y$ \+ G5 L6 K" k) i4 r' _
  646.       {
    & k2 N: E$ @( H+ k% U. z
  647.         int i;2 r6 i/ ?$ [! x" m
  648.         CDC *pCDC=dlg->GetDC();& ~) j& b) Y5 G5 [
  649.         HDC hdcwnd=pCDC->m_hDC;
    : K' w( ]% {+ p3 j0 @
  650. //        Graphics graphics(hdcwnd);4 u: C! R0 p. H
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");' {3 w! a% c1 r
  652. //        INT iWidth=bitmap.GetWidth();- ?! J/ I0 M  S9 g7 W( d8 v1 L
  653. //        INT iHeight=bitmap.GetHeight();* L0 C: G% D4 T. d7 J
  654. //        Color color,colorTemp;
    5 ~; a, O4 n, `7 a7 t5 M+ g, w. [$ E6 k0 y
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)
    5 h5 m' c& H- L
  656. //        {
    9 j; Y/ Q! K8 u* k& {2 X1 u
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)
      f2 |6 x9 h) u/ q* I  l. L% {4 y8 J8 v
  658. //          {; j2 ?. t8 k, U' M# W
  659. //            bitmap.GetPixel(iColumn,iRow,&color);
    * h* }+ Y- {7 N4 }  s" K
  660. //            colorTemp.SetValue(color.MakeARGB(/ _$ [% k$ B- q$ p; V+ x& j
  661. //              (BYTE)(255*iColumn/iWidth),% w. ?* \- ~9 p3 X
  662. //              color.GetRed(),
    ( u7 n  _- }0 t4 Y
  663. //              color.GetGreen(),
    * F) i& F% h* m% G, u# s( F6 E
  664. //              color.GetBlue()));3 ~# E# t+ }! G* c& T
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);
    7 b7 c4 _9 E' n- o! j& R7 ~3 f
  666. //          }
    # E' n6 [, a& X% p8 M6 F( E
  667. //        }
    + [3 K4 z6 r3 Z2 p9 y( O& w) L
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    5 {8 E4 B/ T' T3 c+ d; p
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    % l  n& z0 J) k
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    ) f1 S/ u2 h# l2 {  ]
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    5 ^; c4 w2 t! X9 r1 T# A1 K! n/ C
  672.         for(i=0;i<240;i+=8)7 E8 |) |  d' O5 k. z
  673.         {
    " J+ L. `; S# O( q6 |) K
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);! n- {* ~1 f5 E! i$ f" ~
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    ' d& b- e# ^" v; v. l9 u7 T
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    4 k1 s1 U& `9 |2 G
  677.           Sleep(33);" T* g# F# J/ }& ~( y
  678.         }
    + T4 \, j, ^7 D- T% v
  679.         Sleep(1000);
    9 V3 Q& z; I; A8 q; C3 y
  680.         for(i=240;i>0;i-=8)
    * D: U% o/ x0 E4 D# A8 Q! E2 G% D
  681.         {
    - e$ b  t' U2 Z
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    . l/ T7 Q% l& O. w8 H9 G; n
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    0 @/ ]4 o1 M  B6 N3 D5 q9 w7 }
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
      q) \/ \4 w7 ]5 a. }
  685.           Sleep(33);& S: c/ d6 g+ f) B
  686.         }8 }4 S7 z' {5 v9 j, t9 O  A
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
    ! l: P/ t2 j- m& R7 p0 V
  688.         dlg->ReleaseDC(pCDC);
    - T, n8 p# H( e8 O2 w- P
  689.         DeleteDC(hdctar);2 u9 j8 s5 `. J. |
  690.         DeleteDC(hdcsrc);: C7 ?9 A4 f9 H9 S
  691.         DeleteDC(hdcorg);
    ) i2 d! R8 s' u5 @+ {0 B( M
  692.       }7 H* U. H% V6 f8 d; O6 c" b
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);& w$ G$ Z) j" ~' V
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");
    . A9 f9 i# `* `  L; u
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");
    / L- T% Z3 D3 x" B: L# q! n) e
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");
    ) b; E9 t' b9 ?+ v. P" A3 Z) Y! |
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    0 w+ l7 n' o8 b5 Y/ F( ~, A9 e8 ?
  698.       if(!Dn.Connected())
    + ]5 e3 c0 w; O( @8 m. R
  699.       {9 p% U/ I% s* S. f
  700.         dwTotalFiles=1;
    ' W$ f, N5 p/ d! k/ E1 c: P! t# I
  701.         dwDownLoaded=0;
    " f1 v! C. R$ r( X1 Q8 ?
  702.         bSilentStep=TRUE;+ F' ~$ M3 }- a
  703.         bCompressed=FALSE;) p. S4 |9 n1 f% ]' r# P; u; t
  704.         strExtLocal.Empty();
    9 V( |. y) K+ Z+ f- }
  705.         strFullName="readme.txt";5 s4 h) D  E' S( Q2 y
  706.         dwProgramState=AP_CONNECT;" @) e+ _4 ~7 p8 A- Q7 j& a
  707.       }
    0 @) |: w' F" B( d+ `9 p4 R! L
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();7 [0 F. K- F% J& n
  709.       dwStartUpSteps=2;
    ' l0 ~2 v: [1 m- E, L2 \
  710.       break;
    - I1 o9 {+ A0 t& N* _
  711.     case 2:
    7 H! ~+ t5 o' e# E
  712.       {
    " p' E+ u: s& j
  713.         int iEOF;
    9 l9 x0 {# R! c3 O5 x) R
  714.         FILE *fp;+ F$ O9 W3 S/ _1 y+ e
  715.         char szString[512];
    * M; Q- P0 |- R  Y  }- d9 U
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");
    8 B, T1 [% x: T1 d, m7 u+ b
  717.         if(fp)8 q! e& Z# p) {8 q7 [/ g
  718.         {
    . I  m5 n) n6 A$ G0 \
  719.           do; i9 F( C, s1 @1 G. V( _
  720.           {7 z1 z0 f7 T1 m( N
  721.             iEOF=fscanf(fp,"%s",szString);+ ^: q( L* b' U
  722.             if(strlen(szString))
    4 a% e3 M; N' p; U; s/ m
  723.             {9 E5 u) @: m! x
  724.               if(bFirstChar)
    2 D+ H7 j# M% a3 e) ]
  725.               {
    1 {" f& m. O" l& G7 |; `
  726.                 bFirstChar=FALSE;
    2 o3 c: E3 f0 j% e
  727.                 bConnectIsBig5=FALSE;
    5 c2 C$ }" \$ S! X  @
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;
    / f, @  A0 t& x
  729.               }; j9 s' B* l7 M: w
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
    2 `: L8 w9 V$ r: `4 u' i
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));9 g- g! j; ]- b, K5 R
  732.               dlg->m_ListText.AddString(szString);
    0 w- e& p6 t0 g, |' V5 _! G5 D
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    8 j+ y# f; m( `  F
  734.               *szString=0;
    % y, |6 i; E; c& r5 `! m
  735.             }1 [0 j9 @0 {  b
  736.           } while(iEOF!=EOF);+ J; l) N7 ^- R; M7 W/ v, ^
  737.           fclose(fp);
    8 `9 Q; B8 m, w9 s8 y
  738.           unlink(".\\DownLoad\\readme.txt");5 u+ f0 a7 u3 O. v, A5 b, l
  739.           dwStartUpSteps=3;# G% C0 q- d6 Z/ a. x  b) ^
  740.         }5 A( X5 ?3 v: J0 y6 y9 x2 i) A: N  l
  741.       }
    + _8 u! q3 n/ @3 a, ~" [. s5 T
  742.       break;
    1 D' w+ O# n9 P7 g( ^
  743.     case 3:5 m8 W9 t, P' ~9 O2 |  m# d8 h. U
  744.       if(!Dn.Connected())9 \1 ~) x; o  a0 d: D
  745.       {0 b/ V% v9 }( s& T( u2 B: I
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);& q+ \) l% V: w
  747.         dwTotalFiles=1;5 S( W8 |3 L- K! k/ `
  748.         dwDownLoaded=0;# O: [: t# B  o3 J5 d5 ?2 ~
  749.         bSilentStep=TRUE;
    : ]" ]# [. L$ z5 l- A- R
  750.         bCompressed=FALSE;
    4 p( ~& o+ v6 V! C* s
  751.         strExtLocal.Empty();
    0 a7 Y- y# e0 ?3 V( _  o
  752.         strFullName="checkversion.txt";! W2 Z' T- x' a3 ^# g
  753.         dwProgramState=AP_CONNECT;
    : ]/ S) a8 p' w9 P$ `
  754.       }
    & Q; W% s- n8 C% k& j0 t: c
  755.       dwStartUpSteps=4;
    0 ~. w, Z( m" ]3 @3 J+ x4 h
  756.       break;+ c& ]8 y# u" ]( A: F: B# K+ A
  757.     case 4:( k! m7 H/ X+ d$ }1 X" A1 l
  758.       {0 E, h3 B# g$ V5 P
  759.         FILE *fp;5 P, B5 q/ _6 q1 Q6 Y- I% |
  760.         char szString1[128];
    % Y; j# ^! @' b( d8 Z
  761.         char szString2[128];
    - R4 M  T4 W0 n( T$ k( a7 Z
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    . \* D6 S1 f2 Y. r( Z/ V5 I
  763.         if(fp)
    " P2 d/ Y. B" R: i6 D
  764.         {7 W. [7 z- _0 C
  765.           fscanf(fp,"%s",szString1);: e7 b. i( i+ `
  766.           fclose(fp);
    ) a, c. R( a* ~, G
  767.           fCheckVersion=atof(szString1);0 v5 |8 ^6 V$ E% r5 g; |
  768.           fp=fopen(".\\checkversion.dat","r");
    - {9 }5 i, ~2 ]3 `4 _. n3 c
  769.           if(fp)
    ' |+ l2 V- h0 Q; B: i
  770.           {
    , g5 h. h3 t+ c0 W
  771.             fscanf(fp,"%s",szString2);
    0 b* M' N' e# t4 M' ]
  772.             fclose(fp);
    3 Z! U- P$ _" _1 [
  773.             if(atof(szString1)!=atof(szString2))
    9 r0 o  Z% `) Q" }" a0 U- a
  774.             {$ d. d& q) W( q; z2 k7 i
  775.               if(!Dn.Connected())
    : B3 I: v% S- F- X% D
  776.               {& H: {# Z8 p9 {- I
  777.                 bFirstUpdate=TRUE;8 f, M, U" G. a1 P! M
  778.                 dwTotalFiles=1;8 S8 t, S1 {0 a% O
  779.                 dwDownLoaded=0;: ?3 m" v; C: A5 s
  780.                 bSilentStep=FALSE;
    ) ~: P- r# c! |
  781.                 bCompressed=TRUE;
    4 y0 Q2 N% b$ b
  782.                 strExtLocal=".\\DownLoad\";
    5 X2 |+ B6 F2 a8 A% m7 |
  783.                 strFullName="update.txt";2 x) o$ {, m4 l/ ?; u" \0 c; R5 v
  784.                 dwProgramState=AP_CONNECT;
    ! w4 @) N* ?5 h7 ?8 I. M: M- W
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");  }- D9 J; L" H- p0 {
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    % f' i: S* y+ t
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");
    & `$ {9 ?, B3 g# L
  788. 2 a, e3 e8 @, v* t
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);) Y+ M. s6 c0 D) I
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    9 p+ K0 R! d+ Q" H3 J9 g
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)
    8 Q+ |0 P: Q$ m! f3 P" c$ W
  792.                 {+ f# F. m$ b, D4 T
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
    * q2 G% O1 R  i" L
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");
    & |- R: r4 P- P$ z$ H4 |, c
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");
    : L% A  ]! i1 q  K7 H
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    1 L- r- n8 ?( `( l9 e

  797. 4 |' J9 f$ d4 o$ P/ _+ t
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");1 @) t0 t2 f: R0 j1 j
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    ! s# c) a+ a& L" \( X- O; x8 T
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");. L, x+ ?6 B& B
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    , L: I6 G+ H) _9 o/ F# A4 Q
  802.                 }
    % C# O; c2 X8 y8 a9 j
  803.                 dwStartUpSteps=5;# L5 {+ W% u7 s$ ?. y7 U' u6 `
  804.               }
    3 K$ @, {, Z. {
  805.             }
    / |  p/ D# B  P" H
  806.             else
      `  V/ ?( }4 G# ^2 s
  807.             {' Q% w* Y5 l% @! \# r
  808.               unlink(".\\DownLoad\\checkversion.txt");6 u4 S' E$ _* n# I4 Z
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    + R4 I  T9 H2 g7 g
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    ; x' G: g7 P- P" D7 N
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");
    # r% x% l0 J. z! ^
  812. % {/ i& X& O$ n% j" \6 |
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    * u: G3 N' m' p8 z& N) L' L+ }
  814.               dwStartUpSteps=99;
    ) ?! ^' W7 S8 p( q% r
  815.               bFinishUpdated=TRUE;
    2 }: d! C. `3 @/ h7 e
  816.               bCanUpdate=TRUE;
    . J: A3 k; ^* H/ l- G- n% j) @) [
  817.             }
    3 c; F1 Z6 W6 d+ s2 n% Y
  818.           }
    & ]. \7 T- {' }" S
  819.           else
    1 t( O/ `, u4 V% x; r  ]! H8 v
  820.           {9 b& N- d/ i) r/ i! Q0 U
  821.             if(!Dn.Connected())! ~* W3 L7 ]5 |6 h; ~( n
  822.             {
    ! u, z& }, X$ I3 M- e
  823.               bFirstUpdate=TRUE;9 E5 L' O' C& g
  824.               dwTotalFiles=1;2 @. l, H1 _& o1 [7 \. ~+ J$ H
  825.               dwDownLoaded=0;
    ; q7 D5 d9 ?7 Y) t0 i$ G; ~
  826.               bSilentStep=FALSE;* L+ X: \5 ]0 t- I  H
  827.               bCompressed=TRUE;. i' W7 E5 V# J
  828.               strExtLocal=".\\DownLoad\";
    , h3 ^! \' o! m! C, w$ ?, ]8 c
  829.               strFullName="update.txt";
    + x# s8 ^' y/ g8 J; Y. b
  830.               dwProgramState=AP_CONNECT;
    ( L2 U6 w# G# Z/ D4 ^( D3 h
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");; {9 r: a8 H+ A
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    1 `6 @6 ?  }5 w$ R+ k
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");, z$ j9 J6 N! n9 k  ]) v; l
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    " D+ f0 Q+ W( i: l5 S; }1 R
  835.               unlink(".\\DownLoad\\checkversion.txt");
    6 A8 {5 ?  H& z" X, }
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)
    2 P( I: t2 C$ N' D3 ]1 c: V
  837.               {
    * K% Y6 N2 c) q
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");
    5 F3 ?9 S9 }0 @0 B7 b
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");
    8 V  U8 }! Q. R: P: b" ?" I
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");
      ?* f7 O/ Y1 ?2 b
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);3 X4 j/ ^9 P& i. s& L
  842.                 # e0 X7 q, X" T, R! q) w
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    % B, T2 `3 B- i  d3 d' d( |. Z
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");4 F2 @9 d5 q, S4 P+ X$ `9 A1 H
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");& T7 L, N6 d  ~* N/ M9 O- m; k  i
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    3 y' d% t. L, H
  847.               }6 @  x+ X0 \$ O% L
  848.               dwStartUpSteps=5;2 _- C6 e* U# \8 g1 c
  849.             }
    6 _. r' e, R. k7 O
  850.           }; h/ ]+ e0 F: X0 l7 h7 D
  851.         }
    5 g4 T# ^( e* W( C3 d; b
  852.         else
    5 P( x/ o/ w- l0 ^. L, \# ~- t
  853.         {
    1 J* Y5 {; B- Y
  854.           dwStartUpSteps=3;
    ! Z2 c( M* e5 |& G, R
  855.         }9 u0 p% K  }& I7 ?' w9 Z
  856.       }5 A/ z$ A0 I3 i6 @
  857.       break;
    # P) u8 f$ i* w( s( C5 s- a
  858.     case 5:
      k5 U5 S- K! q+ l! T  W2 H
  859.       {1 r0 k" t' e" Y; L
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)" ?+ ]! x+ ^) B7 o
  861.         {" s4 H" a, I/ \$ ]
  862.           int opt_overwrite=1;2 T) B5 T. T* v7 ^- _
  863.           int opt_do_extract_withoutpath=0;
    5 R# P' X! @* g" |0 r
  864.           unzFile uf=NULL;/ Q, _+ z/ F3 j" i, r8 }2 M

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

8 b) w' ?- `( i9 V. M

評分

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

查看全部評分

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

yun5520245 發表於 2018-1-29 21:25:42 來自手機 | 顯示全部樓層
东西不错,只是现在研究的人少了。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-1-28 19:21

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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