CSUpdate.exe源代码

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

  o+ t9 n3 `( n* }  D" _& Z3 F
  1. / RevApp.cpp : Defines the class behaviors for the application.
    , d3 F# G4 k4 t
  2. //
    " ]# A! q0 C% i9 s, [

  3. 5 E, ~# c. Q% A" {6 X
  4. #include "stdafx.h"' ~0 v+ f" N! g% `

  5. 4 ^+ B2 o& W% i, X) C
  6. //#define UNICODE
    $ j" B' K; C3 `& Q6 ?1 M/ N
  7. //#include <gdiplus.h>
    & ^0 A0 k4 v# Z; P6 F  ~
  8. //using namespace Gdiplus;
    : V3 a' Z7 k$ D5 i+ a3 ^/ g4 R

  9. 0 J6 w) u/ w1 u3 K
  10. #include "RevApp.h". f7 Q* b  g1 j3 I# N1 p
  11. #include "RevAppDlg.h"# Q7 M1 ^- x" W  |* O

  12. 4 H. e4 i; C$ B1 a  R
  13. #pragma warning(disable:4786)
    9 t( Q9 q. ]0 O. x
  14. #include <map># I; ^5 Y1 ?% y: ]
  15. #include <list>2 ]' n5 ]. L( j
  16. #include <direct.h>
    7 ~% I4 _" h' A$ P* N6 \
  17. / o% t" R+ b2 \' |0 |$ H
  18. #ifdef _DEBUG
      N# S) n  o7 ]
  19. #define new DEBUG_NEW% T3 m, ^1 b" J4 j  s. E
  20. #undef THIS_FILE2 @" f, B$ _) }0 S
  21. static char THIS_FILE[] = __FILE__;
      f! k6 B+ q5 P$ l$ U- t0 K4 _$ r
  22. #endif
    * x! |4 j7 h7 N8 d" `% J
  23. #include "SkinResDef.h": M& x9 I- A% {) f' T" S
  24. #include "ChangeBG.h"
    ' N3 N; E! F. ?5 T
  25. #include "AFXINET.H"
    ) V" H: g  }* o  s; j* g# v
  26.   B: V% M5 J& j  p# X+ x
  27. #define TRADITIONAL_CHINESE 0
    " k) V+ p( R2 Q+ x$ Y2 Y- |
  28. #define SIMPLIFY_CHINESE 1
    9 Y' J, T! V  T. y
  29. #define ENGLISH 2
    - t  l; a( m; [4 ^  D) ?, X' N( J
  30. int m_iLanguage = ENGLISH;. k( {% e, u' k+ B9 F0 L7 u
  31. /////////////////////////////////////////////////////////////////////////////
    9 f: |! e6 D, [- S7 A( B
  32. // CRevAppApp3 [& s8 L5 ]9 ?/ V, K& ^
  33. . Y% w% w# y) @0 x% ^  [8 H
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)
    4 I2 l' x. x% R: i/ Q
  35.         //{{AFX_MSG_MAP(CRevAppApp)3 [6 k/ y: k# E- ]" f1 |
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.% o1 h1 Y& q; R, T3 ^
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!3 Z- V9 N' I% u/ I# C
  38.         //}}AFX_MSG* |5 f; @5 j) |, V* ~
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp)( v" w$ F; P+ r0 E- I1 Z
  40. END_MESSAGE_MAP()
    9 ~6 J& l( O9 M/ _, _1 H

  41.   |2 q' r* i/ _' J* t3 P
  42. /////////////////////////////////////////////////////////////////////////////4 S7 b; i1 N$ L; p# X
  43. // CRevAppApp construction
    ( S+ z2 ~7 G& I. ^. ?. v! M

  44. 6 n- [' G3 E) G; \; k
  45. CRevAppApp::CRevAppApp(). K& B- e5 O8 r" L+ J6 U" M
  46. {
    0 U+ D3 ]9 v% h" m$ g) u' G
  47.         // TODO: add construction code here,5 d; y2 A1 h  n  e
  48.         // Place all significant initialization in InitInstance/ Q( B, K5 e6 ?' U4 e- ~0 O, z
  49.   bDisplayIsBig5=FALSE;5 g" G) q4 ]) h0 J* H* e3 J
  50.   bRestartUpdater=FALSE;1 c# E; b# l. I. g
  51.   bFinishUpdated=FALSE;- m) W! X2 ^1 v% I  }7 ^
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;
    6 U& X  j  ?1 V- I& G
  53.   InitChangeDataBig52GBKS();
    . X$ p; m5 Y, g) H  T
  54.   InitChangeDataGBKS2Big5();! Z8 A- _  i- L$ T$ j- m
  55.         //
    # Z$ G  w2 k3 r+ B$ A, [
  56.         bClickRunExe = FALSE;
    ! F  U' Y5 F" d* S
  57.         //
    5 h% l: D$ p. u& n4 V% [! X
  58. }5 {5 Z1 ~2 c, _# e
  59. 8 h$ F, a' D3 u5 @5 A
  60. CRevAppApp::~CRevAppApp()1 W0 [2 X9 g! W" |! {
  61. {
    . Z- V. Z! `, U" Q
  62.         // TODO: add construction code here,* _8 M  ^; u; h, a
  63.         // Place all significant initialization in InitInstance
    8 ]4 ~7 W, }0 g7 N, u
  64.   EndChangeData();- L1 u* Z. O* l0 l" O, P
  65. }
    $ G) I! u$ h. {  @# D
  66. 8 y; j. q  ]; r  _5 j
  67. /////////////////////////////////////////////////////////////////////////////$ a7 e( `  `1 `/ D# I3 E
  68. // The one and only CRevAppApp object
      R) }/ \# h" B! o

  69.   t7 o2 ]  a; `& B4 h+ s# d
  70. CRevAppApp theApp;
    ) Z/ _2 Z, W! y- I1 g% |2 b5 M" \

  71. * X8 a! u: l& k3 o4 a
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)
    % S( R' ^: p% i, s# a
  73. {' w( C! a) E4 w8 t8 l3 d
  74.   int iEOF=0;
    6 |& j, }- U0 m3 `# ~) r
  75.   char szTempName[MAX_PATH];
    / O1 `1 o5 }0 o6 y3 d6 b! L$ P
  76.   *szFileName=0;
    ; S# y$ C, H  `# V
  77.   iEOF=fscanf(fp,"%s",szTempName);& c3 f9 w8 R: ?5 s
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')1 M- v8 B$ p5 Q- P9 ?8 E
  79.   {
    ( R5 o5 a  H" F7 T% V
  80.     strcpy(szFileName,&szTempName[1]);6 R. l( \: q, b( P
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)
    : ~$ ^5 M% b- Q
  82.     {
    8 P9 N8 r% @0 D8 u2 Z6 l8 o- e5 n
  83.       iEOF=fscanf(fp,"%s",szTempName);+ M$ ?7 ?( B- B( i% {3 `
  84.       strcat(szFileName," ");
    + }+ S" ^( y' T
  85.       strcat(szFileName,szTempName);/ L' J. T, A5 U% ?
  86.     }6 B/ X7 u4 r" B
  87.     if(strlen(szFileName)>=1)! a- A( \7 Z+ e* h8 c+ c+ I
  88.     {
    * X4 t9 V! L# d! K; M2 W
  89.       szFileName[strlen(szFileName)-1]=0;
    5 T3 b5 h! s4 e- t9 s
  90.     }2 s7 E8 G* k, [2 Q
  91.   }
      G$ c6 L/ ^4 F6 F% ]) v, N5 Q
  92.   return szFileName;
    3 }. G+ P& U6 ~- l6 @
  93. }
    5 x! x* _$ }& m  @! \

  94.   E- g: x1 G" F, t5 z
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    . Y: \9 O- ]" [
  96. {1 p2 c  _4 W* S$ p! g5 D
  97.   FILE *fp;7 Q: ^# b0 Q5 K4 E/ Q0 }
  98.   char *key=NULL;$ w% @" h3 [, o* {! B7 D4 o
  99.   char version[MAX_PATH];. u( M# Z1 @6 d: C& J
  100.   LPUPDATEFILE file,olds;" a- J2 S) S# ?- j) r2 K% i; f
  101.   std::map<CString,LPUPDATEFILE>::iterator p;
    ; f6 P% Q; h& {+ k' L

  102. - ]! d% M$ K1 t: N8 I
  103.   UpdateList.clear();* ]3 S  @6 D: |
  104.   UpdateFile.clear();& E  e0 K) K  q+ p3 ~
  105.   if(GetFileAttributes(filename)==-1) return false;0 _8 g6 s/ G& g# O) x. z
  106.   if(!(fp=fopen(filename,"r"))) return false;
    2 x+ O3 ?3 G$ `# l" s
  107.   fscanf(fp,"%s",version);# j* t, f+ l/ w! W
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }
    ; e0 n8 U0 ?! e. ?1 f2 S' V+ w. x
  109.   while(fscanf(fp,"%s",version)!=EOF)$ |5 G3 ~3 n4 D0 e
  110.   {- E) }" w) A9 g8 X. l+ W$ l
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));4 G* }; U# m" V0 j
  112.     fscanf(fp,"%s",file->path);! x% H0 `9 Q6 W$ K/ \. t! p
  113.     ReadFileNames(fp,file->file);* b4 T" \2 d# a$ `0 k* e
  114.     strcpy(file->full,".");
    # A9 Q; U3 }' h/ q) A7 n: ]& y
  115.     strcat(file->full,file->path);. C% p! v* G2 R3 r4 U
  116.     strcat(file->full,file->file);
    . o: s( Y, Y0 t# k1 Z9 M
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())
    ( ]7 k$ _6 D8 o6 T+ K1 Z: ]- `
  118.     {- i7 a+ k6 M1 r2 i
  119.       file->vers=(float)atof(version);
    1 R2 A) i0 w* f" q- M& ?
  120.       UpdateList.push_back(file->full);+ O9 ?* G, [4 o$ U
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));
    % |, c6 |0 x% {, ^
  122.     }$ y/ p2 W; G, Z. f& g
  123.     else
    - ^9 S" A! Q5 g1 M) S. U
  124.     {
    1 I* T; l! U( [) N
  125.       olds=(*p).second;1 x- M3 Y( t3 R7 K4 j
  126.       if(olds->vers<(float)atof(version))/ ^% |9 S* Y, G
  127.       {
    % e( g9 t: A! h" ^8 u$ B
  128.         olds->vers=(float)atof(version);
    " l( S; P9 [, D) s
  129.       }& |! J9 E1 ?) c9 Q* G$ r/ [* R
  130.       free(file);
    0 T; c3 `6 B3 x
  131.     }" A6 u# b2 J% J4 J8 @+ _+ X
  132.   }
    & \3 X. R! u) A" I3 k- |
  133.   fclose(fp);
    - i8 W' Q( L9 K3 h& l
  134.   return true;+ p: Q; d0 |$ \) r
  135. }3 N$ e# T1 Q! n) N9 w$ W* o1 `! h
  136. . s9 w6 \: ]8 h1 U: [
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)  C* D# C1 l3 G4 B9 ~3 u5 E( S4 f
  138. {/ {5 L0 x5 Z9 }$ M" m
  139.   TCHAR  szFull[MAX_PATH];
    * X$ y, |1 T2 B' D7 w
  140.   TCHAR *token,*inter;
    & B$ u4 v, f5 q1 u7 p( Y
  141.   *szPath=0;
    / K# f( K: S8 ?+ m
  142.   strcpy(szFull,szFullPath);
    ) u0 j$ F  k2 K
  143.   token=strtok(szFull,"\\/");
      o  ?4 O& ]% b0 @) N7 Y+ o( U+ ^
  144.   inter=token;
    - b3 k' [/ A" t6 E
  145.   while(token=strtok(NULL,"\\/"))- M' r2 M  n) {4 e! Q+ R
  146.   {) J7 `4 u7 ^( M/ t4 a9 B
  147.     strcat(szPath,inter);( F7 N3 {; V+ s" m
  148.     strcat(szPath,"\");# S5 f# Y! ~5 K" z
  149.     inter=token;' p" L, k9 a3 _$ U$ ]3 ~, s
  150.   }. v: F, s) h; _* g+ A
  151.   return strlen(szPath);
    6 {$ t3 V& ~; e2 O
  152. }
    . B8 N9 W% D" j3 B4 R# K
  153. 6 E6 `8 e2 r( }3 ^, k" M, G
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)7 Y# u  ?1 b" ]+ g8 h, R. L. g2 \
  155. {! l* Q: F2 J1 J
  156.   DWORD attrib=GetFileAttributes(Target);3 C5 z( T* H& T+ {6 H8 i
  157.   if(attrib!=-1)
    / r3 e* A# i# K" f$ i5 e
  158.   {- M( t/ I' _; ]! Q) |
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))/ [; b4 R$ `% [9 E( @  s' d
  160.     {
    % ~. ~- u5 W% Y2 m) }
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);) \  n6 |& W$ C+ E8 q  v# C
  162.       SetFileAttributes(Target,attrib);4 \+ i+ R% H- R! k* w. i, T0 }+ k
  163.     }! ]1 W2 n: N' Q
  164.   }' z0 K+ x* A7 X. k
  165.   CopyFile(Source,Target,Erase);" k; W; I6 @/ [+ B! u3 c4 s
  166. }* @6 f5 S" H  ?/ L  D9 x; d
  167. * R+ l5 j( p5 A& M! E
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)) ?" h; E- C7 T' K" w
  169. {' P5 F% d! t0 o5 `8 P
  170.      FILE *fp;
    # ^8 {) ^& U! _. y
  171.      char  szBuffer[8192];/ `& L! o4 j7 q% \$ L' x
  172.   va_list  argptr;- z$ U6 ?  Q' i; M9 K5 ?

  173. ) M% j/ s7 t8 k# E
  174.         va_start(argptr,message);- d4 P% t* M' Z3 C  {
  175.         vsprintf(szBuffer,message,argptr);
    4 x9 H) a+ M  p( A+ O6 w' w  O
  176.         va_end(argptr);
      H" Y. @5 T6 M8 I! y. k
  177.   fp=fopen(FileName,"a");
    8 c$ o1 k  _8 U  L  W
  178.   if(fp)
    ' O6 ^& }( F) f
  179.   {
    . ]1 r1 k5 u3 U$ r
  180.     fprintf(fp,szBuffer);% E! R: r: f+ H, I  |3 G4 X
  181.     fclose(fp);* x1 d0 H* Y. N2 x
  182.           _flushall();( i& t, Q" b) T! e! v
  183.   }
    ; z( ]7 Z% D' w: X) {- Z
  184. }% c2 @, V1 p  ^3 Q' ^6 P7 N

  185. 9 r3 Z" I/ v* _- d) E
  186. BOOL CRevAppApp::Fclearf(char *FileName)
    ( e; r" j: Y) }& P8 O+ a
  187. {; J# i. Z9 O5 d" F2 n" F; M/ W& {
  188.      FILE *fp;
    5 E$ i+ d1 j$ ~' N  u( y
  189.     DWORD  attrib;8 h- G' |  d8 O2 G7 b( ?
  190.   attrib=GetFileAttributes(FileName);; T% g8 n2 S9 p3 c* D6 Z0 ?
  191.   if(attrib!=-1)/ B) J* ~; P" M
  192.   {
    # F4 Q" Z( x2 t% l& }+ D& [
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
    1 J: D& z; V" n* ~/ z6 M
  194.     if(!SetFileAttributes(FileName,attrib))
    / R$ J: x" F2 ?2 m( Z0 U. o
  195.     {
    " N0 A2 `: w0 _5 r
  196.       return FALSE;
    - K8 p) E! X" B; t/ Z' k
  197.     }6 |/ }$ L; y' f' o& U0 `% P7 x
  198.   }  I" X) N0 C- {: Y
  199.   fp=fopen(FileName,"wb");6 z2 @) T! o# U0 o# P/ p5 r/ U9 B
  200.   if(fp)
    : W* ^2 h' W5 x9 |
  201.   {
    4 u% U& b, a3 \& K; x7 `
  202.     fclose(fp);
    ! D* h7 H* ]# K( ~. t5 T* }
  203.   }
    ) X5 p' E: H6 \! T
  204.   return TRUE;
    1 K. _. P# z+ I; {" R
  205. }* P% q' X8 p% @) D6 J; L7 g+ D! E

  206. " H) g& A* U8 B  R. I' d# ^" [1 x
  207. BOOL CRevAppApp::UpdateLocalVersion(void)( s% Q1 y( i2 q
  208. {- E' M5 ~$ y1 ^8 V% l- ?
  209.   char filename[MAX_PATH];6 y& A! K$ A; v
  210.   LPUPDATEFILE file,olds;
    . [) X1 H5 z1 I% _- b0 L% ~
  211.   std::map<int,CString>::iterator i;
    " Y7 t! O5 W5 r, H& T, m" l
  212.   std::map<CString,LPUPDATEFILE>::iterator p;& b/ o% r9 y7 H' l! ?. e. T
  213.   std::list<CString>::iterator l;! V* w! f& H4 d( P+ U
  214. ! c: J& E  O$ g3 z! N0 P
  215.   if(bFirstUpdate)3 `* _1 a/ E9 A# \# w( w" T
  216.   {% E5 Q8 v# q' N  k% A7 p% x: k# G
  217.     dwCurrFile=0;
    , d2 e4 _- U! J& k$ @  q
  218.     bFirstUpdate=FALSE;
    4 ?6 X$ p! `$ @( V, u  \% p
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())
    & e- g9 _+ q+ T0 ~7 B
  220.     {
    ! Y& O+ h6 j; y$ T5 {" {, J
  221.       dwTotalFiles=UpdateLocal.size();2 k1 z+ q0 P, X+ {3 j" L
  222.       dwDownLoaded=0;5 s' N) \4 S5 ?# w
  223.       bSilentStep=FALSE;) O0 b4 u( b' K* w) t
  224.       bCompressed=TRUE;
    ' J4 d- K* E# q
  225.       strExtLocal.Empty();
    ! H# \0 Y% ~5 D& l- m+ ?3 ^1 l
  226.       strFullName=(*i).second;
    # q; `  Y6 M8 ~
  227.       dwProgramState=AP_CONNECT;
    * _- H. u# c3 F/ c9 \- u  i5 w
  228.       return TRUE;- `2 d6 a8 C+ ?% o" f1 Z
  229.     }3 s; N: F* O' q( |( B
  230.   }
    4 X9 R* n+ Z4 f& u( ]6 ?
  231.   else if(bRestartUpdater==FALSE)
    1 c! J- U$ Z8 m. ^! W( l
  232.   {) |/ I. T. J# p8 T+ [
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())6 g. J0 o( ]* i8 G4 y  |
  234.     {. z/ z9 @& v, W
  235.       file=(*p).second;
    7 |# Q( b% H) b! V& S
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())) u% B$ W  ^( P7 V2 [
  237.       {
    / u' B! c$ ?; Z: S+ I
  238.         olds=(*p).second;
    $ t/ z9 e+ [( N5 G5 f4 t
  239.         olds->vers=file->vers;
    6 _. x/ r$ i3 h" s) Z: j
  240.       }
    3 L* V  i% E+ f* {
  241.       else
    + B* H. V/ `0 Q8 E5 Y& h& o
  242.       {9 D+ V' B* K/ f3 [. _, `
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));; e6 l3 `$ J8 m7 o6 z0 X
  244.         memcpy(olds,file,sizeof(UPDATEFILE));' W1 y2 X6 H* L- `
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
    5 c% Y! p% {1 X  z6 K
  246.       }
    3 U2 ?7 I% w  ^2 V
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");6 ?/ G! @0 s0 z0 n5 m2 Z* Z7 M( `* L
  248.       sprintf(filename,"(%s)",file->file);6 O" C' l+ B6 l' G
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);. x! g$ N- Q# T9 @) H3 R
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }- f7 B2 C- S" M" l
  251.     }
    - Q8 r% N# ]% M
  252.     dwCurrFile++;5 q# e- ~, l( r& B2 O9 D; u
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())! e+ }: ]3 _( P
  254.     {& V- {+ h. {8 B+ ^! T8 j2 v
  255.       bSilentStep=FALSE;
    ( m* k/ t3 |6 N4 y6 C
  256.       bCompressed=TRUE;
    9 Y/ f) @) |/ A8 T3 o" b
  257.       strExtLocal.Empty();
    , \( }. x* {3 x2 y) G6 c9 L1 A
  258.       strFullName=(*i).second;
    % x, s& y& V) @  ~" o
  259.       dwProgramState=AP_CONNECT;
    4 L' Z  e# h0 V  p! ]
  260.       return TRUE;
    0 G, O, {8 b6 x* H! `
  261.     }/ r3 ]% M0 K" }$ m
  262.     if(!bRestartUpdater)( D8 N% E. t: b* `/ r* c" T
  263.     {- S# H4 ^- V* [3 W5 S; N/ h/ l8 y( k
  264.       int iCurrSize,iFileSize;
    4 F: O! v5 [  m$ n
  265.       iCurrSize=0;7 \* L; b* _+ Q2 Y2 F/ r/ r9 Z5 g8 \
  266.       iFileSize=UpdateList2.size();
    " j, m7 `+ k9 U1 l
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");& A+ x& M1 z$ J, ~+ N. k
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");
    9 M) L' ~* d  J7 Q' l
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");
      Z7 C* W' H$ ^+ l
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);& \2 o- \. z. j& T% p' m9 z0 \( S
  271.       Fclearf(".\\update.dat");3 c3 c: `* o. w3 M9 O, A9 R8 T" W! J
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    & b& U' n9 ?' m7 ^7 f
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)2 k) D* G# {4 L/ q6 Y
  274.       {
    ( Z! z! D4 I7 ]" l
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())4 _9 C% y: a% \. R: ^3 j" F5 }
  276.         {
    6 a7 R6 d- ?- {% m4 Q
  277.           file=(*p).second;3 f- h. o$ v) N2 V
  278.           sprintf(filename,"(%s)",file->file);
    9 O4 X# I- F2 ~/ g! @. Z) n, c
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    9 z: s2 Q$ |  E# l5 Q) R
  280.           iCurrSize++;
    2 _3 t4 R2 t% k' P5 J# ?
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));
    ; W  H$ Q8 W% G, `2 ]& R
  282.         }
    - Y" s# p& ?8 G  k3 c) c
  283.       }
    . i$ a- g5 {- o0 q0 S( N
  284.       unlink(".\\update.txt");$ x! W% a# `7 o# c: @3 z
  285.       unlink(".\\update.tmp");
    ! m" ^* b7 t# ^8 z
  286.       Fclearf(".\\checkversion.dat");7 u8 {8 H. b) R3 o
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);
    * @. M5 ^4 |" E0 t) G' h7 F
  288.       if(UpdateLocal.size())
    + l3 o  c: G! V# u0 a# T' T% s
  289.       {0 Q4 k8 _- W$ ~  K7 x
  290.         UpdateLocal.clear();
    4 o3 O# x% x. [9 G* @! a6 r
  291.       }& p; E" ~0 N4 E( r2 B1 N
  292.       if(UpdateFile3.size())8 b/ m' M9 c* m( ?/ h
  293.       {
    2 o2 @$ d' K$ D1 |' H- b! @0 w
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)3 C! }% p9 c* |
  295.         {9 o' B, _6 I; w0 v' o& `( i
  296.           file=(*p).second;- g- D, L. q8 [
  297.           free(file);
    , G9 d# M" t* \9 e. m4 X4 v
  298.         }
    * o6 J8 `* N4 t& Q' [- s( B
  299.         UpdateFile3.clear();2 a, [# |4 h) a5 D6 e/ U
  300.         UpdateList3.clear();  y3 K! n" n3 x, Z
  301.       }
    & G9 z- S' \6 s* C( B5 X+ T
  302.       if(UpdateFile2.size())
    3 B, [' o( i% b+ D
  303.       {
    / B3 A2 W+ I  ~" d- ~. r+ o1 m
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    9 h( @- P5 _" ]# _8 T
  305.         {1 n: h# w4 q% y. D0 G
  306.           file=(*p).second;
    " f9 n' e5 ]* p- m+ T
  307.           free(file);4 t8 I* I. d. W; [" g
  308.         }
    # O# ~4 j6 I) ?! c( p
  309.         UpdateFile2.clear();
    7 N/ k( x% k/ H1 s- I2 F+ S6 j8 Y
  310.         UpdateList2.clear();( c5 p/ f: S" {) b6 l- }: w
  311.       }+ E; ~; `* W0 i% q& ^3 {
  312.       if(UpdateFile1.size())
    4 H' k- ~% L8 F- p+ x
  313.       {& o" W( \: O( D$ ?3 m! p( ?
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    9 \# n9 s+ Z! E0 u0 z9 ~
  315.         {) c, r/ Q$ v* T, U3 l2 W. u
  316.           file=(*p).second;1 `& F0 U/ W$ ~0 Y& _8 e/ j1 h( O
  317.           free(file);
    ; W! g, ]' p& x) G
  318.         }
    ! R7 B0 j* S- H! G% v. {
  319.         UpdateFile1.clear();7 R" E5 l2 T9 t, b! n, |
  320.         UpdateList1.clear();
    5 C& @- F0 h% i6 t
  321.       }5 J) y+ e2 Y- k- g6 C: X. z6 |& }
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
    : ~% `" R& K; a5 C( c. J
  323.     }
    ! d# o! q7 n& j& G  {+ @" K3 n
  324.   }/ @' J8 x& x7 s( \
  325.   return FALSE;
    ; B. D# b+ t; \- n& E3 P
  326. }" Z* f, L! x8 w1 `9 }- ^5 H

  327. 1 x8 T! I% ?( j0 K
  328. void CRevAppApp::ClearAll(void)
    / L4 v. ?* F3 y* n
  329. {% ]8 A# n! I# _; Q
  330.   LPUPDATEFILE file;
    9 p1 W$ S, O% o7 |. R
  331.   std::map<CString,LPUPDATEFILE>::iterator p;
    # ^* H5 m4 c5 g$ s: h6 S
  332. # B/ Y' G8 T) p, P
  333.   if(UpdateLocal.size())+ Z7 w8 Q; |4 o$ @' D& v
  334.   {
    # u4 B$ ~3 [- h8 T# {
  335.     UpdateLocal.clear();3 i* {  C( L# M- l. K* ~2 h7 X
  336.   }
    ' ]& P- S/ I# a; A. s6 ^
  337.   if(UpdateFile3.size()): ^$ h9 @4 e5 o) `- V2 f; K! N4 X
  338.   {3 T, M1 n) Q# c' H" T0 K9 e
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++); r, F7 _, t; r( L% z5 @
  340.     {
    5 X4 t: S6 s/ I) e4 Q) |
  341.       file=(*p).second;7 o- \- J1 r# c. J: [
  342.       free(file);2 L# Z  y5 z" `$ v. ?
  343.     }0 T) b* x% L* c! b. S3 G& J9 Q
  344.     UpdateFile3.clear();! n0 `! t# v) b( Y
  345.     UpdateList3.clear();6 A) N0 k6 W( _0 l1 u: M
  346.   }  H$ j0 U# }# P7 K) L, }; \
  347.   if(UpdateFile2.size())
    5 O4 x2 s. \( [- ~* J
  348.   {
    & j% \( D( K$ v& {
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)6 e8 a, a! `0 M/ w
  350.     {
    # K# w9 e6 x, d) L
  351.       file=(*p).second;* d! Y% U- T9 q2 M& P  H) ]- |" n
  352.       free(file);
    & ~3 T9 `% l+ |- _& t# b
  353.     }
    2 \, G4 n0 T$ ^
  354.     UpdateFile2.clear();- z% ~" f. t9 u; X3 d
  355.     UpdateList2.clear();, E  F6 N: i6 q: f) Z
  356.   }
      f* T2 f5 W9 G4 s$ w( S( k
  357.   if(UpdateFile1.size())
    % ~! w4 r! z. U- p0 _9 T: J
  358.   {
    5 c; |$ ~  y; Q  O
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    0 D- |$ ?+ _5 r, i3 s
  360.     {8 y( O7 y; O0 F) M" X- j7 \
  361.       file=(*p).second;4 P! K5 K, G5 O! u; J. r7 k
  362.       free(file);
    ) m% O  K% G0 E, Q! \+ B. K6 ~! j6 l
  363.     }
      x) h6 f/ ~! o9 d
  364.     UpdateFile1.clear();
    0 f! M% \1 z- D# ~/ b4 n' b
  365.     UpdateList1.clear();! o. C+ t* f5 W% o
  366.   }
    , k" G. o( \+ U, h* {; t& V5 h
  367. }  
    * }( s) L- ]: q9 g0 c
  368.   0 ]# B& y) ~- J: u
  369. BOOL CRevAppApp::CheckLocalVersion(void)' Z* h" a7 Y# l, U
  370. {7 a. W" U! u, R! X; l
  371.   int c;
    ; U4 k) F  T6 o  A/ o
  372.   LPUPDATEFILE file1,file2;* ^* h( a& M0 J
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    & S6 o. f8 b% n' M+ }" y( N: Y
  374.   std::list<CString>::iterator l;
    # G* d5 C1 U  c1 w6 `
  375. + M( A9 W; Q7 ^# F. q
  376.   UpdateLocal.clear();
    " d4 R' H9 p& z( b9 z! G
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);. D0 g6 w8 j- P, P, o/ c% Z- G2 p
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);
    # C) d5 `6 X" ?% M
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);
    * j0 L( C, z. e0 I
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    * o* \) Z: t2 J% u4 r* y: g
  381.   if(UpdateFile3.size())
    3 a" K- t. I4 U' [
  382.   {+ ?, a, j; B( H1 e2 E1 J/ h
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)7 m! e+ }9 J+ Q+ o6 t7 N8 x/ y
  384.     {
    , M1 T0 k- H' O2 q4 w
  385.       file2=(LPUPDATEFILE)(*i).second;) |& n& c; s2 U3 P0 F0 ~% u
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end()). C1 x4 y4 n# U
  387.       {
    ) S8 h1 x$ V3 S) I
  388.         file1=(LPUPDATEFILE)(*p).second;* O0 h/ E' R. }9 V' L0 h3 E
  389.         file1->vers=file2->vers;7 e+ k2 b) j; Q- s# h$ T8 e/ m
  390.       }
    2 d4 e1 |( V- r1 n0 y3 u# f
  391.       else+ M  A; a* x+ V8 |- ?2 Y6 g
  392.       {% s% }, T% Q% B) i5 ~
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));2 h# E3 m) _! Y/ e
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));
    + t, x, e& a& u( C3 e) H( K; a
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));; Y! v. s( M* h/ p1 ?& U1 ?' v
  396.       }2 W& M9 _) e* F0 Y3 n+ T
  397.     }% J8 l1 a) B' a
  398.   }5 t* @& [$ g: ~* n" b1 I+ Z( g
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    ' K3 Q1 ?2 n: m) M
  400.   {
    0 ^" R3 c, O) |' W
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end())  M$ q) Q+ ~; R5 ~* s
  402.     {
    3 Z/ F( T$ u% S7 }
  403.       file2=(LPUPDATEFILE)(*i).second;7 R6 y9 m' P% O' i, F1 m
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
    0 U0 y# T+ d& Y! ?7 G: g; C
  405.       {
    7 }% {) y) H) f% m/ b* L) W; H
  406.         file1=(LPUPDATEFILE)(*p).second;
    * d5 \2 H; Z- H3 L+ O, u
  407.         if(file1->vers!=file2->vers)! h0 R3 q" T/ d! U. X! h3 q# Z5 c
  408.         {! N0 q0 F$ a, i* e
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));) v( P1 y( o3 G+ l; |: r
  410.           c++;
    ; A3 ~+ C/ F7 h
  411.         }4 p, q1 @5 t9 \/ H
  412.       }$ s+ [; v" `& e7 Y
  413.       else7 U0 r$ H, I1 ~% S1 k
  414.       {. v" m9 c3 U) r; s4 }9 ]
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    $ [8 D) l; b" K
  416.         c++;
    2 Y. H, e( E5 v- z+ T1 F: x
  417.       }1 ?1 u5 {! h8 e) A
  418.     }
    1 |0 v! r& `) J
  419.   }9 M6 h1 [. P; P( a. f+ r
  420.   unlink(".\\DownLoad\\update.txt");, [6 N& X$ w3 S
  421.   if(UpdateLocal.size()) return TRUE;
    ! U' P* ~6 `& K
  422.   else                   return FALSE;
    ) m$ H7 _1 `3 I8 a
  423. }: o6 Q! f& m" d9 ?# Z

  424. , H2 b1 a. H, w. U# Y* X5 j9 v
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"
    / f/ F4 i+ a+ j& o: k
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"
    5 W" k9 {0 T2 L. w: T

  427. 3 g  g" |# E2 o) X+ i
  428. 7 u/ V! E  N! m7 F; x

  429. ' }0 ?7 T5 h1 Y3 M
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)
    4 W  V  i1 Q1 ?" ?
  431. {8 z. M- ~: B: d0 j  ]
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;
    8 |. v+ k: _: O& [4 x) A8 v" v1 _2 L. o
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)- ]: t! R9 H+ t) s
  434.   {
    8 J% ]- ^% p8 `7 c/ ~
  435.     char szLanguage[50];
    4 h$ q% ?0 @( ?: R5 g4 k1 y
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");+ J. t- m* k& [! j% ]. e0 B- Q% z. S4 A' b
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;( a" y) H4 `  \; T! T
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;: h- [$ m2 w4 O! [3 n4 b+ v3 U4 V
  439.     else                                   m_iLanguage=ENGLISH;5 G+ ~) v/ _+ f+ b- Y7 `9 Z7 W
  440.     char szRegister[100];9 P+ V4 S# r8 O& L; f6 X8 N
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");2 O; m! T/ |& N1 n6 X# ]
  442.     strRegsName=szRegister;
    . E8 G) ]9 W! ?7 u, T9 Q1 f
  443.     char szPatchURL[100];
    9 F( X# t4 G& g
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");) _. n: J3 `! n% {5 P
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    . t: ?) [, T! n# `
  446.   }
    ( P( W7 _+ w. F" p- }+ t& N
  447.   else
    ' R* \1 p* h" s7 W1 z+ n* A
  448.   {
    8 k" `: v( ^) P9 n. k7 V
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    + p7 m& v/ Z7 m/ y- K& O2 _
  450.     strRegsName=DEFAULT_REG_URL;7 I7 _' p5 i% V0 @! K+ }
  451.   }, ?# g, I1 K$ y& w
  452.   if(GetFileAttributes("hosts.ini")!=-1)% Z( y$ H% J% f- E6 q$ F
  453.   {
    - f6 ?; C$ E. d/ |+ k! t. J; t2 t
  454.     char szIP[50];
    3 P0 g& z' j3 |" w+ S
  455.     char szDIR[300];4 L. }2 D9 X7 L3 G
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
    6 V5 I" w6 I7 r1 Y0 X0 q2 v
  457.     {* z% H& Y' x, _. f$ A. x
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");
    5 c! B5 Q6 X5 C, e" e- u
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");( g' v4 |, J* T
  460.       strHostName=szIP;: Z% v% \) a8 a3 T" v/ a1 u! P; Z
  461.       strHostPath.Format("/%s",szDIR);: A) H' M# i0 S' ]; Z& z
  462.     }6 ~; }8 c9 m" S- u
  463.     else0 J6 N+ s6 G1 |/ T* d: c" r+ j
  464.     {
    6 I8 P; q7 ?) S8 J! [7 g3 Z* I0 l* D$ ~
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)7 w, m) g- Y4 M
  466.       {
    / M. T+ B3 R& I0 J, E1 U
  467.         char szLanguage[50];
    9 i9 l" q  N5 n, Z9 g& k
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
    ; L! x$ a8 k0 E- o& ^
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    " o$ V0 s' l9 X) S' b9 x
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;. Q& z$ {+ a2 j+ l* |
  471.         else                                   m_iLanguage=ENGLISH;! v" n' x6 h3 D4 z" [
  472.         char szRegister[100];" Y: x4 L1 R; M1 u1 ~, {  i
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    ) G" Y: E. ~- C1 _7 }1 X
  474.         strRegsName=szRegister;
    + j( S  j. w/ o" m7 p6 E( f, ?
  475.         char szPatchURL[100];
    ( e6 ^& s9 {  _% X$ T9 V
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");7 m- p1 Z. D8 d7 E/ y
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    9 A  X! t3 d- j6 ^
  478.       }( A7 E9 w$ E1 m3 ^# `+ |
  479.       else
    9 v5 @! G! ~& |+ l* q: j% W
  480.       {
    * T; W% X: A1 }/ b/ u, z7 h
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
    2 U( C# e$ i0 t! w4 u
  482.         strRegsName=DEFAULT_REG_URL;
    ' v% b3 Y7 A2 V0 f; i6 A
  483.       }
    . P5 L% k4 X" p) G; `
  484.     }
    & _  c- m$ {. _6 f8 }! m3 J
  485.   }1 ^6 A( F2 J1 G% E3 F0 X
  486.   return true;4 ~# M2 y; M8 d5 s2 u5 ^
  487. }
    " ~: c; [6 V( X  R. o
  488. & G& |6 H- J' V3 c
  489. #include ".\ZLib\unzip.h"7 {8 e# P# U( k2 u0 i7 [
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    ' N+ K/ M6 T# _' @" s
  491. /////////////////////////////////////////////////////////////////////////////
    . o1 `4 c2 @8 R. \, G( M1 V: }
  492. // CRevAppApp initialization
    2 m+ c+ A/ C0 z% t1 J$ Z
  493. * U) m; D7 C, N' D7 I" p3 w7 c4 L) ?! A
  494. BOOL CRevAppApp::InitInstance()
    " Z" h& d% q  G+ }
  495. {
    , s# L) \" z9 S  P3 E; \6 t
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    ! `- v. S5 P9 a8 f. ]

  497. ' B& @- R7 D9 r5 ?) s9 V! Z9 ~
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);0 o$ Y$ s+ D% \0 I6 V# P
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))& O4 J5 C# i5 V) v6 f; c1 e3 |
  500.   {
    $ i& m# e; @5 g( i
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");! s9 Y1 l+ Q$ H' J: ?2 B( b# `
  502.     GetPathFromFullPath(szPathTarget,szPathSource);1 s- E5 `) N) H# ]$ r
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))
    4 t8 v' }# s6 A
  504.     {
    9 T- s6 p, A$ W( M$ h- n
  505.       strcpy(szPath,szPathTarget);$ w, V3 l  i2 A' ~
  506.       SetCurrentDirectory(szPath);) {, Y/ p8 s' h3 g3 t3 x- s$ ^# I
  507.     }0 C5 y& L' N3 ]
  508.   }
    9 }) Z4 u$ j  E. D& [1 s- O
  509. #ifdef _DEBUG3 e+ \- K$ o$ V! T- Z5 H1 b' ~
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    # C: S. ?+ `/ w( W" r6 [6 z% d: K
  511. #else
    ! S, G" ^' g* D  k! s7 Y& O
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    ' k& j. R, F5 W4 i# W* B
  513. #endif
    : t! P& x, ^$ m8 r7 G; ^. c& w" X
  514.   {
    1 c: f  t) j9 c  p4 W/ V
  515.     char tempFileName[MAX_PATH];% f& W) }6 ~1 V, \/ x% K
  516.     strcpy(tempFileName,szPathSource);* S) o% d) k- P, h0 H5 J
  517.     tempFileName[strlen(szPathSource)-12]=0;
    7 s$ J+ X4 ^6 B' R6 M! W
  518.     strcat(tempFileName,"\\$CSUpdate.exe");
    $ ?0 E* Z* z: M3 y; E$ i4 D0 \
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);
    " _% G5 @" e5 l& L: o
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);" c3 Z* k/ y$ Q
  521.     return TRUE;
    & a# q* u/ K3 @( s
  522.   }
    5 s' V: e, A: |: R
  523.   // Nuke 0118: Delete run.exe
      `: l7 ?% k% m: a8 {1 _
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );
    + h6 i, D2 w0 x6 o0 N" g) |
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");# X5 N+ X- G" i' C: X5 q
  526.   if(!ReadCfgFile("Config.ini")). z; {0 Y4 n$ @# n
  527.   {
    $ h: \# @! [  b5 A5 T+ c( J3 h% W
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);5 B- j8 r" x1 A6 ]. F
  529.     return TRUE;
    # W; |! b, z; {) C+ _( n9 X
  530.   }5 `6 E% }9 T7 K. f& p
  531.   HANDLE mutex;* O3 d: `! @6 b6 d1 F
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))
    ( \5 ]  Z2 M/ z
  533.   {
    + e: n) _3 q% R$ O6 E
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS)
    & m  @% q/ e, ~3 n3 s; H
  535.     {
    : \$ n3 w! `* d  \, P/ A
  536.       CloseHandle(mutex);
    4 D& \) `0 @7 V) W6 j3 x8 U
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    # H% x! N" C# x' L* f: C7 `0 z$ H1 t% i
  538.       return TRUE;
    8 O6 |/ K% `3 Y3 f
  539.     }  `" y% n5 F' t( x! D: l8 y
  540.   }  
    % G; x, H+ _" ~) \$ y; @+ S+ _
  541.   CloseHandle(mutex);; [7 U- ?  M1 T, A7 b/ z% H

  542. 6 Z" R% o" ]* L% Y# D
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);: U, @% g9 ]% Z  v
  544. ) w3 |$ i8 m. B2 g( ]( r
  545.         AfxEnableControlContainer();
    : C0 \) K3 k7 v- W- d8 W  G# m
  546. 6 {, J) q) R7 }. z  p
  547.   bCanUpdate=FALSE;
    6 R& g2 B2 L5 g0 \& G, x* r  z
  548.   dwStartUpSteps=1;& q$ l" z% h/ B7 F9 L+ U- Z
  549.   dwProgramState=AP_NOTHING;
    4 A8 Q* o$ l: O2 b

  550. 6 J5 T* ?8 l7 K2 e( {
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);
    ; g/ _  t  s. v1 W5 _6 D0 ^8 I" [& C! R

  552. 0 R. b' ^9 x7 \, R1 u$ B/ [4 r. p
  553.         // Standard initialization
    3 ~4 S; d' A  v; h3 T; f5 E
  554.         // If you are not using these features and wish to reduce the size( j; G2 s& V/ T" f
  555.         //  of your final executable, you should remove from the following& |4 R) t8 y+ F9 p. I0 U
  556.         //  the specific initialization routines you do not need.! x& H7 c+ E, p) ?; t/ W/ X) e2 i
  557. ; @! P: l4 f- E: C% R
  558. #ifdef _AFXDLL
    7 e/ f9 P1 d+ z9 P4 o
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL3 Y- r9 R# u' ]3 W& H: T; Q% V
  560. #else
    6 u' f( v$ N" g
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically
      |/ ]3 w% c. _2 l) I# L* g# G) j
  562. #endif
    ' H3 b/ Z, `7 R# r2 n8 x4 |/ _
  563. * ~1 G9 P1 ^  c! b, W0 `  J+ J0 E+ [
  564.   dlg=new CRevAppDlg;
    * O4 h) O) H+ x
  565.   dlg->Create(IDD_REVAPP_DIALOG);
    0 f, Z/ G. Y; J0 D0 W& K
  566.   dlg->ShowWindow(SW_SHOWNORMAL);- w" P( E. E2 `2 M
  567.   m_pMainWnd=dlg;( \$ m8 i' E" W5 R) F( W

  568. % s' [& o6 \' J' b" g7 p) J% Y( d
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);/ y- E$ t2 [: n3 s4 ?3 M

  570. ; D, [: _% |: K2 G2 f6 W3 m
  571. //  GdiplusStartupInput gdiplusStartupInput;  u0 y- v0 j- R7 K" |
  572. //  ULONG_PTR gdiplusToken;
    2 t5 [4 K8 e& F& w! N* a
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);% D# z4 c5 {1 l, B3 l; S' ]

  574. 4 x, `8 V  ~0 R
  575. //        CRevAppDlg dlg;
    7 j; t- N& I' Y
  576. //        int nResponse = dlg.DoModal();0 P# J: y& z9 x  M7 [* Q# L+ Q5 x  g: L
  577. //        if (nResponse == IDOK)2 s; F/ G: I- p8 L$ m
  578. //        {0 e2 o% e/ @. W) b3 c
  579. //                // TODO: Place code here to handle when the dialog is. G6 T# y/ S& B# J+ P) Y
  580. //                //  dismissed with OK
    / X4 z. U0 q" _3 L$ b
  581. //        }. s* \7 \0 [  X, [
  582. //        else if (nResponse == IDCANCEL)
    $ b8 \/ x/ S1 N$ {/ [
  583. //        {- X; x& k! W6 M+ H
  584. //                // TODO: Place code here to handle when the dialog is( ^; ]2 t8 \6 j0 D
  585. //                //  dismissed with Cancel
    % V, Z* [$ M3 s, x" n
  586. //        }
    9 {  ^6 l2 y9 L3 P5 Z( T

  587. ( L4 `& N2 W& B0 V
  588.         // Since the dialog has been closed, return FALSE so that we exit the
    , F5 g& S6 ]2 Z1 j4 C7 z1 U
  589.         //  application, rather than start the application's message pump.4 z6 ?1 S& a+ B. A7 {" V" m# m
  590.         return TRUE;
    / P- N0 K% i, X; `: W9 I
  591. }7 O- a) W! x, r0 l1 s8 |
  592.   p+ X& j" ^' ~! m
  593. char *CRevAppApp::strtok3(char *pSource,char *token)
    + e+ G9 _# m8 y- U
  594. {5 C5 g% ]! z3 Y6 ]
  595.   int i;2 m$ [1 q* P  |2 I" w& [, E2 h6 B
  596.   char *szRet;" A) \  Q' @# [6 C8 f. ?6 I, u

  597. * Z8 Q( A  E9 b- s2 m& K, c3 E
  598.   if(pSource) { itoken=0; sztoken=pSource; }9 |' t( X+ c& y( o" w
  599.   if(sztoken)
    2 }$ ^: @2 d3 @, n5 Y! ~
  600.   {3 o# J4 M: i7 l# H! x
  601.     szRet=&sztoken[itoken];2 ^& g, T$ w% n
  602.     while(sztoken[itoken]), O+ q2 T6 Z* x0 s: f
  603.     {
    $ R* t( a! m" `
  604.       for(i=0;i<(int)strlen(token);i++)
    7 K. c* z! u$ s5 _
  605.       {
    * U1 F+ ~) }/ N  k% S4 j
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])
    4 p1 v& p3 H3 D; h8 N+ O" O
  607.         {0 v7 h% H" Y, j2 V1 x
  608.           sztoken[itoken++]=0;8 b. @) F% m! l) O* a8 v
  609.           sztoken[itoken++]=0;
    . s+ O8 r9 i) j/ H- W3 y
  610.           return szRet;
    * r- E( m  [) z' A5 a
  611.         }( A) }( F8 J0 T- U
  612.       }
    / X- K2 C% V+ t& n0 T- d# v4 m0 o9 b
  613.       itoken++;& \: T; Z& p9 G9 U( g& o7 M
  614.     }
    . c2 K6 {3 p- N5 h0 }1 a
  615.   }8 p$ @  w1 u* I! ?$ l& \6 }
  616.   return NULL;
    - d7 Q* I7 e& W
  617. }6 J) J7 l/ W# D. D  c
  618. 1 q: M/ U9 t* t1 e
  619. void ProcessProc(long Total,long Current)$ y5 z1 Z+ X( f6 a
  620. {$ B4 B6 s1 @8 L: ?. Q
  621.         MSG msg;: u: l& }# Y* `7 h
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);7 L: S) g8 i& t
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));+ }2 [' a6 l. N. ^/ _2 D1 |+ L7 W
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))( t' @; `8 t/ C$ s& h( w8 |
  625.         {
    * L: u# M7 Z3 W" P
  626.                 if(!GetMessage(&msg,NULL,0,0))0 W2 X8 q! @# z# k& a9 y/ Z
  627.                 {  Y% s  {, e- [; r  s2 J
  628.                         return;; s9 q9 p3 R4 l  ~
  629.                 }
    1 n# h9 n$ `* h
  630.                 TranslateMessage(&msg);
    0 D# K/ V5 M! }3 _
  631.                 DispatchMessage(&msg);
    0 }' M& M6 J4 s9 T2 ~! d
  632.         }       
    8 ~) q5 V6 d/ ]  ?
  633. }& z9 ^3 ~- K1 Q) e+ H" A

  634. 1 f! w! O+ c+ l- X
  635. BOOL bFirstChar=TRUE;
    ! C7 z, @. h8 ^" \+ T* ~' L& m. ^. X5 e

  636. 0 M/ r! F% _2 ?
  637. BOOL CRevAppApp::OnIdle(LONG lCount)
      u2 V9 q3 Y; p% b" S6 Y
  638. {
    9 i( M' ?% k/ u( }! S! F8 [
  639.         // TODO: Add your specialized code here and/or call the base class' P" V( x* H, Q; E" e1 y
  640.   switch(dwProgramState)+ m! N2 C' Z0 [) O) p; S: [8 X$ z$ B
  641.   {
    ) S. [% c0 P' m+ ?9 V
  642.   case AP_NOTHING:' z' @! w( k$ b# c
  643.     switch(dwStartUpSteps)2 l- B" \3 W; h3 S' p
  644.     {
    . v2 a  l' R+ D) D( j
  645.     case 1:& B  u) ]' ?! x- r% v
  646.       {  \: _: i. k- h7 s) T
  647.         int i;; M# U  x" `0 E9 S* W
  648.         CDC *pCDC=dlg->GetDC();- @) P0 h6 ^1 [6 f5 ?6 q+ z/ z
  649.         HDC hdcwnd=pCDC->m_hDC;
    ( i+ t& W  T; Y4 ~
  650. //        Graphics graphics(hdcwnd);* B8 u$ X/ n1 Y
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");) j1 @% Q& l5 r( P& h. ?
  652. //        INT iWidth=bitmap.GetWidth();
    , s; g7 p* ^. u: O0 B7 u
  653. //        INT iHeight=bitmap.GetHeight();
    $ v0 {. z$ _0 i  ]( d
  654. //        Color color,colorTemp;  z8 {2 h0 V/ j) P# u
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)/ c" A; k+ `6 h
  656. //        {
    ! {/ `- }! @0 Y% z
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)
    ) }4 f0 @* @( ^1 T( g9 \- s
  658. //          {
    : I. y+ v, E( @
  659. //            bitmap.GetPixel(iColumn,iRow,&color);
    " b9 }) y# S9 e  V6 Y; ~
  660. //            colorTemp.SetValue(color.MakeARGB(
    # q( h' w8 L* X5 n! k4 i
  661. //              (BYTE)(255*iColumn/iWidth),
    / Z, B) X$ {6 B2 _, h5 h9 R
  662. //              color.GetRed(),3 {8 n& c% d( F- t
  663. //              color.GetGreen(),% K% T1 z6 s0 N; ^& H# x; v
  664. //              color.GetBlue()));
    0 l5 q% e; _! ~/ L" M8 W
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);, Q0 o5 r/ U3 e) W* \" L
  666. //          }; T# Y9 G" q+ z+ `" m8 w0 z5 }' x' r
  667. //        }1 y+ W" x+ s0 q$ i% r3 G7 D7 v
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);: M+ @  r2 r3 T- T' t
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    ( V8 @# z5 H  t& j
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");  j5 c6 Y& R7 v- ~; H& U4 `! g; s
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");* u! e5 Y! K6 c& A1 T1 N% w4 P: H
  672.         for(i=0;i<240;i+=8)
    5 C7 |+ u( p" m  ^: G
  673.         {$ A& X4 p5 q! e% u
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);6 O8 A* f0 W% m! [
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    6 v% D2 D) n8 ?, G3 ]
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    ; `7 C: Y. o5 L5 v
  677.           Sleep(33);
    % q; B* J9 }4 A' J+ `
  678.         }
    2 T, O2 k6 ^$ T. i8 }( d
  679.         Sleep(1000);
    5 i% J# e% t" j* Z5 ^9 b
  680.         for(i=240;i>0;i-=8)
    % X4 ]+ t3 j7 Z# X' g+ J
  681.         {6 y" c! d2 Y1 @1 R9 k" Z
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    / @, x( p8 F9 z
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);0 T; e. n& k: C, |. E1 s7 c8 e
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);. e6 I% j- ^+ M- {/ `; [: \- C- Z
  685.           Sleep(33);
    % T4 M& A) n( x5 @5 T# B
  686.         }
    $ l* P, E# W' [" ?5 X% N/ [/ ~
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);
    & u% ~7 L; |2 I8 K! H0 k" K. `
  688.         dlg->ReleaseDC(pCDC);9 X2 J2 s  A) C2 |- H7 Q
  689.         DeleteDC(hdctar);( N7 X1 `# {; m$ [) W$ E
  690.         DeleteDC(hdcsrc);
    3 ^% T2 `  N/ n! a9 X
  691.         DeleteDC(hdcorg);( L7 b0 Y# l* X( ]% l
  692.       }* S) s! V. n$ O; I+ O2 B
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);
    5 D! _8 n6 e) Q1 l
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");
    * q2 A- H: K2 S" C+ l. K3 Z& h  F- W0 x
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");+ t' i( ]" L# n. @9 W
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");. w+ ^: u, t1 z( N
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    1 S! F5 F4 \' l* [  T3 @
  698.       if(!Dn.Connected())
    4 t* P2 k6 @! ]2 w7 w. Q  v
  699.       {
    & y5 Z' K2 Z; p  Y* e. m
  700.         dwTotalFiles=1;" U4 N8 U% X$ Q0 f$ w: X
  701.         dwDownLoaded=0;. z( @0 }" w0 q# `2 g7 _
  702.         bSilentStep=TRUE;
    0 D4 u4 i: c+ S: z; g
  703.         bCompressed=FALSE;5 U: T. B* r8 H2 {1 z# j& A
  704.         strExtLocal.Empty();
    : H8 ~, P8 S. [# }1 n
  705.         strFullName="readme.txt";. o5 s$ i, q4 {/ w. h. W+ M0 ^. O
  706.         dwProgramState=AP_CONNECT;) k: v; L1 W* I* B3 y! ^$ ?
  707.       }# N6 g- g# B0 }! `
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();
    0 I( p+ h9 s" f
  709.       dwStartUpSteps=2;
    - e# N$ Q) f/ x  e
  710.       break;
    6 I- H6 @" F' ]6 D
  711.     case 2:& m# H5 u& y: R/ o
  712.       {
    $ D+ d: M) ?$ V
  713.         int iEOF;* K2 v! e3 b, M
  714.         FILE *fp;
    4 ~  ~8 {' h. D0 P
  715.         char szString[512];: @8 g+ @# c; {' b% O& X( ]" V: M$ y
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");- L8 N. p6 p2 X' i  N. J
  717.         if(fp)
    7 o: y5 A! z0 \4 c; U% |& ?0 K
  718.         {
    2 H5 k! n$ D5 @/ n. e
  719.           do
    : d: |7 ]# \. m' |$ h
  720.           {
      Y4 n! T5 y) F, |9 m& \
  721.             iEOF=fscanf(fp,"%s",szString);
    0 d6 r/ u& M' j* B' w5 w6 F
  722.             if(strlen(szString))  D9 y/ `5 N/ I; z1 b
  723.             {
    7 \  ?2 e* c7 z6 C, ~
  724.               if(bFirstChar)
    , L% Q, D4 v1 R9 v+ }, v
  725.               {
    7 a/ J% _5 Z# G8 {
  726.                 bFirstChar=FALSE;
    9 ~, K, ~$ Q& }* @
  727.                 bConnectIsBig5=FALSE;8 R$ @7 p  ^- G; n: x& d
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;) p# v% O4 c* ~+ u3 E: E
  729.               }3 w( \$ F4 |- b
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
    + g, ~' W3 f! a3 E
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));
    0 E: Z8 F( g# d. {
  732.               dlg->m_ListText.AddString(szString);
    . E0 y2 }6 {# a) R0 u/ i" P
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);5 |, D) ?( f5 K1 U
  734.               *szString=0;
    / O8 ^' L# L0 w* z- o
  735.             }
    5 |) f" K$ m7 E% C
  736.           } while(iEOF!=EOF);5 H" e8 h, A$ D, ]" W7 s
  737.           fclose(fp);
    6 P* J0 _% e3 [3 @
  738.           unlink(".\\DownLoad\\readme.txt");, J' g6 }1 t. W+ I3 G
  739.           dwStartUpSteps=3;: f+ X' O; C  z+ B: \$ L
  740.         }
    ' L4 ~. {* ~4 ]5 U0 H3 o. @
  741.       }* N& J) f6 L! W: O
  742.       break;
    ( N" Y4 o- l% Q: V9 A, b# p
  743.     case 3:
    . }- Y" m7 L! z3 v% O8 K% f
  744.       if(!Dn.Connected())
    3 K, I8 W9 [0 w8 @% d1 }  D
  745.       {
    1 }3 @( w: V% \3 s# S
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);5 H' ?; b7 c$ s1 h/ B
  747.         dwTotalFiles=1;
    / S$ V" `: r+ k4 b9 |: A  ?' A
  748.         dwDownLoaded=0;
    : t9 _2 r. S0 K, r8 i' I
  749.         bSilentStep=TRUE;
    2 @6 r! {" ]9 r  S: |
  750.         bCompressed=FALSE;0 [$ D, M9 ?* q7 V5 Z# g
  751.         strExtLocal.Empty();. N) u0 z. c% b  d
  752.         strFullName="checkversion.txt";7 A8 K  H$ e' Y( g" k( S9 Z
  753.         dwProgramState=AP_CONNECT;
    : D& [3 w( O+ X5 ~6 ?% J7 b
  754.       }5 ^# w* v5 G' |/ E- y8 ]) I
  755.       dwStartUpSteps=4;% j* p; C+ \0 u- g& {6 ?$ a4 h" X# n
  756.       break;; i8 H3 T) i# J
  757.     case 4:0 b) z) f1 S5 i6 ?0 R$ i- K
  758.       {
    7 O' L+ p' P- ^9 X: a
  759.         FILE *fp;
    ' w. T1 f; Y" _, s5 r1 c
  760.         char szString1[128];" f( A: R# r) o, i
  761.         char szString2[128];
    6 i2 H- a9 G) E. D) B7 a" A' b8 q
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");1 z, y- _& ^4 F& h1 V: D
  763.         if(fp)
    . n7 ~+ G" V  i. Y; L$ E) O
  764.         {
    ' [' B* ?8 |: F6 Y" R* w5 g
  765.           fscanf(fp,"%s",szString1);
    # O, e. {  y7 d, g# k" d
  766.           fclose(fp);
    4 Y. A( O! Z0 }  E
  767.           fCheckVersion=atof(szString1);5 \: V. [3 D; a3 B+ S
  768.           fp=fopen(".\\checkversion.dat","r");
    . N( X; E, b, _; V" A: W
  769.           if(fp)
    % I7 s0 e, f. \: V/ a  f, U7 b; ]
  770.           {( ]7 B; y. N& H/ n# F
  771.             fscanf(fp,"%s",szString2);( q) x# h" W& e; w4 b  l
  772.             fclose(fp);
    6 p/ ]# E) u$ s  }$ a
  773.             if(atof(szString1)!=atof(szString2))& P3 D: s! j( }2 j
  774.             {' \+ j3 c7 r: B: j4 y
  775.               if(!Dn.Connected())
    $ Z4 \' Q8 k; W" A$ H$ y9 u) M& x
  776.               {
    ) i: ?) S- @! ~
  777.                 bFirstUpdate=TRUE;
    6 |7 b1 ~+ R! ]2 D. v' r5 X1 s) V: u
  778.                 dwTotalFiles=1;. O2 e& F  l8 C2 j1 i- }1 R
  779.                 dwDownLoaded=0;
    , e# `# ?/ i8 [( d. K
  780.                 bSilentStep=FALSE;
    % a/ a: j+ u3 T
  781.                 bCompressed=TRUE;
    3 m  i9 W/ o/ J( H* r; L
  782.                 strExtLocal=".\\DownLoad\";
    7 U/ @( t; X2 Q! E, H
  783.                 strFullName="update.txt";9 I% [/ Q6 @( @/ g4 R0 _
  784.                 dwProgramState=AP_CONNECT;' f* G; h* b5 M+ X  B
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");" K% t6 c0 H+ I5 e; l
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");7 ~: r9 T( B6 P* k% P8 X, @: t; c
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");* k6 x9 m8 u! @
  788. 4 |+ T+ z( x; L4 L
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    & C& G- Q! |; P6 A2 u, E
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    2 _6 I1 a% [" \
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)
    , \; b2 |0 _; y: _" l
  792.                 {: r. Y. w! D: K0 o8 t+ S8 Z, j
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
      H) h" q/ t% L+ ~
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");6 V3 l' u3 j) f! L- l
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");
    * [/ f9 w, l' X: V7 c5 f
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    5 u+ x* i: V) y' u; e) D# c1 Y; I% K

  797. $ w! T' _+ H* v
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    7 u2 K# e8 S$ d" _: ~) U
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    0 S/ F1 c5 K! E5 v
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");1 U0 [! A/ S8 n
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    6 v2 \: k$ p- G& y- ^5 Q
  802.                 }' i( G0 L! B' v+ t8 y
  803.                 dwStartUpSteps=5;' v, g4 g9 V. l0 f7 Y
  804.               }: E- e- [2 b, S% {1 G( W
  805.             }% F0 k9 E  P% L9 u# ^+ [& s
  806.             else
    8 O6 d* f$ Q/ g3 K! d+ G9 N: ]$ P& V$ x
  807.             {% |! \: h2 V  [+ H/ d+ x
  808.               unlink(".\\DownLoad\\checkversion.txt");
    & N& }- k3 t, s* s
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    / g* v5 f/ _5 m% B
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");
    4 N+ t* O& d+ O' f
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");" ^* \2 S* Q2 c% y: v

  812. 4 Y  Q0 G+ `. A! W2 K
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ( ?- _1 B$ A; `
  814.               dwStartUpSteps=99;
    1 y6 y& y) y9 D. c: R
  815.               bFinishUpdated=TRUE;, {" F5 k; S+ z* o; h
  816.               bCanUpdate=TRUE;
    5 z2 I7 e. C, Y" e5 ]% q
  817.             }
    ) j# |6 D0 B: y5 b/ ^% }! {: A
  818.           }
    ' ~7 D/ I+ u  [; P' {
  819.           else; p' b& ~: x/ W
  820.           {6 S3 e0 s$ i- g7 f. I3 j  t* n
  821.             if(!Dn.Connected()). k; O2 Z& f. y
  822.             {
    5 r7 O3 [" Y% O7 O0 B; O0 \
  823.               bFirstUpdate=TRUE;" \* p8 J+ ~5 }! j, c
  824.               dwTotalFiles=1;6 g. b/ ^! P. J/ J+ t' j
  825.               dwDownLoaded=0;
    ; z5 k6 A: M, W) Y2 K. g; ^/ q
  826.               bSilentStep=FALSE;
    2 ?1 n: [* ~7 A3 p: y
  827.               bCompressed=TRUE;1 A' \3 h  u0 Y* ]* x2 G
  828.               strExtLocal=".\\DownLoad\";
    1 J' D8 k9 ]6 d/ B
  829.               strFullName="update.txt";/ ]' n! M5 j% x( k; W
  830.               dwProgramState=AP_CONNECT;
    ( L+ p# U& S; ~' Z3 E7 z- V- X
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");
    6 a, i- U8 q6 Y1 {- k
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    5 @1 S+ s% v+ `6 X+ b1 E  B5 r
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");& U- z5 n- O7 h; u: A
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    ! s8 U/ W0 i6 ~$ J
  835.               unlink(".\\DownLoad\\checkversion.txt");
      k& j( T& y/ }0 f$ X* ^6 [3 e7 E
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)7 A6 @# c$ _! T7 l
  837.               {9 G% ~1 C" O$ L  s( T
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");$ }8 B- n  y8 Z
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");
    + f6 D: B5 w7 T# L# T; w9 p" P
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");& G& G  z7 L6 x0 M3 U
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);6 k7 [  r1 h: P3 \* _( ]4 t
  842.                
    6 b: P+ K6 v# c4 N# R" U) G( K
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");
    ) t2 {  L: B9 t/ w8 T/ J
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    - f, ]- {" j* l
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");5 V5 v( S+ N& R8 g
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    6 z3 t5 {8 |9 h7 h
  847.               }- m6 l, u" n6 x2 U
  848.               dwStartUpSteps=5;% X" @- X* n- X9 v% L
  849.             }
    ; f. S' s: r! H& @3 p( U/ b
  850.           }
    % g* E6 j8 n3 A4 W! C. ^! r6 P
  851.         }
    8 |9 ^5 r8 f8 e9 S' w7 @
  852.         else
    0 @4 F+ M9 ?& @  e* L
  853.         {
    - g) {; A9 R! c- d! ]
  854.           dwStartUpSteps=3;
    0 S7 O4 l& Y7 x- T+ a/ }
  855.         }- N: A) l( _2 w* y) o/ K
  856.       }; k1 F  a. C( j4 }- n
  857.       break;/ _& w& v' S9 s  \  f; |
  858.     case 5:
    3 t+ r0 K9 T; b9 ?9 A, Z
  859.       {" z8 U. h! }! j4 Y0 a0 A7 M, M
  860.         if(GetFileAttributes("Wsa.zip" )!=-1); e# u- H9 V' a- t8 D0 `& r, _
  861.         {7 Y- f) d8 u+ j. L" j
  862.           int opt_overwrite=1;
    $ s! ~: m( q: R& c. w
  863.           int opt_do_extract_withoutpath=0;
    7 P7 Y  Y/ x: k0 m
  864.           unzFile uf=NULL;
    - z! O: S0 F. A, k
  865. 2 q8 z; f+ k* K7 V& W& P
  866.           uf=unzOpen("Wsa.zip");9 C8 Y* A! @' u+ D
  867.           if(uf)- l3 D  Q5 O2 M$ o+ y( k$ B1 m' p
  868.           {
    & r5 b$ k6 c& g4 m
  869.             do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
    # ^- U7 z$ n( k- ^2 f
  870.             unzClose(uf);4 R+ `  A5 z9 l+ l$ ]
  871.             if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃ЧΘ.....");1 M6 D! B" \5 P* o% r
  872.             else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压完成.....");
    " E+ g' y. k) I# \# x2 r
  873.             else                                                      dlg->m_ListText.AddString("Unzip OK.....");
    + ~* _0 W( {  e6 k' T' w% L
  874.                                           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);) s0 e' ~/ ]/ l* {
  875.           }
    ( g& v( @7 J4 \; m" o' F
  876.           DeleteFile("Wsa.zip" );% Q+ o6 a# n2 c8 v3 @0 e; l
  877.         }
    7 \$ I( w+ ?+ y! H0 c" S0 |& T

  878. 3 e1 D: w% O4 T; B
  879.         if(CheckLocalVersion())
    4 O# B: _' g. R$ B; v
  880.         {
    ; U  o" j& L5 R( m+ f# f* d
  881.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫磅︽絬穝戈.....");* j) N6 _$ N7 K! s/ f
  882.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请执行线上更新资料.....");
    * \0 q& ?1 V  G; @5 r$ R9 E
  883.           else                                                      dlg->m_ListText.AddString("Please update.....");
    ! H& m" c- G4 C% W8 v
  884.           dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);" f. k  ?, a( M+ [' X  F# u+ @
  885.           SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);. ]- m: Q; d& r5 G8 g3 F
  886.           dwStartUpSteps=99;0 }2 O9 D4 b, `  k8 B. }, O" v$ Y4 X
  887.         }0 }7 l5 a) [5 ^; _  F0 @- i" W
  888.         else
    ! L7 m3 W6 k4 c7 D2 v1 }
  889.         {
    ' W( e/ I4 h# K  N
  890.           if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");
    , p, ^: s7 D! i
  891.           else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");; H) {2 Q" Q% T# m' X# f' X7 l1 l
  892.           else                                                      dlg->m_ListText.AddString("no new file update.....");9 C& m$ L* ?- j

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

評分

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