找回密碼
 立即注册

CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閱讀模式
, e1 X, P4 {, a' v9 O' y# U. v; k, \
  1. / RevApp.cpp : Defines the class behaviors for the application.
    ' _7 q0 ?. X! Y8 c' l9 \
  2. //4 I) H& G# l" `* T6 [2 g6 d" y. p
  3. 1 {, x4 [6 p4 L
  4. #include "stdafx.h"% Z# m8 m- U( E
  5. 9 F1 E0 ^7 j5 P! n$ `- F# x$ u
  6. //#define UNICODE
    1 l3 y! B  ^: Q
  7. //#include <gdiplus.h>. _$ N( x0 j9 X  @" Z/ ?$ ], {3 X
  8. //using namespace Gdiplus;
    0 l/ j  ?/ d, h. u% N5 s

  9. 7 [3 M8 H; E# A
  10. #include "RevApp.h"
    8 Z% V0 C) h# M- F% J0 m
  11. #include "RevAppDlg.h"
    8 i/ I1 r6 H+ h9 U, h0 m
  12. $ C8 c) M5 r5 F, K# O, \; T
  13. #pragma warning(disable:4786)$ x4 F1 V' k; @  J* t  b% t
  14. #include <map>4 V; L2 Z  p( J
  15. #include <list>
    % O" y$ ^: Z" q0 a2 C/ Q
  16. #include <direct.h>/ L9 U* h0 S# g. H7 L

  17. 7 B6 b5 v7 l6 n* u/ ]/ }
  18. #ifdef _DEBUG$ D/ P) R1 N& n' ]2 O/ M
  19. #define new DEBUG_NEW$ ]) f/ A. u: r4 _/ {' a" ^$ [
  20. #undef THIS_FILE
    4 M, K& ~- X  t' I9 a& ~
  21. static char THIS_FILE[] = __FILE__;* H, g9 p4 l6 p
  22. #endif1 }$ |& X4 c4 w7 C) z
  23. #include "SkinResDef.h"
    7 [: N4 f8 R. u: X% N4 j: D+ H. M+ I
  24. #include "ChangeBG.h"
    : z$ W  S0 v9 e- \, R
  25. #include "AFXINET.H"
    1 ^" N8 C3 c/ D9 x" ^* _1 l
  26. : ^- ]  r4 `0 Z; ^* k
  27. #define TRADITIONAL_CHINESE 04 t; N7 G. M$ `5 f) Z) k. G4 t
  28. #define SIMPLIFY_CHINESE 15 n2 T8 A' m0 s+ ]7 W$ j, P
  29. #define ENGLISH 23 t% _2 m# W# ~# E
  30. int m_iLanguage = ENGLISH;
    5 U) q$ B& S( z% J0 x5 W9 Y, q
  31. /////////////////////////////////////////////////////////////////////////////
    ; T& ?; R  B  p' o, F6 P
  32. // CRevAppApp
    7 n: {, z& H4 h! I7 ?9 e3 G( S

  33. 2 {0 T8 h1 t. [* r. T% m
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    7 h  _7 J9 w$ w) @. r! W
  35.         //{{AFX_MSG_MAP(CRevAppApp)
    3 y: a/ F% S+ b  G; F
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.
    ; F* u( h3 U4 e
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!
    ) A/ p8 |/ r: `9 d0 }1 R
  38.         //}}AFX_MSG' ~; i+ L. u2 p; D) w
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)1 C( r. O! H9 U
  40. END_MESSAGE_MAP()$ l' T9 P9 S2 s  Q: }. p

  41. + U2 \6 Z" A+ u: l( [
  42. /////////////////////////////////////////////////////////////////////////////5 n* {! ~. w' c8 A/ `8 n
  43. // CRevAppApp construction' J- @, ~5 Y7 H. K4 W" l: @$ P, Y+ c

  44. 3 _* {2 v1 C+ I4 p
  45. CRevAppApp::CRevAppApp()
    5 p4 p) D9 A* Y1 w3 _# Y$ B
  46. {2 G& r+ y* o7 p: d6 x8 E3 d" f' C
  47.         // TODO: add construction code here,& A. |: y" f: k- v$ W0 ^
  48.         // Place all significant initialization in InitInstance
    # {1 C' t) l# G* y; U; Y$ Z7 w( d* d
  49.   bDisplayIsBig5=FALSE;7 X7 y8 H# @0 ?6 S: Z4 N! i
  50.   bRestartUpdater=FALSE;
    ! l# {% c* i3 |0 {+ Y7 N  U+ Q$ M
  51.   bFinishUpdated=FALSE;
    + N" C9 z( L' c3 h
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;  \( {% v. C: y4 z1 |# r
  53.   InitChangeDataBig52GBKS();, p! S( n# X+ {* L1 D5 t
  54.   InitChangeDataGBKS2Big5();. f7 h, m( m& ~  n* H, Y
  55.         //3 H7 C; u% M5 @* \# o& l
  56.         bClickRunExe = FALSE;/ U6 F$ |) v5 [/ Q
  57.         //
    2 `9 f& g% a8 k* Z
  58. }
    ' R) L- D3 F& Z. u7 z) S

  59. ' B) W+ j9 P7 a2 @
  60. CRevAppApp::~CRevAppApp()) L5 F6 |# [( i1 J/ x0 K, J  Z
  61. {
    8 C# T( {! T, v
  62.         // TODO: add construction code here,
    $ Q/ G" D* H1 Y
  63.         // Place all significant initialization in InitInstance
    : r0 H, N" W3 [& s1 e
  64.   EndChangeData();* G$ S1 j' R- B$ ^, d; |& w
  65. }
    ( V+ V% c! R$ ?. c5 t1 m

  66. ' B' X6 P2 n* M. P# c! K9 A
  67. /////////////////////////////////////////////////////////////////////////////$ N! J5 p; t" ~$ ], r
  68. // The one and only CRevAppApp object6 k9 `6 Z6 j$ I! {0 o4 ]/ X: |: V, l, F9 O
  69. ' G& `: R9 M# {. V
  70. CRevAppApp theApp;( p5 _3 R' x9 n

  71. " D2 w) i! b& }+ Y; c# m
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)4 ^3 G& T9 X# ?5 Y
  73. {
      ~- ]6 N* U6 V7 _1 ^  }0 L
  74.   int iEOF=0;. z; H7 f* t# V' Y) q
  75.   char szTempName[MAX_PATH];
    5 u+ S( A7 b# B0 [6 z/ t8 r
  76.   *szFileName=0;
    6 ]9 _- }. B2 h
  77.   iEOF=fscanf(fp,"%s",szTempName);
    ) e# V/ x; X6 {: Y" x) u
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    4 ?) k$ C7 _. O
  79.   {9 e, J; b- h* D; u  P
  80.     strcpy(szFileName,&szTempName[1]);, Z: V0 n" A2 i3 o( }0 q- q# U/ x
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    # h# s7 `) |/ |
  82.     {
    & l( R" U( T, P- ~0 ]% k& P: x4 j
  83.       iEOF=fscanf(fp,"%s",szTempName);" @# @8 t+ |; A( b1 ^$ ^3 T
  84.       strcat(szFileName," ");7 ~* v3 ^5 B+ u3 c
  85.       strcat(szFileName,szTempName);
    9 s* Z# t5 ^3 @, q) X( o
  86.     }
    " X- }/ u' b# |  x  x: @
  87.     if(strlen(szFileName)>=1)
      w" H, q' k: v7 V* B( ~, l
  88.     {4 t) c3 ]7 ]6 A' G; H5 G1 `  P
  89.       szFileName[strlen(szFileName)-1]=0;
    # b/ ~$ a+ M+ H
  90.     }; c7 j- b) ^& u& h8 a' o
  91.   }
    9 E- y/ m3 T) g4 F4 G
  92.   return szFileName;
    0 |+ R4 J! H8 ?8 x
  93. }
    5 b, m$ H" n+ P7 W8 Y
  94. , p0 u/ i1 p- q1 ]4 `5 F1 L
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    $ h: ?" Y5 G1 z) a) M
  96. {" c( |% d; j; H* W8 n
  97.   FILE *fp;
    + K' f3 C- L8 B9 X& A% C% m+ O
  98.   char *key=NULL;
    * O8 L, a9 X! S
  99.   char version[MAX_PATH];6 Z) N& S! e9 N& {# G' f2 Q! O
  100.   LPUPDATEFILE file,olds;
    % Q! M/ K5 q5 _
  101.   std::map<CString,LPUPDATEFILE>::iterator p;. Y* P- v( h" a  ?5 k

  102. 1 s  [9 ^6 @, W! Y% P! Z' ~& ^6 D! g+ ^
  103.   UpdateList.clear();
    * t/ I( e3 q  G4 R% y6 v
  104.   UpdateFile.clear();
    0 f/ @9 F$ i* W* |' a% }: v
  105.   if(GetFileAttributes(filename)==-1) return false;
    " _$ W( x; v. W, P. @
  106.   if(!(fp=fopen(filename,"r"))) return false;& O8 m( M" c2 K- O8 \& U
  107.   fscanf(fp,"%s",version);8 _: m; U) s) L* S
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }
    + t2 Y+ {1 V# T
  109.   while(fscanf(fp,"%s",version)!=EOF)
    : d( ~6 `3 j2 V& f$ a# [7 _
  110.   {' C7 E9 d% t! _. b: E* i
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));# G' S# \1 r2 [6 G% k  [1 O  x/ z
  112.     fscanf(fp,"%s",file->path);
    8 C$ q. I- D) A. F/ o9 u
  113.     ReadFileNames(fp,file->file);
    2 U7 q  c' y: E" ?* ?9 g5 y4 q: Q3 t
  114.     strcpy(file->full,".");: ^; h3 M/ v: I! T
  115.     strcat(file->full,file->path);
    . N1 V( ]& R+ }$ X5 U
  116.     strcat(file->full,file->file);! {2 W) g2 d/ X2 _8 p
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())/ C: N( C% H8 T+ P; ^! ?! c/ v
  118.     {
    ! b* \& R" P# k2 F
  119.       file->vers=(float)atof(version);& ~% ~8 F0 g/ K6 k
  120.       UpdateList.push_back(file->full);9 F! S9 D/ N3 C0 O, V. e1 p3 C
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
    5 L* F1 p. [( V* q1 |: v
  122.     }
    2 P$ k5 z9 P+ s& T, n
  123.     else3 f7 V, U6 s% W
  124.     {- B7 w/ @& U8 x7 [/ Z2 B; u  s
  125.       olds=(*p).second;( f# T4 E5 [* w, b" {! x
  126.       if(olds->vers<(float)atof(version))- I6 @' l& c1 F, }
  127.       {5 T5 S4 q" e! ?4 P7 D! K) y
  128.         olds->vers=(float)atof(version);
      ?8 @; x3 A1 v% Z9 E
  129.       }) p1 d1 t1 A4 ]$ V, i
  130.       free(file);
    $ G; Q, \  _9 ^8 T$ l: B7 o, m
  131.     }0 p, d/ {1 M! x& @: n& ^
  132.   }
    6 T7 ^+ k% G9 r0 V+ P/ Q$ [7 m
  133.   fclose(fp);
    8 {, d  u0 M# e3 i. t! ~( g0 z: [
  134.   return true;
    / g! ]8 w  a" ~/ o
  135. }% T1 r! e2 e  W, }. Q* c* Y
  136. 5 P  ?! D* J# e( c0 r
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)5 f6 c, l: W" h% U
  138. {, z* {/ k. u( a$ k0 c* I7 G
  139.   TCHAR  szFull[MAX_PATH];
    7 p, ?# J2 l& a- j+ \
  140.   TCHAR *token,*inter;& {7 [, X  p$ S( s5 ]2 o/ d2 l; Z
  141.   *szPath=0;" p5 [4 h( u( H- `3 Q
  142.   strcpy(szFull,szFullPath);
    ! S7 h( v2 t2 @; X) @
  143.   token=strtok(szFull,"\\/");
    - E' e: ^! q" [; j9 {  |& T
  144.   inter=token;9 E2 F* y' @5 ~) G+ X+ c( `% D
  145.   while(token=strtok(NULL,"\\/"))/ _6 I0 \) [5 ~6 z2 K# y" h
  146.   {3 g& ?2 {6 x2 |" u& f# t
  147.     strcat(szPath,inter);
    ) }% u1 [! \/ _
  148.     strcat(szPath,"\");" f2 V0 y6 f) W  Y6 ]7 c4 w& `: S( D
  149.     inter=token;
    & t  M0 B2 w" ~! D5 j
  150.   }. N  R, H3 R5 Z1 Q6 A, q
  151.   return strlen(szPath);  C6 S$ b+ a% l1 S# d
  152. }
    1 x5 ], E3 g& Z. o
  153. + n1 d. o: a) p  N2 |3 G* @% C
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)% S" ^, r3 \: P: J2 g
  155. {- l% D3 L9 I2 u3 S1 c. h) Q% l
  156.   DWORD attrib=GetFileAttributes(Target);, [% v) K1 }0 J: ~
  157.   if(attrib!=-1)9 |' F% l+ |  g" d# @* ~
  158.   {( `  q# @6 H1 }+ {& w8 g2 u
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    2 v, b" q, n9 P7 H3 ?3 M# `) N
  160.     {4 }- N2 v9 v2 q- R1 s
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);9 V9 i5 u( \  {2 i: q+ ~8 [! o
  162.       SetFileAttributes(Target,attrib);
    $ [( i! n6 J* i) K) K, e
  163.     }
    5 x+ T7 b! l: u: ~+ d0 h7 x
  164.   }8 j/ i3 F9 l" L. ?
  165.   CopyFile(Source,Target,Erase);
    * a+ K3 p9 M/ f: \+ {% C8 Q
  166. }
    6 ^) b' i; i' I& I1 `, c

  167. + C6 z# z1 x) F! F; }
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)
    - t9 S* g* M2 N. a6 M: W
  169. {" [# V! ^  U# W- ?5 ]
  170.      FILE *fp;' i  w) f* N& F6 J
  171.      char  szBuffer[8192];) B! k' B9 q0 T: j/ |
  172.   va_list  argptr;
    0 x, Z8 g& y6 q" \) ?2 A* {6 f. x
  173.   v. J- ]4 |- A( n9 K. A7 ]- G# r! x
  174.         va_start(argptr,message);
    + w, h  @; B3 G- F# _, C
  175.         vsprintf(szBuffer,message,argptr);! q7 \/ N1 S" {- V
  176.         va_end(argptr);
    : G9 o/ i8 |% ^; r. e  w
  177.   fp=fopen(FileName,"a");
    " X. I6 M" M! b; t4 @' \! y# H$ x# g
  178.   if(fp)
    1 Y' z" R+ i  m6 Y" s' W  X
  179.   {  e6 N6 o1 y' ^4 `
  180.     fprintf(fp,szBuffer);$ i' G) V  x% \8 d5 Z  y- B2 _
  181.     fclose(fp);
    7 y; Q; |" S5 _: [! Q
  182.           _flushall();4 `2 n2 ]" S7 t* B! g: z
  183.   }
    / U' M1 |. ^) `3 _: ?6 A4 t
  184. }# E. J% z+ C) l8 d$ I5 l! u" B

  185. # s/ t1 ^( k- `$ E5 O3 H
  186. BOOL CRevAppApp::Fclearf(char *FileName)& U$ A8 N3 S: t
  187. {
    1 `& H6 f( J: c% Y
  188.      FILE *fp;* p! [( f+ D3 ^, Y3 n% C
  189.     DWORD  attrib;
    ' _8 h) H: E  z/ p6 j, e7 F
  190.   attrib=GetFileAttributes(FileName);
    , E* F  u$ g1 [& l9 K
  191.   if(attrib!=-1)
    # F( I( j. t5 n' ]- W
  192.   {
    $ a& F/ M$ R7 I, Q/ s) g
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
    , L% c' O0 z4 ^; f" @* x
  194.     if(!SetFileAttributes(FileName,attrib))
    ! T; Y0 v: R/ y. u( _
  195.     {8 y8 Z4 y4 i7 W8 C/ z  {8 n
  196.       return FALSE;
    0 _3 _# q& \6 K
  197.     }/ a$ h  ?' n# n0 K1 M% C7 k% m3 F
  198.   }% e# c3 s) K) i8 A" R4 V$ w
  199.   fp=fopen(FileName,"wb");
      |; }+ b7 _1 L# U( V: v5 I+ g
  200.   if(fp)9 p! k* @* h- l& U/ i; k
  201.   {
    ' g3 {  R3 b$ N, Y* @1 F
  202.     fclose(fp);1 u3 L* b: V2 S- s$ z
  203.   }( a$ g) D/ A4 f9 O
  204.   return TRUE;
    / L* R* I/ K% N$ y/ X
  205. }& ?) G6 X5 e" z3 F& W

  206. & Q) [) k: o' t$ Z5 V
  207. BOOL CRevAppApp::UpdateLocalVersion(void)
    " N3 ^$ @0 L7 [! q
  208. {: I! @/ p6 T  W! }- \+ |
  209.   char filename[MAX_PATH];
    3 A6 S; D) r4 N3 t
  210.   LPUPDATEFILE file,olds;
    ' F. i% P+ u6 I  z2 z3 u; {
  211.   std::map<int,CString>::iterator i;$ f  R  [& ^& F: ~
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    3 H$ H  u. r7 ]2 K; \7 A
  213.   std::list<CString>::iterator l;2 Z/ _$ x. ?. B) T6 F

  214. % Y  m& s) f* E( l3 v
  215.   if(bFirstUpdate)
    * G: v% Z' l2 U
  216.   {
    2 U* G; j' ]) L8 K1 G; @! Y/ f. R
  217.     dwCurrFile=0;
    . Z9 E, P2 c( X) r1 [3 D
  218.     bFirstUpdate=FALSE;5 S$ c. @% a# t& G. }3 Q
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end()): |$ e5 @" P0 {/ O* N# I' T* N
  220.     {. m0 h! ?2 K8 F% r" O2 V
  221.       dwTotalFiles=UpdateLocal.size();  l- E, ^, s( o7 x' \9 h
  222.       dwDownLoaded=0;
    : ^3 M7 o  m0 d3 C  \
  223.       bSilentStep=FALSE;
    2 Z& Z- n* |1 \+ E0 G" Z5 K
  224.       bCompressed=TRUE;
    # K6 d" q9 W$ h3 b9 J3 \* n2 V
  225.       strExtLocal.Empty();
    4 D+ F# [0 d; N
  226.       strFullName=(*i).second;9 }8 v  i6 E, `
  227.       dwProgramState=AP_CONNECT;( J/ U2 `, E1 B7 u# a! q5 |: F
  228.       return TRUE;/ G2 {2 V' R  o4 V2 Z) q
  229.     }
    " P' |: W4 r: _, d3 k% ?$ G5 B* `
  230.   }
    ) J2 G2 d  J* p3 O+ R
  231.   else if(bRestartUpdater==FALSE)
    0 @% R8 n9 f, [/ b% _7 ~8 B* N# [
  232.   {7 a* O9 h" g( J2 H3 L
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())
    1 d$ }; X+ n0 P4 J, s) S: e
  234.     {7 P3 t6 V) e. K' b
  235.       file=(*p).second;# e. J! r2 ]" k7 L2 ~
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end()); ~/ T: S% o3 s
  237.       {* Z! @& B& f  h2 U! z+ x
  238.         olds=(*p).second;
    - ?$ M7 o4 p& e% ?: ~9 j
  239.         olds->vers=file->vers;
    & w, q/ O, W' S1 k/ H
  240.       }
    7 w! D" a, [/ N5 n- J
  241.       else
      G+ S& C/ W( r0 W* e/ h1 t
  242.       {
    6 R/ l0 u' ?  ]& c
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    2 {$ D: C- D1 m0 h$ N2 [+ R) V9 v
  244.         memcpy(olds,file,sizeof(UPDATEFILE));' Z" @0 [2 i9 W
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
    1 x0 x9 U$ U9 U% m
  246.       }
    % K3 o( `) f* ^2 v
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");
    , }9 z* f8 ~( C) }9 X9 C
  248.       sprintf(filename,"(%s)",file->file);+ T. B0 m1 _# \
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);# T# s$ @  Z1 [4 f  O0 N
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }
    * [. Y4 Z/ H. h* t8 c" f9 [& \
  251.     }+ }; t& G' B% P8 E  t" {+ x
  252.     dwCurrFile++;
    1 |" P% S3 X) ]4 J8 b' u9 s
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())" G. g5 Q# g: {3 M; l
  254.     {
    ) m) U) t9 L% p5 [; k! F. j0 ^1 }
  255.       bSilentStep=FALSE;
    * ~5 D8 E+ j1 S: v3 f6 F  a
  256.       bCompressed=TRUE;. @. J' o. z7 J* _  `+ m  c
  257.       strExtLocal.Empty();# I+ \( a6 W( @+ `$ i/ q) @* `
  258.       strFullName=(*i).second;& H- t; d' a$ i( Q# s- `; s
  259.       dwProgramState=AP_CONNECT;
    : v) ^8 f  m8 A" \" W" }" N
  260.       return TRUE;
    - f* H1 n& s, B" X8 b7 G* ~, K$ `
  261.     }- i+ \% [: `- F2 |; S
  262.     if(!bRestartUpdater)
    + \+ V' j# W0 a, X
  263.     {
    ' x) t  a; Y) d  N1 a
  264.       int iCurrSize,iFileSize;0 O6 |1 Q3 g5 G7 p* l
  265.       iCurrSize=0;
    ' t" V3 M% ?0 Q* d
  266.       iFileSize=UpdateList2.size();  d; ~, O  ?" Q
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");, Q' G  N' _' l4 j1 J/ O: E& O! f
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");
    9 v! G1 q' a* g2 k& y7 _- f
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");. N. p) O: {4 b5 y. u1 m0 n
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ; a- V% k6 {2 v# F/ v7 H3 M4 U
  271.       Fclearf(".\\update.dat");
    # n( G& u4 }' d& ]( v
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    ' `1 T. G$ \1 {. {9 \8 f2 l" ]
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)9 i" O5 }5 J, n5 e3 V7 v4 \7 [
  274.       {4 V- U4 u7 U' p2 `; V2 E
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end()). f' J7 c2 x' Y# V. L  i1 h5 V
  276.         {" T4 |; Y7 U" h/ A; K( \+ a
  277.           file=(*p).second;6 c: `; i6 k! }' r
  278.           sprintf(filename,"(%s)",file->file);
    & h! {) O; \$ l# ~1 T# J. ]. i
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    3 c8 N; v7 P* K" c* V( P: o* O
  280.           iCurrSize++;: d( F( S  p' y+ x
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));2 Z2 G, i; G$ M, {2 _% S" A# `: E
  282.         }2 r: ]$ d+ F7 V& D, t
  283.       }
      @1 l7 w/ x& D/ N+ h& O
  284.       unlink(".\\update.txt");
    : K; k! u! u8 B5 N* r, {8 j. u
  285.       unlink(".\\update.tmp");
    3 X  n, z2 Z$ z# k9 s/ K; W' d
  286.       Fclearf(".\\checkversion.dat");- X! _8 F5 R, w" v. h2 }& C
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);2 r1 ]# T) E2 ?/ ^( P+ i
  288.       if(UpdateLocal.size())/ `0 H! i9 E! N4 E2 N
  289.       {
    / t& ^/ I1 Y" @5 w  H
  290.         UpdateLocal.clear();
    ; ~5 @( G; L3 R; q* H
  291.       }/ |+ t, K, I( n+ B
  292.       if(UpdateFile3.size())
    6 U; Y! y: N" ~
  293.       {
    ' O4 @" ~2 D2 m" X" j) [" T9 l1 ]  ]
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)0 u& J+ \6 V6 B& u1 I
  295.         {
    ; s5 r' H6 h* B0 q4 c, j
  296.           file=(*p).second;8 g7 G. x. B, b
  297.           free(file);
    9 ?7 X. W6 B2 t8 x
  298.         }' v+ o/ }- L; B. W* |5 `
  299.         UpdateFile3.clear();
    5 [) y- h8 x1 {7 ?" [1 ^
  300.         UpdateList3.clear();
    , [# _+ T, x8 n
  301.       }
    ' v; Z7 D( m% T  C
  302.       if(UpdateFile2.size())
    - i) v+ u1 {" E( q# o( q
  303.       {, o1 ~6 k! c4 ?, j; v7 ^+ E, P( B
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    / Q4 b, D! P/ y$ v, f/ U! D
  305.         {- E1 z! E) V3 a8 h. `) x8 X
  306.           file=(*p).second;
    9 R% G4 y4 q, n/ u6 d
  307.           free(file);
    7 m1 P5 I7 P+ M! f/ k0 Y
  308.         }
    , O! o" H: d  }( s& p* \
  309.         UpdateFile2.clear();
    5 U$ |2 E' Q8 G' U$ |
  310.         UpdateList2.clear();6 q0 }# P7 X! E
  311.       }
    & `, }% t& X! Y+ D
  312.       if(UpdateFile1.size())
    , H5 r) B  {1 [! f
  313.       {
    # L$ [/ T8 p# x' I
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    / u5 m8 l  \8 ]* Y# _6 K3 E4 I  H
  315.         {
    % |- O' U& U1 y4 F
  316.           file=(*p).second;3 P- `* K9 J: z5 X, r5 w+ c, H
  317.           free(file);# E0 s% V1 c+ ?$ V5 w1 ?, j
  318.         }
    ; @7 j% V9 e, \  V# [$ _7 M! R
  319.         UpdateFile1.clear();3 g3 \8 z9 V) U+ z# I
  320.         UpdateList1.clear();
    1 f. E6 n/ B1 g0 d7 `
  321.       }
    9 H$ t+ @/ u# c8 l5 j5 m" k
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
    # m; T1 [" c* o7 B
  323.     }  N9 Y' K- @6 {6 {9 y3 M# z
  324.   }
    : {" n; Z$ U) u, c
  325.   return FALSE;% d; W( L2 r" p+ E9 `6 z: K8 r
  326. }, A! w' Y, m8 _! _

  327. , K/ V$ `7 L) y1 t# Q
  328. void CRevAppApp::ClearAll(void)
    , v1 ~) q" d" H' u
  329. {
    3 I. `7 B0 x5 `  f4 m( u9 \, p
  330.   LPUPDATEFILE file;
    ! a+ X2 n7 ?4 n2 m3 J
  331.   std::map<CString,LPUPDATEFILE>::iterator p;' `+ N5 y: A+ x7 f# `; Z
  332. : C4 X  Z7 s5 ]. \$ {7 V
  333.   if(UpdateLocal.size())
    , s" Q1 p1 O3 Z* H* ^- b0 r: R7 F: O" ~- t
  334.   {9 c* d1 J# J0 ?8 H2 `  n( X- ?
  335.     UpdateLocal.clear();
    % n0 g7 u& A7 W
  336.   }6 T- U0 w- \. @( N# \
  337.   if(UpdateFile3.size())
    1 I* P2 n5 n0 ^& L0 X  S. Y
  338.   {+ r/ o! A" P- b0 U; l! g7 j
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)2 h( u9 W( _( P: ?1 c' i, Q; u! w
  340.     {0 _7 @% r- p+ S  V
  341.       file=(*p).second;3 c/ C( C, ]8 H7 y" g8 O5 p
  342.       free(file);% K- E& d/ e$ H+ U
  343.     }
    1 D7 A9 ^0 X2 M9 c+ B: t8 Y
  344.     UpdateFile3.clear();& U3 ~1 n  t0 _, h# g
  345.     UpdateList3.clear();
    1 ]" g/ J$ P% V/ j
  346.   }! e9 M4 [, V2 o# s2 P, q1 f( [
  347.   if(UpdateFile2.size())2 o7 d* b6 B' [4 \# S! z
  348.   {
      N' ]2 l% D7 R2 ?6 @: Y  W: @4 x& I7 t
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    ! P: k& j: Q* H
  350.     {% c8 X# e; D4 {9 A
  351.       file=(*p).second;
    - _$ a0 c% U6 G6 [1 b
  352.       free(file);
    9 h, @% ^+ _: M2 [  U7 }
  353.     }; J/ B$ c: E# x7 M+ A% g) M
  354.     UpdateFile2.clear();. }: _  r: J* e% P0 ~8 g6 p% T
  355.     UpdateList2.clear();
    ; ?- D9 j: ?) L( R: X
  356.   }
    8 A) @5 c# M. {6 b2 {
  357.   if(UpdateFile1.size())) P6 _, k/ a# x; R  Y. o  `+ F
  358.   {
    . S' ^% M' |4 L" C
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    8 b5 K" l! M9 ~' ~( @3 ~
  360.     {
    * a& B- g4 p5 Z5 z4 B) k
  361.       file=(*p).second;
    / @* R# ~- b' x: Y
  362.       free(file);
    1 W  y9 z9 w2 X5 f. t
  363.     }
    ! f) E4 S3 _* t) y$ N
  364.     UpdateFile1.clear();: t  ^* ?; A2 A- j5 R% C
  365.     UpdateList1.clear();
    & H* |2 P( A* K8 @7 g
  366.   }
    6 l+ H2 Y  E3 R0 y2 U$ ^" O: R
  367. }  
    ' g5 I1 O. ]" m: k3 Z
  368.   
      M0 h) p$ w* r/ }) k) u) M9 G
  369. BOOL CRevAppApp::CheckLocalVersion(void)
    1 m* d) f# s6 b% V  f8 k
  370. {8 B( b( l4 ~4 O' o& s* m; n4 x8 y
  371.   int c;" l8 Z; W: h/ B/ J2 M% H
  372.   LPUPDATEFILE file1,file2;) ^3 E7 a0 }# h1 u7 ^
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    - |, ?0 c7 `! s& B; I& s; P* `
  374.   std::list<CString>::iterator l;
    1 s8 Q! G0 M& l; R

  375. 9 g9 f( v5 t: p
  376.   UpdateLocal.clear();
    4 b6 P2 z$ D- P. P" w
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    " ~2 h8 l3 e  x, ~1 o7 e9 \. `" g
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);  e" I" a* P8 d2 ~9 b  K( h( c' R. ?
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);3 z8 D* J6 b  S# F, d7 D$ G
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);6 w2 i8 X7 @2 E- S% ~8 e6 y
  381.   if(UpdateFile3.size())
    3 f$ ~' }) ]- Q' B! N' F0 S
  382.   {
    ( I1 W3 S5 J! {/ r0 @0 t
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)" C- r6 Z  J8 {+ H1 K) T  Z
  384.     {
    # j! D, C( Q9 L: g2 O
  385.       file2=(LPUPDATEFILE)(*i).second;1 Y' r7 H# m) O8 Q2 V* ^- A* E
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())6 \- J: B& q' Y1 O* {" x5 w0 Y
  387.       {
    6 {' k" g* m5 X; k- o4 C% Q8 c( y
  388.         file1=(LPUPDATEFILE)(*p).second;
    ( o4 h" V) o& |  Q$ k
  389.         file1->vers=file2->vers;
    - l' S, f$ ~% n, y9 P, @
  390.       }
    , Q* J5 Z- O2 f; N0 `; W0 K
  391.       else- B* w' x8 ]' Q; a
  392.       {" V: ?" b2 y4 ~6 M2 a/ }
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    4 T' F( o* R4 ?% n, Q1 H
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));, E% m/ n$ _- Q1 R
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
    . g) f; a6 C. g) ~9 c3 ]
  396.       }
    ( P+ u+ r: w+ f! N' P
  397.     }) R, R. `+ d1 p, E6 R5 J" F( W% `- [5 n
  398.   }
    $ Y! K: j% r$ ~: W
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    , D& [8 l9 O- q, [4 ^7 p' s2 @
  400.   {+ A+ C" f) k0 C) R$ U2 ~7 U' U5 Z
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())( R2 Z- @" h. o1 D" y
  402.     {
    5 N$ O( G( G( V& C' q( y* l2 [% G8 K
  403.       file2=(LPUPDATEFILE)(*i).second;
    : y$ Q. C5 u# Q1 m' X9 X
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())$ k* N3 p  [% J5 f
  405.       {
    * ?# `" u* k8 @  A- l  {  P
  406.         file1=(LPUPDATEFILE)(*p).second;
    / A8 D4 ^; M( N2 \  J
  407.         if(file1->vers!=file2->vers)2 H* y: H1 |9 @
  408.         {- }/ d* P" U* u
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));  O, i3 Q) @0 L7 q8 j
  410.           c++;/ r# w& d& E* A- g% b- i/ f+ O' ^
  411.         }7 w- _3 S7 h2 Q1 c
  412.       }
    8 y( p' f- V" Q6 @- j
  413.       else* d8 D& O0 K# [- d1 c
  414.       {
    % \, \' D2 \1 k5 ?
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));, y$ }2 y. u( i5 j; C
  416.         c++;
    / p5 M- h6 R& J  Z3 q. A
  417.       }  B3 W+ }3 v$ a: K5 C3 i
  418.     }
    " ?# ]: n  h! f+ C
  419.   }* K) ]8 J8 n+ ^/ y; u& N. Z5 J
  420.   unlink(".\\DownLoad\\update.txt");
    - w) N& y3 z3 b" z5 v- r5 R/ h
  421.   if(UpdateLocal.size()) return TRUE;) f+ M1 y4 @  ?9 H
  422.   else                   return FALSE;, B) e1 O4 X: ?( k# S! M3 t! ~' w3 t9 ~
  423. }
    ' _8 X7 ^8 M& D7 B

  424. % v# i( Y$ O) f5 r
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"$ x3 Y7 a5 s7 w' y$ V' J# w% q* F
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"5 y$ R& f" @6 r1 @
  427. $ K5 \7 g3 K# A4 }" c6 L; b

  428. ! A+ y  w  t0 @1 }. g8 F! ^; E  b6 G
  429. ; }( U2 N" i1 C$ X9 c! F
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)8 A+ }% c  [* B4 B0 d% W3 w/ \
  431. {0 g3 D7 U2 Q, S- D# M1 E) I7 [
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;6 r; @' j9 f' C" ]1 j# W
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1): t- \: g& Y( F( ?" c3 y4 B
  434.   {, G1 `2 }5 }6 M0 m6 v9 S. a* h# |4 ^" F) u
  435.     char szLanguage[50];8 X- Q+ x, y) Y. b4 l
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");- U( W, O) h9 v- P- t6 P5 R/ ~
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;- K) y9 K6 G1 f; L, ~, ^
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;) P+ V. H9 E' ~  d* [- w( v
  439.     else                                   m_iLanguage=ENGLISH;0 X# ]0 b- D! w3 G- Y
  440.     char szRegister[100];3 _/ O* b$ L  _$ C7 }, [2 r
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    6 O2 n7 X* S+ z5 ~5 t: P; b
  442.     strRegsName=szRegister;2 w4 g/ {5 A% {# q0 P* O$ u
  443.     char szPatchURL[100];
    % ?; W, h& j2 |0 L1 [* N6 n7 O
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");4 U! n( x+ N9 v- P  y5 K
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);9 K+ Z! F# Z1 E& ]
  446.   }
    , w. t3 M$ S% k% e* d/ Y4 B3 R
  447.   else/ x7 Y! p* l7 x% p( j0 H, |
  448.   {
    ; {+ ]5 [+ `: ^0 e' f) n
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    9 A: T6 ~* N: i: S" R7 R
  450.     strRegsName=DEFAULT_REG_URL;& q% S! L4 x2 t/ c- A2 S% ?& m
  451.   }: k1 c8 d8 s+ d# j
  452.   if(GetFileAttributes("hosts.ini")!=-1)
    ( _+ I: O) g9 V" Q6 Q0 O9 Z. R+ m0 v
  453.   {
    ( T# v, E6 P& _# i9 y9 d8 R4 v/ M
  454.     char szIP[50];
    3 \! @- v( D  o' u# l" o
  455.     char szDIR[300];& y' F  P" c. O( c( i( G
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
    & R& B* r3 u/ k3 X0 D8 N+ n( B
  457.     {- m* ?! v( o4 X% P# h
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");% M& Y: v/ [4 [( e: v
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
    7 n# [+ R* s2 V$ |
  460.       strHostName=szIP;
    ' m, Q: g0 H2 {: z! E( ]
  461.       strHostPath.Format("/%s",szDIR);
    % v8 Y8 b5 X1 }9 ~1 A
  462.     }
    , U3 Z2 f/ {0 u4 P. @; F+ r* x6 g( _
  463.     else
    ; q- U* s# }( M' a
  464.     {  b! V5 S; |( }2 J
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1); C1 u% k- a$ x0 y: F1 Z% w9 ]
  466.       {
    5 y. V0 b9 W, ]! G; J3 ?
  467.         char szLanguage[50];- ?/ Y' l8 T. A/ _' d6 w; s
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    ! _" K9 V3 h7 v/ W' @
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    1 F* C" t% d+ [6 G  I% l3 o* \
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;( m& N2 {" I- T( ~
  471.         else                                   m_iLanguage=ENGLISH;
    ' o4 H3 r, g8 u. p3 {3 H, r
  472.         char szRegister[100];% z: J' L# i& B( E; \
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    9 z# S0 U) U( u$ V" R
  474.         strRegsName=szRegister;
    ! o3 E/ [6 G0 R' L4 }
  475.         char szPatchURL[100];
    2 u" C0 I; X; X$ G7 ]
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    6 z/ v) c, M' T" f& d! g6 ]
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    7 v3 \2 v  _# Z1 G( L: ^- L0 h8 Y
  478.       }7 W/ y7 l4 V3 V0 L2 _4 |( o. s5 X6 \
  479.       else
    ! Y/ J' ?% B9 w$ [# }% @
  480.       {% ]6 E1 l3 F5 W( ]8 Y6 P2 Y
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    # @$ |# e. b9 W( Y
  482.         strRegsName=DEFAULT_REG_URL;
    - D. e# h- b/ q
  483.       }4 y0 |' U2 @  D; j$ |9 _" a
  484.     }
    + t' ^0 K: @6 j, }
  485.   }5 {; g$ V$ t9 U( `, j# ^
  486.   return true;+ a1 \; ^7 V, q2 j% p1 a
  487. }
    0 S* n# @! _" a+ I/ O# S
  488. ( ]& P$ J% Y$ P% X) {& |. t
  489. #include ".\ZLib\unzip.h"$ E/ W* I1 ~3 P3 c
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    " |) Q, ]. j3 A8 H5 K2 F
  491. /////////////////////////////////////////////////////////////////////////////
    9 Y# m! Y3 w" x' H$ e
  492. // CRevAppApp initialization* ]3 O* g  `/ t" O$ ?' V( V" \) y
  493. " C3 p! F. Q, B
  494. BOOL CRevAppApp::InitInstance()
    4 G5 E3 F; N/ I+ W
  495. {
    + s2 A8 N$ P% P4 h5 ^+ S
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];( z$ O6 k& P; ~* `

  497. 3 z8 B2 x; s  o3 N' g5 u
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);3 `9 r) I0 s3 m# I) B2 D
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))
    * h1 [+ j3 a4 a
  500.   {
    . y7 c5 g( Y6 }7 i! T' m  K, A
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
    ' m4 t9 J: X0 S0 H: L1 d
  502.     GetPathFromFullPath(szPathTarget,szPathSource);
    0 q* Y% L4 T3 [7 E2 V7 o3 @
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))
    ) g; e3 r: ]/ Q
  504.     {
    * E/ i! [! ~6 P  n. k0 T. Q. J
  505.       strcpy(szPath,szPathTarget);5 J3 R" D- _. T9 g8 N6 @
  506.       SetCurrentDirectory(szPath);7 a* V4 T! y9 u2 P& C+ v
  507.     }. a& `. |" E1 Y" N- j
  508.   }" [: V! e3 I2 p: ~( q
  509. #ifdef _DEBUG
    6 `7 a% J: f4 M9 d* q+ `* P3 Y
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    $ [$ K1 S  O+ x: z& d+ C. @
  511. #else
    5 F( Y/ }, E! K2 |/ |& |$ M2 R$ ^+ I
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))9 T: o+ N. F/ q& c5 i7 c
  513. #endif$ ~" H, i% U0 E: u6 y
  514.   {
    % h, a* C! Y+ [3 }' z0 U
  515.     char tempFileName[MAX_PATH];' r, u  v2 B# W6 _
  516.     strcpy(tempFileName,szPathSource);
    / N+ Z, D$ z% w3 w1 \5 X
  517.     tempFileName[strlen(szPathSource)-12]=0;1 i7 {3 s1 q2 e4 q2 S
  518.     strcat(tempFileName,"\\$CSUpdate.exe");5 M" x3 L+ E9 U
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);' o/ R# C8 u* F1 a/ m
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);# k1 u  p( `) B% |+ Y. g) J0 x
  521.     return TRUE;% ]* V; C$ o8 _( @
  522.   }* j& R2 X8 ^3 D0 H# ?9 C
  523.   // Nuke 0118: Delete run.exe5 m( y& F; v# s/ u' a9 m, T
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
    , [+ R; M: q- i; X
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");: L. |0 U2 O0 f3 m! k
  526.   if(!ReadCfgFile("Config.ini"))" K$ y% ]6 h3 x% T# ~% ]
  527.   {: J5 T9 w# u) s  a+ P9 u
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);, D- a! B4 C1 g* \( w1 i
  529.     return TRUE;
    9 T! S$ W$ E7 a( R4 l0 ~. I" Q( v
  530.   }
    8 M* k5 m3 S- ~5 w) a2 V
  531.   HANDLE mutex;
    : @* ?$ G7 y  x% d: Q' H  C/ c
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))# Q$ q0 P7 ^1 C
  533.   {# ~+ k5 d, s1 B/ w2 }
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
    : k, D8 h* ~' n- M, `5 N
  535.     {/ v7 j/ L" m$ ^! d
  536.       CloseHandle(mutex);% @5 E2 x& U/ U+ o+ \7 V7 B: f
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);0 H3 M( Q, U" h2 i" E/ c
  538.       return TRUE;
    3 V# O/ Y& N9 v  `: T* |' h
  539.     }
    , G3 I9 j& @; j6 u4 R
  540.   }  
    & ~& @; Z: h; P+ J
  541.   CloseHandle(mutex);$ O( _2 G6 ]3 m8 c" N, u' g

  542. ; ^$ m* }, [; A) Z) ]
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);* q$ k; k- e# \1 r

  544. / ?" d/ X9 @+ f  Q
  545.         AfxEnableControlContainer();" B- L; B; O  y9 k
  546. * l3 `- m3 S! D* _) r( }7 w
  547.   bCanUpdate=FALSE;
    % N6 t9 n/ v$ D$ q' y
  548.   dwStartUpSteps=1;
    : ^& Y$ B* l9 Y4 J& h9 r# p0 I
  549.   dwProgramState=AP_NOTHING;) S( N( O/ g% U) w5 Z# E- X

  550. 3 A- s1 h  E; o/ b* y8 f( P
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);
    : d% l+ i( A& Z, _$ Y9 e) w) C3 g

  552. 3 [. z: E3 |( K( p' O
  553.         // Standard initialization6 m9 S. J/ I8 Q+ f: z8 \% q" @3 y
  554.         // If you are not using these features and wish to reduce the size$ _) W) d% K- Q- h* ^$ c" ^  x
  555.         //  of your final executable, you should remove from the following! `, u4 h6 e' u5 M5 k* q
  556.         //  the specific initialization routines you do not need.2 c( h) t2 d2 M! ?
  557. 9 m) V* T# J' b9 f6 b( W8 X
  558. #ifdef _AFXDLL* L* b3 q3 G- m& w7 M7 G
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL1 c8 }! s0 x8 v4 f% D
  560. #else
    : U  S5 a3 p5 U# z, b7 }2 I, \
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically3 q+ [9 V0 W  K9 |8 z4 u' ^: i" a/ i
  562. #endif
    ; I$ H' [7 t/ K
  563. 0 k1 G4 a2 {% r8 T6 ^
  564.   dlg=new CRevAppDlg;3 z$ e8 @% L) H& [* p1 I
  565.   dlg->Create(IDD_REVAPP_DIALOG);
      H) |  z$ G6 I- g7 |  o9 X
  566.   dlg->ShowWindow(SW_SHOWNORMAL);5 Q$ }+ Z$ N& K
  567.   m_pMainWnd=dlg;
    2 Y$ o! P3 @7 E7 K

  568. 5 n  @. D9 j% p& o. v# c
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);
    * V8 ]0 q- u+ D, m# z8 o- A4 i: h
  570. & H, I% e* V4 R& O1 J) N  [
  571. //  GdiplusStartupInput gdiplusStartupInput;
    7 y0 F3 a) \4 J0 j
  572. //  ULONG_PTR gdiplusToken;1 T9 p3 n* b4 l1 X* D  c
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);! r* u: Y( H) k6 c
  574. ( G8 Z( K2 Q2 k; _- L4 D' U
  575. //        CRevAppDlg dlg;
    # T* H; A# N5 o
  576. //        int nResponse = dlg.DoModal();8 i7 u: W% Z) R: ?0 q, H' I3 @. n: J& X
  577. //        if (nResponse == IDOK)
    1 c2 |) R+ y7 S3 u5 T; |; C
  578. //        {0 C% w" t- R) ]' H5 G+ S! Q
  579. //                // TODO: Place code here to handle when the dialog is
    & Q1 z* s) T4 F9 f4 n
  580. //                //  dismissed with OK
    " a- ~! P% @/ L5 @+ p
  581. //        }7 D, w$ L+ z' b3 [1 N& ~) O
  582. //        else if (nResponse == IDCANCEL)" n8 p, f6 |5 ?5 e& F
  583. //        {8 U" L1 ^6 l# u
  584. //                // TODO: Place code here to handle when the dialog is. M+ a& n* p9 A. x2 L
  585. //                //  dismissed with Cancel
    . }6 K. y+ K+ P
  586. //        }
    9 v7 l3 |0 o5 o! B( s: q% g3 K' `
  587. 9 L/ p3 `. r- D# o) E
  588.         // Since the dialog has been closed, return FALSE so that we exit the2 u) |* _3 T' w
  589.         //  application, rather than start the application's message pump.
    9 Z% g7 H. q5 L. u, C
  590.         return TRUE;5 |* U' i; r$ R: |
  591. }5 n- o6 r. c& `! P, H

  592. . h4 r0 h0 G+ D" T! {9 ~) {1 x
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    ; ?+ l  q, H4 ?8 b  H2 P0 h# V
  594. {
    & s( Y* c7 b7 W8 \+ I4 c' t, U
  595.   int i;
    & U! ]& y% h& L6 B3 @! P
  596.   char *szRet;
    8 [2 U( z5 E9 T+ |( b) G, E

  597. 3 J: e$ @( x, t# B/ n( v
  598.   if(pSource) { itoken=0; sztoken=pSource; }
    1 u2 ^) O0 L( [
  599.   if(sztoken)
    , t9 {! \6 ~5 E
  600.   {6 A  G. N0 U7 S4 b9 W6 p
  601.     szRet=&sztoken[itoken];
      n2 t  i. ^$ B+ j* M
  602.     while(sztoken[itoken])
    / m# R! S4 S3 q* B5 F# f/ A
  603.     {
    6 `) ~. X2 [# `* L  ~
  604.       for(i=0;i<(int)strlen(token);i++)% y/ m: Y1 }+ w8 ?0 F" y
  605.       {6 Y5 l% r, {/ K. Q: s& C
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])8 U; A! s1 D( i6 X5 \, K9 z+ e
  607.         {( J* T' R/ G9 w0 [4 w# ~+ y5 l
  608.           sztoken[itoken++]=0;) w  s+ \7 s4 M) H9 ]
  609.           sztoken[itoken++]=0;! X) @7 f$ a& b" ^, r+ g
  610.           return szRet;4 P; Y! A! d; T* X1 b7 K
  611.         }) _2 V" ~* G( K$ S" N- I
  612.       }
    3 u$ t* ^: V5 K" Q4 o6 k! l
  613.       itoken++;
    ( t% X. ?; _8 M, j
  614.     }, z  v8 v' m+ @6 ^
  615.   }6 n& k4 q. M- v1 ]; y% p; _
  616.   return NULL;
    # P1 U- e7 U& a4 N5 A* f; Q6 f
  617. }. T$ s2 D2 _1 {" A* ~

  618. # c! b: L8 M' ?) p# T7 T
  619. void ProcessProc(long Total,long Current)
    3 g" r# _) n/ S
  620. {
    # {0 x; q& B4 ~( q, k0 q
  621.         MSG msg;+ ?& u, P0 E0 z
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);
    5 Z( |7 U- p/ M4 V6 j; k
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));
    ) B" {6 q% G* d
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
    5 f. b! F2 L/ P# V
  625.         {: n" H/ h9 k/ [6 W
  626.                 if(!GetMessage(&msg,NULL,0,0))
    $ Q# Q. C0 Y4 ^# G" L& `
  627.                 {
    ! @, C8 g% A1 v5 O
  628.                         return;. m' ~1 n3 k1 E& ?6 |: L% t
  629.                 }
    % |" O& D+ f# J
  630.                 TranslateMessage(&msg);
    0 ~& L8 y9 D; }& k' @6 D" n
  631.                 DispatchMessage(&msg);
    6 n; J# X( Y% C5 l
  632.         }       
    ! k4 l7 e* h/ F' ]% X
  633. }
    ) j6 N  v/ z  S! i, x
  634. ! j7 m& a* O  c0 Z" A2 J
  635. BOOL bFirstChar=TRUE;7 B  c$ d1 U- j- D! R: b3 S/ y

  636. $ r. [/ i9 T% o  r
  637. BOOL CRevAppApp::OnIdle(LONG lCount)
    . x2 m7 j: E- I1 T! j6 n
  638. {
    - H' H% Y5 x1 N' B$ a
  639.         // TODO: Add your specialized code here and/or call the base class
    # D1 m  V4 d1 h) L) e0 e+ }
  640.   switch(dwProgramState)* P/ j" \" i. D) S! K
  641.   {
    & d! C3 I0 D# |7 L
  642.   case AP_NOTHING:
    1 y1 d4 W6 O3 T) T
  643.     switch(dwStartUpSteps); ~" b6 F) w6 ?9 w7 Q
  644.     {* U1 F2 e5 t8 N6 b3 I. A! C
  645.     case 1:1 |0 d+ |, B7 \6 ?  x( Q% w9 @
  646.       {
    - @. ]; b+ ]- L! m/ W/ ]6 [( z8 B
  647.         int i;
    , C# A3 s' U" ?% y  G2 Y' y
  648.         CDC *pCDC=dlg->GetDC();
    5 x$ P4 E9 u* `7 C" r4 n, o
  649.         HDC hdcwnd=pCDC->m_hDC;/ K6 z# X% E5 c; K9 }( X
  650. //        Graphics graphics(hdcwnd);
    4 H. s/ h7 ^' @* g0 z3 C
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");
    - Q2 X$ [- H9 o/ `! v& h
  652. //        INT iWidth=bitmap.GetWidth();% ?3 e, [# n( M0 R8 S) w+ G
  653. //        INT iHeight=bitmap.GetHeight();
    ( k1 K6 B; \8 C! N5 Q
  654. //        Color color,colorTemp;
    ! J0 f2 r0 l( I- n* y5 L
  655. //        for(INT iRow=0;iRow<iHeight;iRow++). L- @  x$ {5 z  r" L5 L& z4 `
  656. //        {3 ^: K  \" h1 C
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)
    : r& n$ r( J9 W( J' `, Z8 x
  658. //          {
    + T3 D/ o" b7 ^3 L% t
  659. //            bitmap.GetPixel(iColumn,iRow,&color);
    # O5 m+ e# `* z7 ]. E6 p4 h  h% u
  660. //            colorTemp.SetValue(color.MakeARGB(
    # L, o6 T2 K/ K' j" O2 I
  661. //              (BYTE)(255*iColumn/iWidth),
    $ ~5 d1 ~: |. v% b
  662. //              color.GetRed(),. Q0 q5 y7 t/ u
  663. //              color.GetGreen(),
    , u. ~3 M9 o) ]) {( }" k5 V. }, S
  664. //              color.GetBlue()));! I' B, _5 W/ _" A# }! E% y
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);
    ; q7 O  M% [3 \
  666. //          }* r) R8 U" V& Z
  667. //        }; O$ k7 j/ W/ E2 Z% ^! W; |
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    . x% P! O5 `2 C4 g8 Y" Z) V
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");, G, ?$ O2 j, P9 [6 j
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");0 y/ b9 c3 X9 a, `( D5 I3 C" t
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");& A% u2 M' Z8 G/ i9 k! N, b5 Z+ n
  672.         for(i=0;i<240;i+=8)
    0 {; h: w1 |+ ~/ b+ F6 ?
  673.         {
      G5 o2 p6 v# f1 p
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    0 W! K% y( e$ ]5 Y1 `
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);5 e( x6 c3 y- M7 O7 T1 j+ o9 V
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);0 t2 y0 l5 Y, b5 w9 b
  677.           Sleep(33);9 W9 v  T+ c  w2 T' Z( C, M. _8 A/ }
  678.         }
    9 h+ z) l/ l8 \' L& A
  679.         Sleep(1000);
    5 }( l: z! @+ I$ {
  680.         for(i=240;i>0;i-=8)
    3 l6 }8 K( o! z& T
  681.         {
    ! x7 G9 V. e  q2 T4 J6 }  \
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);1 W4 D3 ]* u0 [" Y7 h8 J) y5 l
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    # h9 ]$ N" M/ c8 H" ?) a
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);# G& a1 `0 x! i, T2 k0 ?
  685.           Sleep(33);
    6 I7 k3 n8 F! v9 p# Z, r( @0 U# ?
  686.         }) x! Q- a; @1 [& X. r
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);* I1 i- z1 U+ ^; ~* h
  688.         dlg->ReleaseDC(pCDC);
    9 B% {* F- H( R' [- M
  689.         DeleteDC(hdctar);3 R( C7 W# R9 q/ H  Q, |
  690.         DeleteDC(hdcsrc);
    # N  D1 J  y! T; K2 [3 L( J  i
  691.         DeleteDC(hdcorg);
    : O/ z/ z( k& M! {' W
  692.       }# q5 e% v2 `7 f9 i- q+ l
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);
    , y1 y4 W2 W0 y9 ?: S
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");8 `4 E- u# b: q% V0 d& P1 l
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");
    " h0 y, z* T: p
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");
    : ^& `+ L( {/ L5 C
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
      n, Q1 |6 ^4 f
  698.       if(!Dn.Connected())
    : T, r* o; l5 J- {
  699.       {
    " x! O, X! Y/ k9 B6 ~+ _
  700.         dwTotalFiles=1;( ]4 e' K% `2 {: S% M- S; a' q. F
  701.         dwDownLoaded=0;
    . X8 r- f3 H1 Y4 u$ ~
  702.         bSilentStep=TRUE;
    ' n2 \" L2 w% R" e( }% e; C& Q
  703.         bCompressed=FALSE;
    - Y8 g$ f% D( H4 P$ h+ l2 C% A  b+ d
  704.         strExtLocal.Empty();
    ' W2 P$ Y+ n* e+ y3 j( ]
  705.         strFullName="readme.txt";
    & U& F  R# ]; C9 Z' Y# o
  706.         dwProgramState=AP_CONNECT;3 t& _2 B. t- d2 {
  707.       }, J4 i, o* k5 [
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();. i) X# b! m/ y/ N
  709.       dwStartUpSteps=2;
    : ~% t2 [, x5 }: v! Q( o
  710.       break;. G7 D( w; _! ?9 ?  l
  711.     case 2:2 X7 N/ Q6 r' C3 [
  712.       {
    ! r. `; }, K: g8 L; H
  713.         int iEOF;
    ; ]$ u0 f2 D' ^
  714.         FILE *fp;8 b- R  s* S1 L8 s/ e4 M
  715.         char szString[512];
    # d2 A% _  j  `& C4 ^- b% H9 U' B* }
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");
    . q) A& Z2 n4 T  u0 i( h# @9 z
  717.         if(fp)
    + u" @: z$ s2 [$ c
  718.         {
    ; `3 k; Y3 G: @9 ]$ ]
  719.           do
    9 j. Q9 c! ^7 M1 ~9 e
  720.           {$ p. j9 y8 R( K6 S+ ~! N1 g& r
  721.             iEOF=fscanf(fp,"%s",szString);: c) `0 D/ t  d* d- k: B" u
  722.             if(strlen(szString))
    0 J! B4 D$ n2 {+ e
  723.             {* {! q" m1 F1 _2 n6 |! n
  724.               if(bFirstChar)
    " y# K& Q- {" s8 F5 N
  725.               {) Y6 |8 T& X; L5 c
  726.                 bFirstChar=FALSE;
    2 n* {2 ~+ }% R! A0 f
  727.                 bConnectIsBig5=FALSE;  T8 h1 a6 d9 q; a
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;  ?6 _+ `( U7 l$ C3 A8 u+ P- l# H
  729.               }8 G  \1 v  S, d  A& {
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
    1 B! _7 [% Y' R3 D
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));- \% s. N  l. Y1 E2 v1 O
  732.               dlg->m_ListText.AddString(szString);$ u2 ]- n4 j5 i& d" {0 V
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    . @! I/ S! f6 ~* f5 @  D& E
  734.               *szString=0;  Y, q: f% a$ h; @
  735.             }
    : _9 G1 h; M, e6 T  V
  736.           } while(iEOF!=EOF);
    ( U: k, J+ f$ ~, m
  737.           fclose(fp);
    ! b7 E" e8 w  D; G, p
  738.           unlink(".\\DownLoad\\readme.txt");6 B& r! {' Z; I8 b" b) _7 f( \8 x5 P: B
  739.           dwStartUpSteps=3;# C5 u" b& v6 [! L" E8 J
  740.         }
    ( @  p6 r( y* j4 s" N* ]
  741.       }2 P' ]# p) m  q' v7 N
  742.       break;
    + @5 C* c1 E: N- ~( N! m% u
  743.     case 3:
    & c/ p8 a0 m% O
  744.       if(!Dn.Connected())
    % N  j" ~1 Z! J* [7 ^" Q
  745.       {) a4 @( e* w5 ^% Z5 w: O' n
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);, A) C* j% }+ G) @
  747.         dwTotalFiles=1;2 h& U% M3 w' e
  748.         dwDownLoaded=0;* ~. i8 K2 t6 ]! R. R0 m# d
  749.         bSilentStep=TRUE;
    8 y& a7 Q1 N8 t* r( D( ^7 h
  750.         bCompressed=FALSE;
    4 {! Q3 R; i0 C2 B  Y. }
  751.         strExtLocal.Empty();
    8 [- Q! R4 J, j
  752.         strFullName="checkversion.txt";
    % Y7 a& d0 X( g7 W
  753.         dwProgramState=AP_CONNECT;
    1 T* |/ H' j. A7 u
  754.       }  M2 P8 W$ H% k/ \) Q& q5 L
  755.       dwStartUpSteps=4;7 g. {+ h" A5 f% [5 ?1 ^
  756.       break;
    + h/ i5 z0 l4 R3 e+ b. ]9 B
  757.     case 4:) d0 o! R% O5 ^4 B" w
  758.       {
    * l6 \" O( w3 @) ?
  759.         FILE *fp;
    * @5 u, z* l" `/ I" q
  760.         char szString1[128];
    ( `1 M- t! M9 U' ^1 ]" J' a8 k
  761.         char szString2[128];; a' |0 H- ~5 e1 b
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");0 O$ t3 f1 f* `" ?6 P" f" T3 ~
  763.         if(fp)
    $ `% ?3 a# t7 t4 H9 z3 F
  764.         {6 E- d! K- f; ^2 P2 a# ^
  765.           fscanf(fp,"%s",szString1);
    " Y% T8 @8 m: A: c
  766.           fclose(fp);' X0 J8 u6 v9 q& d' I$ a1 u! u
  767.           fCheckVersion=atof(szString1);
    ' @6 [/ z  E% \0 D5 R2 j
  768.           fp=fopen(".\\checkversion.dat","r");
    7 S3 }( s; Q  E
  769.           if(fp), a/ i" j0 R6 a3 g4 w' N
  770.           {9 E4 {' v4 g. N: `! H. J
  771.             fscanf(fp,"%s",szString2);( ^5 T: p  @( ^8 o
  772.             fclose(fp);
    " u' L# I" u. R
  773.             if(atof(szString1)!=atof(szString2))
    4 D- v0 F' M, ~( b' f4 c
  774.             {- ~/ A0 C: ?9 C6 u
  775.               if(!Dn.Connected())
    ) W, t5 Q5 I2 \/ v" x. u
  776.               {
    # d- p. X% g+ Z' i# S8 l, {& x
  777.                 bFirstUpdate=TRUE;: C3 W: K5 M& P, b/ @. |/ m* ]
  778.                 dwTotalFiles=1;
    ( @, o* |( x9 G
  779.                 dwDownLoaded=0;5 L/ T# m& j+ R; }/ ^* U. E& O
  780.                 bSilentStep=FALSE;
    + i+ ]. i$ ]0 k& O" U& R* z
  781.                 bCompressed=TRUE;
    & i4 j! o' B9 i8 N& Y- `' b/ D
  782.                 strExtLocal=".\\DownLoad\";. ]0 J  J1 O8 x5 @; q# H
  783.                 strFullName="update.txt";* c8 G2 Q5 D0 y
  784.                 dwProgramState=AP_CONNECT;. p4 ~/ s* Q$ q3 J
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    ) E% f$ I- _: {6 m/ o. H: Z
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");8 R( h/ h: t3 P. P, Z
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");' v9 ]+ X( b& f4 B; k$ t

  788. 9 x7 @6 o% Z  H
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    + F4 G. E* s" K
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    % A6 n5 f; t; S7 X9 @
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1): l8 _8 }, ?+ E& B" o
  792.                 {, @/ R2 T6 I8 W
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
    9 \1 G: J' V4 {- {' L- E' M2 O
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");* |) v2 s  A# d' Z/ L
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");. K- i) E6 Q" f5 T
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    # k3 q8 ^; b) C( z0 B2 H
  797. 3 k& Z3 p- B: ]* o- E
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    ; J. ?9 C* E! j5 ~- {
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");5 R. n; q. S. q; ]2 v
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");4 u) e4 a' c4 _0 [
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);) b' a/ `5 f. J3 E6 p/ v7 K" ?
  802.                 }
      q3 ]* ]7 i6 y! Z2 i
  803.                 dwStartUpSteps=5;3 A9 V4 x4 r9 U3 F
  804.               }
    / N. {  ^" {; G
  805.             }6 v3 j% S9 R7 r" ]6 v! p3 B4 Y5 e
  806.             else" I/ [5 o: X8 q4 ^# u7 |$ W  s
  807.             {* W8 ~, e+ Z/ X# k
  808.               unlink(".\\DownLoad\\checkversion.txt");' G1 N8 s8 P  n1 }- ~) C
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    , }, d8 Z( ^( O, i( P! e! t
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    : @& q8 |6 [% f+ k- X* ~
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");
    % }, w. d; o" ^5 u. r+ j% d
  812. 3 M) ]+ S& G2 ^' B( q5 H0 s; e
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);2 o; w+ Y9 B' G+ g5 h
  814.               dwStartUpSteps=99;; o5 U7 y* q5 L' o9 T* `) z
  815.               bFinishUpdated=TRUE;
    7 A: k! o+ G& ~9 s
  816.               bCanUpdate=TRUE;. j+ N. w" ~8 X. w7 c
  817.             }; g! N. v* Q2 z3 Z( u7 ]6 l1 S1 r
  818.           }
    7 H# r/ ^5 F1 D* T
  819.           else' u# Q& x+ u% [( Z- @$ v
  820.           {) i& t% X% |4 H
  821.             if(!Dn.Connected())# ~4 L5 A; d  w" J( \$ G
  822.             {9 i5 B6 }+ g2 p5 j4 a
  823.               bFirstUpdate=TRUE;
    $ x" p+ ^: _1 s6 V
  824.               dwTotalFiles=1;. d# {, _  m5 |  G
  825.               dwDownLoaded=0;
    + `$ ?7 N" Y5 O. @
  826.               bSilentStep=FALSE;
    3 c& T7 K1 R9 n$ V6 Q/ W! {
  827.               bCompressed=TRUE;
    * N, r$ ^6 i2 Z5 Y+ S
  828.               strExtLocal=".\\DownLoad\";
    1 n) _0 `  n- H+ d
  829.               strFullName="update.txt";' m, y: }0 Q- n5 F* q% {
  830.               dwProgramState=AP_CONNECT;  x# y6 a' P! ]8 Z; g0 T) ?
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
      w9 e+ l+ U) ]: M4 g) L% M
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");: m* z! W! G2 ]6 `, }  Q2 K( l$ @
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");" y+ h' G( N9 k6 T5 T4 e5 x
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ Y8 {6 F1 c# X# S
  835.               unlink(".\\DownLoad\\checkversion.txt");
    $ I7 N! D! z5 k+ `- [
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)
    1 ~. D3 ^4 g3 r9 W* a" j; W+ L
  837.               {7 G. n7 J! Z9 M: m* T
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");. r  D% z) m2 |7 R# S3 W6 U
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");
    9 y; k) B4 ~7 J3 ?! r* M8 ?  k
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");. w$ T6 g. ]" S3 q% i6 `# e
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);, n) Y$ U( V  ?" |9 q
  842.                 9 d7 n/ v) j! g- w
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    + [( S+ W7 K; Y  R/ ?
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    ! C$ r/ R, h( j+ _+ [
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");3 ?+ t; b! p. M! Q9 Y+ `
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
      }9 N4 p, @' U
  847.               }: R+ k1 A( J& f& S
  848.               dwStartUpSteps=5;: s/ W! y2 T: Y& t+ p
  849.             }1 _- F$ E. C# O# y8 b  G# s
  850.           }! i% u) C& N' @- s
  851.         }* X, v" L, x: g
  852.         else
    4 U0 ]: [! n) G4 s' m( J* b
  853.         {. `1 `. j4 s! l4 V$ [
  854.           dwStartUpSteps=3;
    2 e- U( ~# N* e. O( d. R
  855.         }
    - L; Y8 i" m0 f2 ~$ p) s
  856.       }, h' Z- a1 ?. S' T7 r
  857.       break;
    0 ?2 u1 p$ `6 U9 ?1 L
  858.     case 5:
    ! w' K6 Q$ q/ K5 S' F
  859.       {- n9 T: p' c( y9 x, o9 j3 I
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)3 @$ U" e. G& S/ g
  861.         {' B! f0 X2 I1 N" N, [
  862.           int opt_overwrite=1;3 m9 v& G$ @+ q( A% O& f2 [! h9 T
  863.           int opt_do_extract_withoutpath=0;
    / T& T0 F2 C0 }5 {3 O/ O3 I9 d
  864.           unzFile uf=NULL;
    . k, m1 w) |9 d
  865. ! h! i- u  x: q7 n* A) Z% F
  866.           uf=unzOpen("Wsa.zip");* W# d9 o- D2 K. q
  867.           if(uf)- C# m8 m+ }/ a5 b5 B' f5 S
  868.           {
    + ]5 x# c- F7 n8 u9 L
  869.             do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
    9 D3 M1 c% K# B- g
  870.             unzClose(uf);
    + E7 k. D- f( x9 H! c
  871.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃ЧΘ.....");8 ]' B7 i# r8 j
  872.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压完成.....");
    - v1 R7 _, c) s3 |) Z9 @
  873.             else                                                      dlg->m_ListText.AddString("Unzip OK.....");
    , V2 j+ i0 g* n. h( ^/ [1 ~+ @
  874.                                           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ' Q- ^3 {. k- P8 [: ^; M; v
  875.           }  {( W6 w" B/ M5 I2 {$ U& d2 ?/ R
  876.           DeleteFile("Wsa.zip" );
    ) f4 O6 [1 K$ X0 w6 l
  877.         }' X+ w" O( c- ?3 P! x0 I
  878. ; s* Y6 f/ y  k9 _8 `
  879.         if(CheckLocalVersion())" m/ Y& ^- C2 i! @
  880.         {0 I5 L/ S7 ^+ J# z
  881.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫磅︽絬穝戈.....");  T3 B" {: }* l- z5 ^" a
  882.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请执行线上更新资料.....");
    9 J, @0 a; F3 P) {. O% p, ?
  883.           else                                                      dlg->m_ListText.AddString("Please update.....");' d* W: B; M' P6 _  n; X- e, L
  884.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);* i0 Y* V5 p- D" i
  885.           SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);  n$ U. q5 k% x5 p0 C
  886.           dwStartUpSteps=99;
    - X/ X9 N8 s) g% L4 }/ n' b
  887.         }
    ' B1 g0 @* y# T9 K# b0 [
  888.         else+ {$ l- V; k9 u% e' t4 c* h
  889.         {# Y  K' z: }' j' J9 y, t
  890.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    ! n6 e% x: c4 u
  891.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    ( A  I9 V* M# v+ N7 f% t
  892.           else                                                      dlg->m_ListText.AddString("no new file update.....");
    0 g7 t9 b. q4 W

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

2 i' F2 b2 f6 u7 A; `1 e

評分

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

查看全部評分

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

本版積分規則

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

GMT+8, 2026-2-15 22:27

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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