CSUpdate.exe源代码

[複製鏈接]
洛小枫 發表於 2018-1-26 20:48:40 | 顯示全部樓層 |閲讀模式
4 J7 e2 F: ^9 B% v( X  M
  1. / RevApp.cpp : Defines the class behaviors for the application.7 {1 ^) R( m* F1 |5 _' i& E
  2. //
    5 H; H# D% N, X& f6 u1 }! f
  3. 3 @. [. a2 k* H- e* L) o8 n7 F
  4. #include "stdafx.h"
    * \% A+ z1 ~, A
  5. & D+ D! z) P4 g
  6. //#define UNICODE
    % T9 ^3 |$ Q4 t. S# f
  7. //#include <gdiplus.h>
    7 l8 w3 Z3 ]8 Q" w8 Z
  8. //using namespace Gdiplus;6 k6 i4 B8 y& X% n7 q
  9. , Y4 C$ d, F$ m6 ~4 ]
  10. #include "RevApp.h"4 g9 I& r9 i( l" ^# X* V4 R; l
  11. #include "RevAppDlg.h"# [9 O1 c* L" u  n- W

  12. % ]6 t/ l' f& j; K7 S5 H
  13. #pragma warning(disable:4786)
    : V5 W) J7 U+ p& B: D
  14. #include <map>
    2 ~. V3 r1 o' \0 Y+ |$ C
  15. #include <list>8 N, \, [4 O3 h$ r
  16. #include <direct.h>+ R- W% o# E8 z5 M0 f- A3 }; x3 C. m

  17. . \# l4 a  ~1 ?( x* F9 y; L
  18. #ifdef _DEBUG  J) O6 U' N& P9 C) R5 N
  19. #define new DEBUG_NEW
    , I- ?+ y: a6 E5 O/ m/ H
  20. #undef THIS_FILE
    " O! l% d8 v% i
  21. static char THIS_FILE[] = __FILE__;7 \# J- V0 P4 E8 ?
  22. #endif
    2 y7 U4 H+ b2 G" J: a
  23. #include "SkinResDef.h": }4 V9 U( X5 c% N' W. n
  24. #include "ChangeBG.h"3 L' }7 K# r% _) k- H) H8 H
  25. #include "AFXINET.H"
    - m: h% p  E+ }- N

  26. + ?, ~1 S8 W' L( k& C) X3 M. C; S7 k
  27. #define TRADITIONAL_CHINESE 0
    " M3 ~  V3 X2 C* U- M" ~' z
  28. #define SIMPLIFY_CHINESE 1
    " w5 q  `0 F  d; }+ C1 P: G
  29. #define ENGLISH 28 T' ~( }, [8 F" U
  30. int m_iLanguage = ENGLISH;
    4 V. _; ], |' t& N: N, p; f: w
  31. /////////////////////////////////////////////////////////////////////////////
    5 e$ j" N, ?3 O7 A  t
  32. // CRevAppApp
    ! l2 W- c2 T/ `* h4 N
  33. ( ^+ R7 b3 K& F$ B. O0 S3 F
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    , K) A3 ^8 L& J# {! a8 Y# ]$ [
  35.         //{{AFX_MSG_MAP(CRevAppApp)2 ~5 r8 a# ]2 l& f
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.
    3 p' s& N. z: S( j  a$ R5 n% ?0 v- O
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!
    ! u& V. G5 z! w+ i  T
  38.         //}}AFX_MSG
    . t' Y& P! P4 Z/ y! w; g
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)6 V, |* @4 T6 @# v
  40. END_MESSAGE_MAP()5 n- D7 R/ ^( e. ]
  41. - e5 y$ b. W) N3 y3 B& \: O
  42. /////////////////////////////////////////////////////////////////////////////
    : h" c, N- ?! ~/ ?* u8 q
  43. // CRevAppApp construction& C( ?* S; M5 {" M5 C2 [  C

  44. . U8 n* S" [" W% J) Y, j
  45. CRevAppApp::CRevAppApp()
    6 q9 V/ O' O- B) ~* ~# F0 s
  46. {
    # {4 m5 X% g* d# _; I
  47.         // TODO: add construction code here,
    ) X$ u* I, A. v$ }* N' v, g
  48.         // Place all significant initialization in InitInstance' c' \7 u  G/ k
  49.   bDisplayIsBig5=FALSE;, O) F8 g; z8 U/ Q' C7 H
  50.   bRestartUpdater=FALSE;
    0 V8 y1 }# o0 U, }% F0 L
  51.   bFinishUpdated=FALSE;9 A$ w1 O* @7 f1 ]* _' ?: B8 ?
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;
    . l9 n  ?7 \2 B& x
  53.   InitChangeDataBig52GBKS();
    4 h: x5 X0 l% O9 J+ G" w5 y% u
  54.   InitChangeDataGBKS2Big5();
    7 c' ]' X  {9 l8 S3 S+ d. }& }5 V
  55.         //
    4 u. v( a5 Y, P: u4 `
  56.         bClickRunExe = FALSE;! O& {) L% ?5 j# S3 l
  57.         //# s% L; d/ B9 t7 v- S/ L) W; l
  58. }
    & K4 p& i% q  V5 Q/ O+ r

  59. ) a% d% \9 ?1 Q" H7 P& f# {  I
  60. CRevAppApp::~CRevAppApp()
    8 L' G. r! z" ?
  61. {" W7 R& s3 |) d
  62.         // TODO: add construction code here,
    # C8 C7 L) }, N3 U- N% n
  63.         // Place all significant initialization in InitInstance# d9 |; q. ^- n9 X3 R
  64.   EndChangeData();# t; v* }% _& Z; C( X% p
  65. }$ v0 K3 r% c# A. U3 U

  66. : K2 I, {+ Q9 v. w: |
  67. /////////////////////////////////////////////////////////////////////////////3 r# s2 P1 \; R* u/ [4 ?
  68. // The one and only CRevAppApp object
    ! v' h$ @7 E4 z6 _1 d' z

  69. # `9 ?; Z( Z( R) g2 b5 F
  70. CRevAppApp theApp;
    2 g! ]' c1 E. g4 d* C9 B

  71. 1 ^1 k$ ^" z- J
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName): b. d# V' f) `( B
  73. {
    4 u3 n8 J- e, F+ S9 p
  74.   int iEOF=0;
    7 J7 a' A! f0 D' M* G; ^" q$ c7 u
  75.   char szTempName[MAX_PATH];! T9 R( [* b6 A
  76.   *szFileName=0;& D0 ?0 k2 _- b( p& {9 O8 K
  77.   iEOF=fscanf(fp,"%s",szTempName);
    % p1 F( ]9 |+ o2 E
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    9 m' m! n( E! a2 \
  79.   {0 S, Q# r& U9 H7 o& a4 m: p+ r% y
  80.     strcpy(szFileName,&szTempName[1]);
    ) g* G) v/ D1 i: y5 x: W( ~. a
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    " l; ^! L- o2 q
  82.     {
    " _9 z9 W4 S* z. {6 `
  83.       iEOF=fscanf(fp,"%s",szTempName);! k$ ~0 p% ?' X. ^- @/ }
  84.       strcat(szFileName," ");
    4 p. w, v' U& `2 K
  85.       strcat(szFileName,szTempName);
    9 Y$ ^1 C7 b. |$ ~
  86.     }
    ; K# m( b4 F$ U4 k2 o
  87.     if(strlen(szFileName)>=1)
    * ]  e" B8 ~5 {; y' n" a2 q0 C
  88.     {
    ; E: v' ~5 Q  M
  89.       szFileName[strlen(szFileName)-1]=0;2 n3 n% u$ J# T+ s% H
  90.     }' `4 G3 d9 q& g! p6 H0 e$ K' \
  91.   }
    7 n9 p0 u& \( M( q+ w: `; R- O4 Z
  92.   return szFileName;
    7 K& z2 i; s2 H! ?1 y: U
  93. }+ j0 y/ ^7 f. h
  94. 4 _' V8 O. D% T; g% n  }  [2 j
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)5 w$ z% \) `) [- _5 e  L' D/ p1 c
  96. {4 x- }0 D% g9 E
  97.   FILE *fp;' L. b' c+ F& T" [( A& f
  98.   char *key=NULL;0 g* n9 X& i. r
  99.   char version[MAX_PATH];
    2 D# b) m# e; ]! |4 C, W; E: T0 T" w
  100.   LPUPDATEFILE file,olds;+ B0 q+ u, t5 N& w+ a1 J2 d
  101.   std::map<CString,LPUPDATEFILE>::iterator p;$ r2 V3 I$ m  m5 O

  102. 1 y  s. t2 \% T2 i
  103.   UpdateList.clear();
    ; `5 i- o' g# c. w' t* |8 L, w
  104.   UpdateFile.clear();* @9 S  @0 t3 @/ w
  105.   if(GetFileAttributes(filename)==-1) return false;
    5 v0 P& n! v; V- b
  106.   if(!(fp=fopen(filename,"r"))) return false;# a; v0 F2 `  p& L
  107.   fscanf(fp,"%s",version);
    % A( m5 z: P8 p* I3 {( v
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }, G6 N1 m& n, E, d
  109.   while(fscanf(fp,"%s",version)!=EOF)
    ; l6 [' R: \! ]4 W. `% U4 u
  110.   {
    ; i) v* r; s! F3 M" X5 A3 d
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    - r# i+ ~, C4 v& ^1 q% H4 _
  112.     fscanf(fp,"%s",file->path);6 T: @& ?* S' }: |' m, O* Y4 V7 N4 y. \
  113.     ReadFileNames(fp,file->file);
    1 X) W, @) V: \; K7 V6 W
  114.     strcpy(file->full,".");
    4 X% |7 s: n+ P( S. M
  115.     strcat(file->full,file->path);
    # _6 @7 U; K' g8 h
  116.     strcat(file->full,file->file);( z8 \+ z# k* B) R& S9 r
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())
    ( P" p- V3 L4 M0 [. u
  118.     {3 b) H" N' @4 m4 C1 s6 U
  119.       file->vers=(float)atof(version);
    6 B8 i1 C0 D6 f1 e9 t9 @
  120.       UpdateList.push_back(file->full);
    / C- w  b1 i5 g" Y2 I* @, d
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
      F9 o' T( d; l- u% b
  122.     }) h% h/ c& R1 C- a! o* p( |7 t
  123.     else
    7 o# `, W8 O6 g' }2 u
  124.     {4 Q  h$ y; e7 i
  125.       olds=(*p).second;7 w: i; X7 p: h5 c) u- G  m1 D
  126.       if(olds->vers<(float)atof(version))
    + D! y# v% s" d, v
  127.       {
    1 i* {% Z6 P  B+ }' Z4 _  Q; F( Z
  128.         olds->vers=(float)atof(version);* ?1 a8 S3 W9 a% M2 l' a% \7 Y
  129.       }
    ! ?; h$ o4 I4 k" q9 a3 k% W: d
  130.       free(file);% j  V% I) H* v3 n9 \3 O, j) O8 w$ u  K! ^
  131.     }
    ! l3 V+ X2 N9 {+ T7 \* ?/ l. Z
  132.   }+ J% q4 }* D* P+ `
  133.   fclose(fp);
    ) P* C6 N0 X, K  P
  134.   return true;! e0 q  t* g8 x/ ?  N
  135. }
    2 i% o7 [$ ?& b. R1 _- P7 j

  136. % @/ z, ]2 `2 B8 f, D' Q
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)  d; u' t$ K5 b* H1 M1 i6 M9 [
  138. {
    : j4 }8 @6 R& j' V
  139.   TCHAR  szFull[MAX_PATH];' t$ [( Q7 t, o! C
  140.   TCHAR *token,*inter;
    3 m8 @6 v. q3 g; ]  q* g" ~
  141.   *szPath=0;
    / e) S  T+ E3 u/ E3 r  [
  142.   strcpy(szFull,szFullPath);
    , C' k" [4 X2 z- q. y8 {# ]/ ?4 D
  143.   token=strtok(szFull,"\\/");
    # X/ z# g& H8 L% v
  144.   inter=token;
      q& {+ Z/ T6 H2 e( h7 @# |7 E9 G
  145.   while(token=strtok(NULL,"\\/"))
    8 Q  T' ~% h  N6 f5 ~0 ~. }) `
  146.   {
    : N! W( u  M/ S& S
  147.     strcat(szPath,inter);2 K4 ^9 @/ y; j( F- q0 [
  148.     strcat(szPath,"\");
    ( p* r, v$ N& P0 A& b+ D8 a
  149.     inter=token;& @6 G9 I9 c+ s
  150.   }# s" x& X6 W& T8 d
  151.   return strlen(szPath);
    4 g7 n) r+ {- N+ K/ F
  152. }
    - @0 _; q) y2 D& B- A+ y3 n: h  i

  153. - a: X$ H* S. Y# j! X5 M& v
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)) Q, g5 F! ]7 j9 e: W+ o
  155. {; G: O* b- g6 G6 b
  156.   DWORD attrib=GetFileAttributes(Target);, d* W+ d  Q" P/ _# l: E5 T, O
  157.   if(attrib!=-1)2 x$ z: @! n2 j$ G/ R6 @) e# t
  158.   {
    6 v7 \5 e* ]1 d! l" T7 o
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    8 ^! d% o$ s$ i1 a- N8 N# F
  160.     {/ |3 S, D5 ?& _# I. s+ L$ i7 f
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);
    % c5 G% v4 i$ ~$ I( z) ?
  162.       SetFileAttributes(Target,attrib);+ y9 h+ \7 Q, ]5 k# S$ A+ A7 S
  163.     }
    ( y4 y  e" D; m# ~% m( h8 v
  164.   }
    3 h" Y2 ^) K4 f" B; H; E; c
  165.   CopyFile(Source,Target,Erase);3 d; \, C) H* R
  166. }
    / Z& g- |2 z/ X6 b1 N6 Y+ e

  167. 2 A5 R+ p2 L# k4 r% ~% k' m
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)$ ]" M6 Z5 x1 _9 v9 m* v
  169. {# d) S" G4 K/ V/ N! I
  170.      FILE *fp;! Z8 b! q8 B$ Q# y7 }2 H2 G' ?4 M
  171.      char  szBuffer[8192];
    6 i$ J8 c4 n" b. Z' a& t
  172.   va_list  argptr;7 s% @; ]1 j3 E7 g

  173. ( `1 o; p" t# J4 J  w
  174.         va_start(argptr,message);- t& i, d- P( V9 p5 [
  175.         vsprintf(szBuffer,message,argptr);" g& M% S; a% q2 J7 a
  176.         va_end(argptr);
      w) R' o$ W1 L  r
  177.   fp=fopen(FileName,"a");: [0 Z5 l' W6 \4 m; _1 H; l- D! S
  178.   if(fp), P3 m: f2 q) H1 K8 P% n+ r
  179.   {
    ( I9 \* Q& I9 a7 F
  180.     fprintf(fp,szBuffer);
    0 k: e$ g8 W( C7 }6 h! S6 F( Y) r
  181.     fclose(fp);! P& x" V2 Y( O2 }. R
  182.           _flushall();( j4 }- V7 A! O2 ^9 u
  183.   }) ~+ H* [) [1 ~8 P8 x" V( o0 S
  184. }5 h* y) a" b2 O, u3 n) o; B

  185. 3 Y0 k" D$ [' o4 c
  186. BOOL CRevAppApp::Fclearf(char *FileName)) G" ?9 U; d& C: w  m1 m/ v
  187. {
    / x3 p* u* |" ]8 T- f( r6 K7 p
  188.      FILE *fp;' C9 j( I4 P7 F# h, |* y, p* M+ j
  189.     DWORD  attrib;
    5 d7 y# E3 E0 ~$ V% |0 Y  {
  190.   attrib=GetFileAttributes(FileName);1 T" w* S: ^# n- z! M- |
  191.   if(attrib!=-1)5 A5 p8 h3 o5 J
  192.   {2 Q- X, X5 m: _5 @
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);) S* C) H# t- N+ k/ T5 h6 W
  194.     if(!SetFileAttributes(FileName,attrib))
    ( b: j$ x/ A7 d$ s+ b6 t: ~5 z& p
  195.     {
    # }2 Q0 }% f) o/ m" k
  196.       return FALSE;
    , p4 V8 V1 d+ ?5 S
  197.     }+ K$ w9 N6 a" O; ~+ k1 g+ ^9 s
  198.   }
    5 m6 d! m0 E; c+ R, `8 o5 h+ R7 P" O# X
  199.   fp=fopen(FileName,"wb");" }0 y5 L! ^- w( _# w
  200.   if(fp)
    , D3 n4 ?! Q$ m/ ?& r. O
  201.   {- c& ^0 e2 ]& r6 \
  202.     fclose(fp);' Y5 u# L* [% c7 q; x% a3 V
  203.   }
    5 {5 a/ u2 o9 ?$ R# d+ q! U1 S
  204.   return TRUE;8 B9 o* p9 f' X7 q; T1 j  l
  205. }9 P2 U( w. j0 l4 i+ S. @

  206. ) g- E; N, K9 m+ o9 W2 [6 c: t0 m
  207. BOOL CRevAppApp::UpdateLocalVersion(void)
    % [2 s% C& q: g4 Z  U
  208. {; m* P0 c  f1 R/ g6 F, H) Z  f
  209.   char filename[MAX_PATH];7 h  A5 @/ p+ Y0 F- E( m6 N6 V
  210.   LPUPDATEFILE file,olds;
    , |# o$ Y5 t2 f
  211.   std::map<int,CString>::iterator i;
    * T$ i3 p" g" _, o! M
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    1 v# b) m5 J1 E$ P- O3 Y- [; Y
  213.   std::list<CString>::iterator l;
    7 }8 m+ h; t4 h1 d$ Q

  214. ) [& P, Q! p/ D# m; D6 l) a
  215.   if(bFirstUpdate)
    * v2 r& R( b) `) O! D
  216.   {
    $ F/ {4 }/ t9 K, ^2 L, F& `
  217.     dwCurrFile=0;
    + Y+ ?# R1 c- ]) d! l$ ?8 W
  218.     bFirstUpdate=FALSE;
    ( |* y* I0 }; V2 R: O) g" L3 h
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())
    3 W1 v6 X% h4 V  X0 f" C6 d' t
  220.     {
    4 Y  Y$ K* y) f( r
  221.       dwTotalFiles=UpdateLocal.size();: f2 h  d" y+ N* x1 @7 y/ o; I
  222.       dwDownLoaded=0;
    7 ~  E) ^5 W- U; t& E
  223.       bSilentStep=FALSE;
    0 y# x5 x, b* ]1 U. {* w
  224.       bCompressed=TRUE;
    & v( h2 L# ]3 X. N7 n0 T2 L- Q( P
  225.       strExtLocal.Empty();
    4 W: K6 A9 @7 @6 Z- a9 A
  226.       strFullName=(*i).second;
    7 T9 A# n2 e7 p! |
  227.       dwProgramState=AP_CONNECT;
    4 j+ l) _4 E: A! n2 Z1 Z. U8 f
  228.       return TRUE;
    2 @5 Y* d6 j& {' d# N* r" p& e1 g9 s
  229.     }
    , B5 k+ }# U5 T0 S0 _
  230.   }: R, ]+ K* G* z3 M/ a, o
  231.   else if(bRestartUpdater==FALSE)
    3 k- i6 }( d0 \8 d
  232.   {
    * H9 @% r6 R' s3 e( b
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())7 d: L. v: C  D9 n' e( l7 y
  234.     {
    ( Q3 T  ~! Q) L
  235.       file=(*p).second;" Y4 @1 U- q+ V( |; G, M6 D
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())
    + [, _& L, m( t* q$ j9 n
  237.       {3 ?' p. j2 z8 g" U4 ^+ B
  238.         olds=(*p).second;
    ) a# R( d+ U/ _! q  F
  239.         olds->vers=file->vers;
    * V! P% {2 c! X& w, b
  240.       }5 \; U# s3 w8 w, H) Q! q
  241.       else1 R- t3 I8 [1 }. v5 H! T* V
  242.       {) G# o2 m! U6 O8 X- U+ K
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));1 @; C- G/ E) {* c5 G# U4 Z; u
  244.         memcpy(olds,file,sizeof(UPDATEFILE));' j  `' S. |" z! f, b
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));. ?$ ~5 }* Q! @9 E9 C9 t) ~
  246.       }
    7 ~- `; q7 y& \
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");5 y/ @) }6 M, H0 Q( D
  248.       sprintf(filename,"(%s)",file->file);
    $ {% |( f" }. N- M' G# ~
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    + N2 z+ `0 r( v5 s9 d- K
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }, Y8 @  O0 Y1 @! z% o
  251.     }- N( j, ~" x, A  Y' t
  252.     dwCurrFile++;
    ( D, o; T! E1 n2 o; a7 r
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())# z' Q0 e& F6 p5 ?
  254.     {9 ~: E+ D. Z$ J- |2 w* p
  255.       bSilentStep=FALSE;
    . @+ W) Y. g  E. q- w
  256.       bCompressed=TRUE;0 t. Y% k. w8 n1 Q" O
  257.       strExtLocal.Empty();
    * W8 F& F% c: n( k' u
  258.       strFullName=(*i).second;/ c9 ]! @" U. P0 q: a  s& X
  259.       dwProgramState=AP_CONNECT;, r3 g  U, |8 m' l/ {5 L
  260.       return TRUE;
    : `6 Y$ {" H6 X. W# [3 D) [
  261.     }+ a  @. q# J$ t/ ]' q! U2 [
  262.     if(!bRestartUpdater)+ S9 v5 X9 j& s' g( J
  263.     {- |( H* T6 s% {# x! ^$ `/ l
  264.       int iCurrSize,iFileSize;
    ) ^' w* Y: W9 S" s. l7 s# k
  265.       iCurrSize=0;
    7 p0 B% e" F3 Q$ I  {6 x
  266.       iFileSize=UpdateList2.size();, ~3 r1 o0 R0 A0 T/ ]6 G* {# d
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");
    # }) H$ h, M+ J$ H" g
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");0 |. p$ O# Y3 k/ `- ?, R' f8 e
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");, Y" s/ G' d- N) o' m* V% x/ v. I
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);. [0 p- r# g1 u# F9 w' P. W1 q
  271.       Fclearf(".\\update.dat");1 s- g7 V& V4 J/ H
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    6 [% G- r& i' U+ p0 @  T' ?- v
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)
    ) Q0 f) ~6 m) W0 b
  274.       {
    $ v" x1 y7 w6 R5 i1 _
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())9 Y: O5 L: Q. g( j1 y7 m
  276.         {  O  R, K. d; J8 _: Y
  277.           file=(*p).second;, E3 ]& [! }% {+ F3 V1 `
  278.           sprintf(filename,"(%s)",file->file);
    $ V/ I8 m% E0 w6 z# W* P% n
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
      W7 Q/ p8 Q/ p6 ]' y
  280.           iCurrSize++;
    # v! r2 e) w4 J9 U& G. U
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));; d6 h0 e" ?$ {5 V* ~+ ?' k" k, s
  282.         }0 h! z+ ]% g! y. a$ E+ |
  283.       }
    & n9 q2 x0 S4 H+ X! l6 T4 `/ v( [
  284.       unlink(".\\update.txt");
    ) N6 D% X/ l0 z. c7 J6 Q: j' H- M
  285.       unlink(".\\update.tmp");
      X2 `) A# z4 g  W0 _2 y
  286.       Fclearf(".\\checkversion.dat");
    . Z9 _0 n) R* L  R6 u. _
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);
      l  _7 N# G: `! Y0 ~  P+ W/ f
  288.       if(UpdateLocal.size())
    ! }2 \+ {/ O# j# w( K/ I# g3 @  A
  289.       {
    0 ~5 P$ u3 z' C! Q" @1 t
  290.         UpdateLocal.clear();3 K* `8 S* q& K8 p; a
  291.       }- l  d0 ?/ _  L4 s) ~) r- Y, X
  292.       if(UpdateFile3.size())
    + ]& F9 H, z. M/ Y9 y
  293.       {
    ! V  c) l$ `2 O$ ^3 v- c
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)+ v  T  D& S7 J
  295.         {  @# V1 R& G% c( `" p8 q
  296.           file=(*p).second;' J  r1 O% V) j0 ~' N
  297.           free(file);) x# ]$ y6 d. N
  298.         }3 j; f& o; y6 {4 X  C2 K5 T- J2 C2 m4 K% F
  299.         UpdateFile3.clear();
      {$ r9 A' n$ U
  300.         UpdateList3.clear();* O* h( r0 h! H  U3 e
  301.       }
    7 Q4 m" Y0 N; U0 t' @
  302.       if(UpdateFile2.size())
    # }. B" k4 I, `; G
  303.       {
    ( x# t1 p0 E2 [$ r2 D
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)  x( W9 {* x) K' E6 A' }6 L
  305.         {& J. Z, P8 ~! A1 A1 }% }$ @% |
  306.           file=(*p).second;
    , t; {* q- \: M/ u  L
  307.           free(file);2 p5 W' D( a0 L- ^% x
  308.         }
    3 }. C) W- x% x' [1 t( O" H9 x
  309.         UpdateFile2.clear();
    - N8 l, ]) X" D$ k% @+ H. m
  310.         UpdateList2.clear();+ ^+ @6 ^* ~; I0 x& Q
  311.       }
    1 Y1 D& b) w' v3 \3 l
  312.       if(UpdateFile1.size())' w. u7 A: A3 U2 M  R
  313.       {
    . R5 c1 w* R5 K, @. v+ ]& X
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    ' a8 R* k: w# C6 c$ o
  315.         {5 _. A. ?! c3 Q, ^( ^) s* d
  316.           file=(*p).second;
    # b) I% R2 ^% B  u0 M0 _- f  U$ C
  317.           free(file);( {) u( V8 Z0 b0 A7 W) {: O1 Y
  318.         }
    & A6 j5 v2 S1 N) A
  319.         UpdateFile1.clear();; N& W0 P+ n" e5 I1 _% m2 H
  320.         UpdateList1.clear();
    : W/ u' W% ^: v3 q9 ^. u
  321.       }& w% r; ~# ]9 x8 e! O
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
    # J! J- e2 b1 u! x' Y
  323.     }" G2 W* [9 A& [4 X6 O
  324.   }* p$ F% _5 k2 B: a. f$ z+ ^4 C& w
  325.   return FALSE;
    4 N3 y) l: s4 F2 X+ ]
  326. }( H. u: r; a+ Y5 w+ G+ H

  327. 1 U" V" t1 }" D1 k' H# X
  328. void CRevAppApp::ClearAll(void)
    / t/ J/ Q& b6 h( J: q
  329. {
    $ N6 v8 |4 {* I
  330.   LPUPDATEFILE file;/ D4 Z+ N- \: R( d
  331.   std::map<CString,LPUPDATEFILE>::iterator p;
    9 l& |% B$ l! k: Y2 u9 `
  332. ) i& g8 ^. m0 f4 z" _
  333.   if(UpdateLocal.size())& i/ w) v! Q0 X- Q! q4 ~8 W
  334.   {
    & q$ W( O9 w* [; \: a6 [2 W  T
  335.     UpdateLocal.clear();
    8 K4 U1 a6 y0 r( O, {" V
  336.   }/ W! C0 v/ _8 w
  337.   if(UpdateFile3.size())
      s" ]. z7 P. l
  338.   {( M/ I2 w0 t1 i$ n
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
    ; w" M. j( N/ s4 ?0 q& I
  340.     {
    4 b, c1 E# ]8 {6 r' b
  341.       file=(*p).second;- o9 [+ V  N( i& l
  342.       free(file);* O; B( s( o' K0 U# {- y# H
  343.     }
    : {6 l% }& q$ C( u4 k
  344.     UpdateFile3.clear();% i' E3 O: p+ q3 C! Z! r. }
  345.     UpdateList3.clear();
    5 c& o/ }$ z- J: x4 r/ b
  346.   }5 l9 U6 h) H5 v0 Z- r" W
  347.   if(UpdateFile2.size()); g& |! x) T2 w& E
  348.   {
    ! q& b+ ?& e4 @* e% e
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)+ a: h: e! D& s
  350.     {
    ! z( L' v. L* g' E2 K9 D0 b
  351.       file=(*p).second;8 H! q- n9 R) _' g! k- f+ A& {
  352.       free(file);- L& G; q2 _1 \4 }+ Z" j
  353.     }- m0 x' N( T! N. Z. r1 G9 Z
  354.     UpdateFile2.clear();
    6 }5 T9 a* P3 u" X) r
  355.     UpdateList2.clear();
    - C3 q& x9 n4 B8 J% J
  356.   }
    ! _* e& e4 z& J" r0 W2 }
  357.   if(UpdateFile1.size())1 v. }8 `) e/ b' g
  358.   {
    $ y- N* l& j( c
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    2 _# v( _8 F. c: {
  360.     {
    ) ~: J& q- F- j: O
  361.       file=(*p).second;
    # s5 t1 q- z& H  J) v
  362.       free(file);
    5 j( A7 d$ ]9 b- q# Z* _5 S- w- K
  363.     }
    / w: P2 o2 I; X. T' \- g
  364.     UpdateFile1.clear();1 s- f" W0 }. N, L# D0 r
  365.     UpdateList1.clear();
    % u7 i9 i# R, |* D! @4 f
  366.   }8 X6 l! j! Q2 F5 I" g
  367. }  3 C. L# E; g, @( N! a9 A
  368.   
    * W, W9 H& V* \6 m- \9 Q
  369. BOOL CRevAppApp::CheckLocalVersion(void)& j6 r4 @3 J2 f) g! G, Z/ ?, K
  370. {- J5 A4 D$ U' g5 e( R
  371.   int c;" |+ H8 l9 i/ S" a
  372.   LPUPDATEFILE file1,file2;* d6 W1 W# P/ q( {' S4 K- t
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    . |# e% g6 R: I' v) U' J
  374.   std::list<CString>::iterator l;
    + s5 i+ n* f, s# F3 F+ W2 H

  375. 8 }* S" J' F' l) T% a6 P+ \
  376.   UpdateLocal.clear();
    * r9 j  X+ E/ x3 M5 u
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    $ C, s* M- I& t* _. k) o# k  Z" y
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);! P* p7 m" q! a1 g# r- y
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);# p8 x; Y+ s% R: t3 O/ L
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    5 K  d$ ~: N) D0 a7 J4 Y: ?
  381.   if(UpdateFile3.size())9 y+ _9 O8 ]+ y
  382.   {2 b' X9 r! i- H( `% _
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)
    - d) F! y+ q$ S, o4 K# g
  384.     {
    4 W9 t' \. i3 [
  385.       file2=(LPUPDATEFILE)(*i).second;8 ?5 V1 v% _+ u- R3 N1 {& h
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
    7 B/ i8 B: X2 Y+ ]+ R
  387.       {
    % p  Y% n) P; d
  388.         file1=(LPUPDATEFILE)(*p).second;
    + U' Z7 Y3 _" L/ x# f
  389.         file1->vers=file2->vers;
    ' U0 s7 @9 h; O
  390.       }
    . N1 s+ m. Q4 e0 d) \& o% N$ |! F
  391.       else9 t0 Y8 _2 S+ N3 h  F
  392.       {
    - C, m5 Y0 c3 y1 P) N0 V5 J' s
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));5 H  ]+ N3 d( P% k
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));5 F$ ~4 x! o$ j& h2 W
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));; {- \' V+ G$ I' j9 L
  396.       }) X5 Y  B7 R5 G- N
  397.     }
    2 m; w. f3 |, X1 y5 o9 }6 g  r
  398.   }
    % D1 k6 `, `9 H. a
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++); s* l! _# B( a/ ]# A% y' p
  400.   {/ V$ r+ \* H6 h( [! C( K+ y2 x% U
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())
    1 G/ _) J! [% k! A# C) A9 |% r
  402.     {, N) D1 k2 ?& b* E5 e4 n
  403.       file2=(LPUPDATEFILE)(*i).second;
    9 _9 q1 o( o3 b3 O: I
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())0 D. W; _" }, p& z- x$ n
  405.       {
    # I, a, h) v. D% a1 g
  406.         file1=(LPUPDATEFILE)(*p).second;+ w$ d5 V/ H& g" }; L7 d
  407.         if(file1->vers!=file2->vers)1 C9 B, n% d) Y: _) y! E  s9 v
  408.         {# ~( h. x& [1 g3 T' h/ Y
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    2 B" x% ]' [) x8 Z/ G
  410.           c++;- _# e& l+ L* E6 H3 R" Z" p) L
  411.         }5 k0 m1 `& ^* b+ `5 c' k
  412.       }
    ( n4 W- l, u5 W; y8 U( z- Y' a
  413.       else
    : \6 w, _2 ]2 S+ F9 N
  414.       {
    7 {# F1 i0 y; k2 s3 c. V
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));( J0 K8 `) J+ y
  416.         c++;
    $ ?2 w0 z/ A( y. Q0 O( f7 V5 }% P0 L
  417.       }
    ( U9 j1 g: y0 H
  418.     }9 {6 c, I9 k  L7 z5 L7 h6 z
  419.   }( _) [* H9 c( F+ v& b$ B% b
  420.   unlink(".\\DownLoad\\update.txt");
      v7 z$ K* w9 P+ c: D
  421.   if(UpdateLocal.size()) return TRUE;4 O* _0 w4 R1 Q+ L% o5 j" c8 {
  422.   else                   return FALSE;
    3 u$ n; P( q* L, ?* X
  423. }
    * J' \7 }9 m3 b( f
  424. : y; t" l' F6 v, @/ l4 F" p3 N; Q
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"
    4 d6 c+ p* P0 ~( H* ~- t* E% j
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"
      |6 H' h7 T" d; A& U* \0 @
  427. $ A5 U( h; b$ w3 }  v4 i1 Y
  428. / t" j2 m! j. p; S, R9 ]8 t: P

  429.   x: ?$ ]5 v0 s& H. `
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)/ N- q6 B# o! Q" v* V' m7 d
  431. {
    ; e- t# s" t1 l& t# U3 }+ v
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;
    7 I) ^4 t0 i  R  G
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
    8 \; Q, s4 p: |7 Q
  434.   {/ @" s) Y; `/ G0 p. r8 q) \
  435.     char szLanguage[50];0 G( z' z* e7 S% `) S
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    ) L4 k1 g9 w2 ^+ S  Y- c# n
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ( U, c! b( M  V
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    9 U' d/ I- O% x9 r' z8 C4 |8 V
  439.     else                                   m_iLanguage=ENGLISH;% P# E% e4 ~5 |( J# F3 K  |
  440.     char szRegister[100];' H/ c% E5 P( M: b! O
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    1 M) p( d' {( ^1 x8 E$ I( j2 u! D
  442.     strRegsName=szRegister;( d! E$ e) q  ~' r* D- C' q: O
  443.     char szPatchURL[100];/ `7 X$ Q5 F! T( ~- i4 Q
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");1 F8 U7 t6 ~, m4 r( w
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);1 _$ @/ V# i, [. D) ^2 _
  446.   }
    0 u, f3 q8 {5 y8 ?9 k/ p  c
  447.   else
      a9 W& r# D* \9 ^4 [& h( A
  448.   {* p# y& p5 V' p/ d
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);6 m: u4 E" I6 @" K3 O7 A
  450.     strRegsName=DEFAULT_REG_URL;
    " Y7 I; F9 I' T- Y: I: E
  451.   }- s- }/ W2 N6 }" w
  452.   if(GetFileAttributes("hosts.ini")!=-1)
    7 N- F  y/ M* |* x7 H
  453.   {
    6 a0 |: H) t5 t  M5 s5 m' g
  454.     char szIP[50];* h$ K& F5 I9 z* K  K, Z+ s
  455.     char szDIR[300];
    ; G% n2 Q; V, k1 q( i
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini")), d% o: N" F5 X) l3 m2 X* }
  457.     {
    + t1 M7 v8 Y& F$ g* C8 W. M
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");
    ( F9 t" `- j+ m* o) ^' Z( ]
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
    1 E5 h2 v& h, f
  460.       strHostName=szIP;. T8 f7 `! y! y% E8 |
  461.       strHostPath.Format("/%s",szDIR);! i5 r' x, ~1 a, I9 [( r
  462.     }+ K4 u  j8 I( `( {
  463.     else- X% }8 C3 I) m1 X4 n
  464.     {; a! d/ V+ R7 X% ?
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)" }6 n1 k( R! c7 K
  466.       {
    * N3 Z. _1 g! B3 g. `5 K
  467.         char szLanguage[50];
    - M% X8 W$ \& R# E1 W: |
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    % j- T0 G' L( s5 d
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;' n0 F% n/ O. G: `
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    7 e7 B4 ]  e( K) K+ X4 R
  471.         else                                   m_iLanguage=ENGLISH;3 ?6 Z# V( @( y1 F
  472.         char szRegister[100];
      p: G. b- N! ]
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");: u7 |% n( t( M$ X
  474.         strRegsName=szRegister;3 h- Y7 t" a* r" z1 l7 o/ j; t
  475.         char szPatchURL[100];) S  x* p. |( J4 [/ Z' k& ^, D
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");8 b( g' c$ Z) v/ c
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    $ t9 W: X* r, K, R6 e
  478.       }0 [3 T) W( X7 t' D
  479.       else
    % Q* [2 M+ [* [6 v. _, L0 C
  480.       {, x" K, a) K0 r" i: s
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);( y- H/ h. [  ^0 l( ~
  482.         strRegsName=DEFAULT_REG_URL;) C" o+ G% O5 H5 g+ V) z
  483.       }5 {6 D# T  h- W% {! ~+ S% X
  484.     }& k5 H1 a/ m0 b
  485.   }$ f1 E) J2 E' O( X/ R& D
  486.   return true;# M' G4 ~1 K8 a1 b0 m! G& z
  487. }
    ; E8 U1 H6 X. l" W: I

  488. & c+ H7 E, R# C0 H
  489. #include ".\ZLib\unzip.h"
    % E$ j# a# Z% {  V! M5 a+ X4 E/ e
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);6 l, a  p3 j0 c) e! F/ `
  491. /////////////////////////////////////////////////////////////////////////////
    7 L" U4 ^/ @0 t+ r
  492. // CRevAppApp initialization# }8 P8 j, I; n: n1 d! ]+ @
  493. / ?- F( b- P% o# z
  494. BOOL CRevAppApp::InitInstance()( [. J+ s" u8 k+ C) ?# H, a
  495. {
    $ c6 S- e( v0 B1 Z4 D5 t/ H
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    ' i, v1 ]! s0 Y

  497. 1 E: o+ p6 |: v; B) q$ o
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);  ~2 Y8 H! W- B' l
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))  L7 q7 r7 U: M7 {5 _
  500.   {, X' w# _: A" d) N4 c& ?% f8 U. r
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
    & _$ [0 L3 O3 J4 V8 D
  502.     GetPathFromFullPath(szPathTarget,szPathSource);
    4 K7 B2 k4 c7 ]& M  T
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))% @% H! y2 a7 H: @
  504.     {
    ( `/ g" c3 ]9 D0 d1 r2 m
  505.       strcpy(szPath,szPathTarget);: y6 j( I: J) k5 T: _# K
  506.       SetCurrentDirectory(szPath);. G9 Z1 _2 ]2 f& A  {) X
  507.     }
    7 g, t! J9 g( e, Q, ]. p
  508.   }. [/ D2 `# H* n4 a8 a- }2 `- w
  509. #ifdef _DEBUG0 J1 b. f3 s( g, X: O6 ?4 z
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    3 J& r/ O  }- t, M; l2 d+ g- N
  511. #else9 `5 \# w4 n: e7 ?( B2 i2 C# ]
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    ! g) r! t4 E: _6 u3 W
  513. #endif; u/ o4 ]0 T2 S' ^0 G
  514.   {
    + I: ]7 ?7 \: U9 z6 r* ?
  515.     char tempFileName[MAX_PATH];
    * a3 `7 `  p6 g9 q7 s# c
  516.     strcpy(tempFileName,szPathSource);+ S5 M% l; l, x- w" V* @* |% z2 C
  517.     tempFileName[strlen(szPathSource)-12]=0;
    ( g, V& Z7 g; S/ h+ W) b( D$ C
  518.     strcat(tempFileName,"\\$CSUpdate.exe");
    3 g6 T3 G! G' J' ^6 z
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);
    6 X! C$ q* O) t
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);
    3 B0 ]3 A) A4 z  E
  521.     return TRUE;
    5 G8 |# I( X0 }' B; k
  522.   }. Y+ X. K: N/ P1 Q) s
  523.   // Nuke 0118: Delete run.exe
    , q& T1 c4 C& T, X* Y& N
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
    / D% F+ N' H; U- u1 {. t: Z, @
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");6 q$ _  ]/ }1 ~2 I! b- M
  526.   if(!ReadCfgFile("Config.ini"))
    . h3 `& P9 `* [  E- _; w0 S8 ~% D% s& T
  527.   {7 g7 _/ }* w- f' q/ \1 A0 W+ P
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);; k/ C, D2 [5 q" G% v
  529.     return TRUE;+ u7 n" l0 ]! o" h" Q
  530.   }
    4 c" l) E9 ]! B; D# c2 i
  531.   HANDLE mutex;
    + @) g1 U% l/ M, T% c9 _8 e6 N
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))0 E! L+ o2 q8 w3 R' K3 A( M/ U  V: g
  533.   {2 J6 r3 Q* L, B; q6 G
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
    3 _9 z" x$ S: {% d
  535.     {
    ; b* c6 r  t; K4 T
  536.       CloseHandle(mutex);, Z* x% s( b1 f9 _2 j6 s( e+ d" S
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    # M7 z5 g  I0 Q6 `6 L+ `
  538.       return TRUE;2 I$ w" q% H) C' O! c/ I3 _) R
  539.     }# F  T) T4 s3 w* ]
  540.   }  / R  ]8 P% e5 u% H/ G
  541.   CloseHandle(mutex);
    : z& D* l7 T2 b$ p$ g0 X
  542. 0 _) E  }$ j$ k+ q" X! N) W2 t% p! h- I
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);, V. \* a( k+ i8 ^* @
  544. . t: d0 w& e4 Q" ]9 u8 t
  545.         AfxEnableControlContainer();; w: T' Q5 W/ P9 R1 R' x+ I
  546. 9 p6 h, U+ z3 p& l
  547.   bCanUpdate=FALSE;
    / ^. z" O  |# f% ^2 `
  548.   dwStartUpSteps=1;8 e7 N0 F. m* j$ V3 ^+ V1 r8 G
  549.   dwProgramState=AP_NOTHING;# o0 Q! C! v& C2 E' C: ]6 E! K
  550. ' ~. u$ w4 s% d$ u3 v9 l
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);
    4 h4 W: E1 G- o- P

  552. ; {) M$ l; J- s2 N
  553.         // Standard initialization
    ) r6 f+ W- P. |' U% I; ]$ Q
  554.         // If you are not using these features and wish to reduce the size6 x; x' s8 M( \' Z) Y3 q
  555.         //  of your final executable, you should remove from the following
    ' D. T4 S& M* a- j5 U8 K; k
  556.         //  the specific initialization routines you do not need.
    0 T/ V  w2 g: b& Q- u. H! J
  557. # c$ B. _4 O6 |+ |, }
  558. #ifdef _AFXDLL
    : w0 {! H" N% @! W* V
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL6 V, y  W# i( l3 r* B: d
  560. #else
    1 f/ H: G1 I+ I# E4 y% k2 K
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically$ ~  c& z3 d/ s7 j& i4 Z; }
  562. #endif
    ' ?8 N7 N7 T/ m* Q, z

  563.   K3 V( E) ]& b8 Y
  564.   dlg=new CRevAppDlg;
    , l) C) h# @3 G
  565.   dlg->Create(IDD_REVAPP_DIALOG);
    & C8 k% O' h9 B" P
  566.   dlg->ShowWindow(SW_SHOWNORMAL);
    $ ~0 Z- `" F3 u* z- E# U1 [
  567.   m_pMainWnd=dlg;# _3 e6 t4 p0 O) _8 x1 t

  568. 7 I9 S  b3 ^# }: g1 u! j9 x, x
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);
    7 R  g' H; `6 S" B9 `
  570. 9 U. K$ ^1 j& e
  571. //  GdiplusStartupInput gdiplusStartupInput;& _1 ]9 w% {6 D; z' j0 ?9 ?" r# U4 E
  572. //  ULONG_PTR gdiplusToken;
    / c3 s0 y$ H  e( L+ n. H8 @" C
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);3 T- U) u2 H: f9 k) m

  574. ! a: k* K6 {& Q" q* q" S
  575. //        CRevAppDlg dlg;
    : ^0 l& u: x3 O1 Y" @/ B' I. i
  576. //        int nResponse = dlg.DoModal();
    % C; ^% H2 s/ K% \- L  B
  577. //        if (nResponse == IDOK)
    1 k6 Y- x/ s; k4 K
  578. //        {
    , I+ [, ~% _, p0 t0 {8 g
  579. //                // TODO: Place code here to handle when the dialog is: {. p% @4 B0 k5 ]% V
  580. //                //  dismissed with OK
    5 P# b9 o3 Z8 `8 ]! e% v9 X
  581. //        }4 b! Q9 K/ I8 b. b; G
  582. //        else if (nResponse == IDCANCEL)+ l" M& [  k7 K
  583. //        {
    5 l. Q4 O$ M  F8 h
  584. //                // TODO: Place code here to handle when the dialog is
    + L  ~% P' l- W
  585. //                //  dismissed with Cancel
    3 @! q9 I7 |  J2 V' `
  586. //        }
    9 B/ T1 L% J. b% ?/ j: h! Q
  587. 1 H) U' x) H/ o2 a6 f
  588.         // Since the dialog has been closed, return FALSE so that we exit the9 P: F+ w- S' D) j
  589.         //  application, rather than start the application's message pump.
    , X2 Q; I  g) I" A/ S' I/ R
  590.         return TRUE;
    0 G; R  J) g6 q3 x8 L* m% C: M
  591. }
    * o9 P6 ]7 a5 \! N
  592. 9 d- o6 |9 A1 ~: W; k. |
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    5 w! r. X/ f- C+ u6 }
  594. {' K+ l1 Z/ ]; v3 s; @
  595.   int i;
    8 G6 r$ }9 `! g0 E+ M+ m9 _* {8 ?
  596.   char *szRet;6 F+ R! f  Z# {5 {

  597.   r7 f8 X5 U9 e$ |5 V+ Z4 e
  598.   if(pSource) { itoken=0; sztoken=pSource; }, T& q6 F2 G( N5 \  {9 X+ Q8 a
  599.   if(sztoken)
    5 W' n$ u! h4 c6 z: y" v+ T
  600.   {
    - F: M3 H0 }: ~+ f+ l( y
  601.     szRet=&sztoken[itoken];) X0 F. H& o; c- A* W2 T! W: u- @
  602.     while(sztoken[itoken])6 q4 D  X) _: T# x' ?+ D- x! b
  603.     {: _. Q+ u( s" }5 t) y" I( f
  604.       for(i=0;i<(int)strlen(token);i++)
    ' g$ Q4 Y' u! l$ a
  605.       {" P3 h; V/ C! N
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])1 v) k+ u, K. o) ~% a6 _
  607.         {$ p1 o( i( N( D# ]9 b+ h
  608.           sztoken[itoken++]=0;4 P# ?4 w5 W6 u$ O# I
  609.           sztoken[itoken++]=0;3 v8 }1 H6 R  a  F; @; l* g
  610.           return szRet;
    ) T# R! n- S0 o0 j3 q) J6 {  w1 G
  611.         }
    , V! n: |% o/ C1 R
  612.       }
    $ I3 ]! d" _2 s( i- _$ F
  613.       itoken++;
    # I8 f) c+ W2 j7 Z3 ^0 h
  614.     }
    ) ]7 ^# |2 z: E
  615.   }2 ^& b: N  [4 `: q$ q
  616.   return NULL;% u0 }+ a# f7 j, p5 P
  617. }5 O7 D$ O' ^4 ^, n8 R

  618. " p: _8 q; s. p" k- n. B" s
  619. void ProcessProc(long Total,long Current)
    6 e  }; e3 ?* x/ f6 P- u( f
  620. {& u3 ~3 K4 D3 f
  621.         MSG msg;
    . e' Y/ L; `! K
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);! v1 u; d3 h6 U8 `1 B
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));
    / J6 ]9 n* ^1 I4 k
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))1 m' p1 S5 {! O- V
  625.         {
    " _5 v* R5 g5 ~0 D3 n) N
  626.                 if(!GetMessage(&msg,NULL,0,0))
    " I' A+ h5 V) A$ V  H
  627.                 {
    2 k  e8 J' o7 a! Y3 \) q
  628.                         return;
    ) z% ]% S4 }0 V) P2 W
  629.                 }( w/ n) ?3 Y2 A
  630.                 TranslateMessage(&msg);
    & N. W2 E; [$ a$ c2 @' |+ X- `4 `
  631.                 DispatchMessage(&msg);
    4 k+ A3 K. c+ B
  632.         }        ) F! k- ~' T9 m
  633. }
    # f! J0 ^- B( {6 I, E
  634. - Z1 X3 d& R9 n, X& c
  635. BOOL bFirstChar=TRUE;/ G' Z$ C; M8 S0 ^( w! g% \
  636. * n* o) y1 n" j- b# P$ \
  637. BOOL CRevAppApp::OnIdle(LONG lCount)' ~( O5 T( Q5 {
  638. {
    " W* m  P: X# a
  639.         // TODO: Add your specialized code here and/or call the base class
    5 A; S" F1 |# h+ o. }5 P
  640.   switch(dwProgramState)
    ( L$ C% p* U) T) `& X* D
  641.   {& O; q/ s) l& \/ M" s
  642.   case AP_NOTHING:
      S6 [: k9 E/ @/ w/ n
  643.     switch(dwStartUpSteps)
    7 [' O; e/ m" ^' `& d9 t
  644.     {
    ' O. S8 Q5 y' ^6 W  G) B* b  J7 M7 B( q
  645.     case 1:
    / c# _9 W# U) @. c. L
  646.       {
    7 V% m' m& B4 L7 Q
  647.         int i;6 c0 k! S. R, t5 u( S  r- X
  648.         CDC *pCDC=dlg->GetDC();8 v( o  ~2 R$ J  @. V. `
  649.         HDC hdcwnd=pCDC->m_hDC;5 S3 s5 [* C0 I# c  O8 p! R7 o9 v+ V' t
  650. //        Graphics graphics(hdcwnd);: [9 f0 [0 X0 u) ]2 [2 ?
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");( h+ o- U# b: Y# q; k! ^
  652. //        INT iWidth=bitmap.GetWidth();
    1 Y4 I# h4 E. r
  653. //        INT iHeight=bitmap.GetHeight();
    4 \1 i6 D, s! \: b# g; F
  654. //        Color color,colorTemp;
    . y, i7 S1 l5 \/ @0 p& G
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)0 l! t9 [% N1 b- F1 N
  656. //        {) ^. V+ u% b5 U
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)5 M* c8 a2 t6 Q  m, f7 |
  658. //          {
    6 X% q) f; ~% w) M
  659. //            bitmap.GetPixel(iColumn,iRow,&color);4 J* W* D$ P& N5 C; e$ z. m
  660. //            colorTemp.SetValue(color.MakeARGB(
    $ H; \( P- c, n  Y! N
  661. //              (BYTE)(255*iColumn/iWidth),
    ( J: Y9 D. k# Q  _3 N
  662. //              color.GetRed(),
    4 Q8 e& N! a# p5 i6 Z
  663. //              color.GetGreen(),
    8 k* q1 q& ^- ]  d8 S1 x7 Q
  664. //              color.GetBlue()));7 J( i& t) b0 B5 x. V. X! T3 }
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);
    " P7 I1 {" a% K( G7 ?, ~
  666. //          }3 b+ I1 e2 R+ ^% ~  y6 u3 B) u
  667. //        }& |6 @+ ~5 x% z) S4 i
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);
    ; x& p! D5 v- n6 R' k8 x
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");) U& c: G7 N6 x6 k1 W
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    2 z+ C* Q/ n" d  m7 P) O" C  m- }
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    . `3 j6 l5 K6 ~8 @0 V4 W- ]( ?( l: W
  672.         for(i=0;i<240;i+=8)4 f/ P8 E! e( y% o/ J7 p
  673.         {
    8 Y4 R! r) i' J; W/ H8 x: L4 G
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    $ m6 `5 `0 c) t/ T6 ]) S  c  z
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    ( m% B5 s* n# x+ P
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);3 d4 [5 A, U/ J! I, w2 S" A, D3 J
  677.           Sleep(33);0 |5 g1 A+ o1 F/ Y$ q( A9 w8 ^
  678.         }$ u! U! ~; d- A8 @  J! Y
  679.         Sleep(1000);
    1 Q0 c- {: A7 q/ H6 M" o$ J- y! \+ A
  680.         for(i=240;i>0;i-=8)2 B9 [- r1 c6 M0 e+ n8 L
  681.         {
    . M& k+ Z8 o+ v& q! K
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    # h/ t+ X9 [. ~; r: w2 x# P, T: }3 O. c
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    ' |* J: s. O4 [5 b7 Y7 `- i- p" r
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    # E- C4 T4 i- V
  685.           Sleep(33);) D* h6 J, f9 q0 l
  686.         }
    " }7 A0 ?+ ?! _2 b7 }8 D; m
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
    4 a' |8 N* ]* u" p( Z3 ?) i$ N* x
  688.         dlg->ReleaseDC(pCDC);
    7 @/ r: m  u5 l( M0 y
  689.         DeleteDC(hdctar);4 Y6 G3 u: |" g2 O( j
  690.         DeleteDC(hdcsrc);
    ' Z. e1 h4 ^) ^
  691.         DeleteDC(hdcorg);
    7 g. s3 C. L$ A8 H- `! u. h: p2 D
  692.       }
    * K4 L7 W  B, A0 M* w
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);6 ?- f1 Y/ x4 V: Z5 u9 j
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");
    ! p/ ^% _* p9 U/ L% b
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");
    , S$ X: c) n# m5 T% ]" q
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");! J" Y& [: _) D0 \4 [) D
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);/ @* }6 B2 o1 |$ W
  698.       if(!Dn.Connected())7 b1 \8 v6 e5 g* D
  699.       {( V, ^8 }: k8 [1 t# X) W: Y7 |
  700.         dwTotalFiles=1;0 d2 d; z: N% B6 u' I
  701.         dwDownLoaded=0;' d/ R2 ]4 P1 X! c
  702.         bSilentStep=TRUE;
    1 v: C3 F8 |, G0 e3 }$ t' D0 b3 z
  703.         bCompressed=FALSE;
    4 a! K7 g( x2 \! Z# _
  704.         strExtLocal.Empty();( c) M4 K) ]: V+ I/ z) k8 M  ?& v
  705.         strFullName="readme.txt";7 ]" E3 @2 k1 f/ Z9 |3 Z  I
  706.         dwProgramState=AP_CONNECT;6 P) N% S+ m& w$ G. a2 _, v1 }+ I
  707.       }
    , U+ w* [4 u4 b/ M
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();
    # j' n& b+ s3 o
  709.       dwStartUpSteps=2;7 w8 b. n: }, ~" s# p
  710.       break;- _' q3 s& q( x& n  h& X- ]4 [
  711.     case 2:
    - O* f. [5 f% p
  712.       {
    ) k2 z' i& h6 j6 ~
  713.         int iEOF;
    2 n0 R( i$ Z, T
  714.         FILE *fp;/ ^( m! o* \4 T# X% A
  715.         char szString[512];
    & E1 N* |# x* ]+ Q* V9 j* J* a
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");( o2 c' r9 Z, j
  717.         if(fp)
    3 J, I3 P' O  Y; \* m: @2 P
  718.         {2 G7 v4 x) F; x" \: _/ t
  719.           do5 M' |5 l" F1 n% u" [* O
  720.           {# G* b& x" i, Z& L& ^7 `3 i. W5 o
  721.             iEOF=fscanf(fp,"%s",szString);: n! `2 ]. X# n$ H! X
  722.             if(strlen(szString)): Y) i, k& X% J, |( a) I& U) |
  723.             {
    0 ]& r0 \3 X9 U
  724.               if(bFirstChar)
    ! v7 C+ e1 Z; D; L& ?
  725.               {
    2 z+ ]: Y! B' a& P* i
  726.                 bFirstChar=FALSE;  J" j6 `. J5 ^( U& s
  727.                 bConnectIsBig5=FALSE;. c- A! i$ A$ B' _8 Z
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;
      w0 ~. w# {# [0 }) e5 k4 T
  729.               }' ^1 e# J( [! b) ^5 O4 Z
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));' i3 _5 c' p* R
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));8 W/ \" C$ `  n! i1 s+ R! z
  732.               dlg->m_ListText.AddString(szString);5 z$ F" I9 b1 n. j$ d$ w% U
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);. g8 }2 J: _' |! B# J
  734.               *szString=0;
    , }3 S* X0 H9 c- E! F9 w
  735.             }
    # T# v7 A1 v& r  t( r% _+ t
  736.           } while(iEOF!=EOF);
    4 a% g  H* a3 A0 i8 \8 {9 ~
  737.           fclose(fp);
    , D( `$ f: E7 O" N) Q0 w
  738.           unlink(".\\DownLoad\\readme.txt");
    & F! ?% P7 G4 J1 b
  739.           dwStartUpSteps=3;' u& b' r; w* E/ Z
  740.         }6 Z; r6 ?5 K# ?( s1 W
  741.       }! V& ^- E% c4 u* a
  742.       break;7 d- n' v3 _% [' t. n
  743.     case 3:3 R$ k2 U8 t! b! \; x
  744.       if(!Dn.Connected())
    ) }" D; A+ g0 f8 ^+ H
  745.       {' ~2 C2 a0 M  U- L) T
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);
    5 A& r" ^) H' a) q/ v2 [  q
  747.         dwTotalFiles=1;- y  m* n6 u' C0 D; k/ W  _6 Z. B$ F
  748.         dwDownLoaded=0;
    $ z5 C- c8 L& G- _
  749.         bSilentStep=TRUE;
    3 Q2 ]. i. H2 f# G
  750.         bCompressed=FALSE;
    & g# N% I$ L5 ~2 Z
  751.         strExtLocal.Empty();
    + f, O( @2 l+ Y- K5 u2 }( ^
  752.         strFullName="checkversion.txt";- z+ v6 O3 i! x! |2 a) ?
  753.         dwProgramState=AP_CONNECT;) N6 U% @5 }5 s4 \( o
  754.       }
    " Q, g  K; h1 H
  755.       dwStartUpSteps=4;
    3 y5 B5 c: P% e; q6 u( m) W
  756.       break;
    ! t& v! x" t$ n' n( X7 O
  757.     case 4:3 C' Y8 f8 ?* u/ l7 Z
  758.       {
    * \9 N# ]* Q+ G
  759.         FILE *fp;
    : x- |: Q( i, M8 T
  760.         char szString1[128];
    : |6 F% U" \( z; _' I! s% g! {. X& n
  761.         char szString2[128];+ ?  X# u. w; M, V+ K
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    ! f; Y8 F$ b# [1 m! b* l
  763.         if(fp)
    3 A0 X1 Z: d9 w
  764.         {2 \. u  K2 |3 c: W7 S+ z" }
  765.           fscanf(fp,"%s",szString1);
    , d$ x  R& w9 V! l9 e5 D- O) Z
  766.           fclose(fp);
    ' U4 ]0 j5 ~4 `0 f0 t
  767.           fCheckVersion=atof(szString1);: O4 W" }: I6 F# O) X* y
  768.           fp=fopen(".\\checkversion.dat","r");
    " L# t3 W, a3 ]1 P4 B3 A! q# v
  769.           if(fp)# V3 @' C. U& ~" n4 f1 t& R8 {
  770.           {
    ' p/ ?5 r% r- \: w- i
  771.             fscanf(fp,"%s",szString2);
    ( D1 U$ W$ F: O4 y- p% D
  772.             fclose(fp);
    2 O. G% w$ ?* R2 B* `
  773.             if(atof(szString1)!=atof(szString2))( J; s, H$ E! a
  774.             {2 W( D% n" b+ d) @
  775.               if(!Dn.Connected())
    0 Y% J9 e* c$ \1 w# W+ `& F
  776.               {# C" B( P3 S, p! k) C- U/ k3 t6 X( f
  777.                 bFirstUpdate=TRUE;) e7 e! P" S/ ?- j* h0 q( ^. @6 \
  778.                 dwTotalFiles=1;5 k8 Q. ^' K, R; j2 ?. a
  779.                 dwDownLoaded=0;+ U0 }5 t  U2 K3 @! F
  780.                 bSilentStep=FALSE;3 R3 ?6 G8 t& g$ O
  781.                 bCompressed=TRUE;8 e! \) l: m8 ?
  782.                 strExtLocal=".\\DownLoad\";4 W& G; G! d# w% z# p0 F$ H
  783.                 strFullName="update.txt";% U) I# A/ v% z, ]0 r% T
  784.                 dwProgramState=AP_CONNECT;
    " G1 Y5 b0 L( S/ b# w# D
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    7 t4 X) F4 H. ?/ [" v4 G+ W
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");6 v) p. {# a! {+ p5 c4 q
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");6 m* V4 D% ~5 S# W

  788. 1 i  `: P& o9 j+ G9 ^0 d
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    4 y9 e/ v: H$ r' A, ~
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    6 F2 D. E& ?3 r, b% X
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)
    5 q+ Q3 X2 d* ?6 }- R
  792.                 {9 u6 z3 \' a& \$ [& d
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");6 C. f+ e; S( F1 }* j6 q
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");
    5 g6 M' _& v* A- z! l$ I
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");4 q& R: t7 `/ ~* o: z
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);( W  y7 d& P" y
  797. * m, ^3 U3 N3 D4 K+ a4 c
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    2 ?) g5 Q3 {5 d$ B: K& u- {: T
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");* e3 ~; t% I8 G2 R
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");
    8 B0 y7 _$ A+ s8 [5 Q8 S4 |" V& J. N
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    " p$ p; P0 u" r8 c( M
  802.                 }( }6 D. m( e0 X; n
  803.                 dwStartUpSteps=5;) O3 E' x% d7 t" {0 k
  804.               }
    & z2 @+ g4 k& ^' ^* B
  805.             }
    / L* }! S. v+ {" \
  806.             else3 ^6 G& f% j3 I8 o
  807.             {/ R9 c) e' O9 t- F6 F! Y
  808.               unlink(".\\DownLoad\\checkversion.txt");
    5 t  w. f3 `( x& ]" w9 O
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");( ~9 D# z2 c0 P/ x3 D  u
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");4 v) ~/ H0 r: _
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");
    ( Q+ ?9 Q. `2 e4 H' ^

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

評分

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

查看全部評分

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

使用道具 舉報

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

本版積分規則

关注公众号

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

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

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