CSUpdate.exe源代码

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

! ?' G2 H. z& t
  1. / RevApp.cpp : Defines the class behaviors for the application.
    7 z5 F. R) g' @  `% _
  2. //
      w1 R, z3 A- w7 j
  3.   b7 P) R8 d7 e! @$ ]! c' f1 \* J
  4. #include "stdafx.h"
    & w4 P% ?) l! x
  5. 5 |( m: \( X+ a# o' a; H( N( S
  6. //#define UNICODE
    / R) B: k! m& c( Z6 m$ X
  7. //#include <gdiplus.h>4 R" ^# W; l3 o2 }) m; p+ M
  8. //using namespace Gdiplus;
    2 R/ M, F& x7 p- E3 B. y' p

  9. : J! G' O- h6 `5 N5 W. r/ ]0 `
  10. #include "RevApp.h"
    9 O. f* H2 h- V
  11. #include "RevAppDlg.h"% _+ L. n- o* E

  12. / A* j# Q2 P- o& u* @& R, }& l
  13. #pragma warning(disable:4786)4 }! c8 }2 Q; m3 A' q/ e
  14. #include <map>
    . ~, ?0 t- _, m4 i/ ~8 j
  15. #include <list>
    : @' `9 U8 `9 x, r0 {" r' X2 T
  16. #include <direct.h>
    3 _; {1 E% k$ }, ?5 H! d- r
  17. * g8 D+ F0 K/ _5 r- _
  18. #ifdef _DEBUG
    ; ]  K4 s5 h0 b6 p5 b
  19. #define new DEBUG_NEW& Y& a$ l2 h4 Y) A
  20. #undef THIS_FILE" R0 @- w# b* X! J) z0 N9 G
  21. static char THIS_FILE[] = __FILE__;- ?1 ~! T  r* L
  22. #endif
    : O; R- }2 L( i# T/ \7 S" t* J
  23. #include "SkinResDef.h". T4 V! M7 O8 E: b/ A
  24. #include "ChangeBG.h"
    6 ?. E- ~: \2 p1 ]0 _
  25. #include "AFXINET.H"/ @: j) N; m3 q5 b5 _
  26. ' Z; C/ H) {' R# @9 H7 q
  27. #define TRADITIONAL_CHINESE 0
    / X% `8 V# M2 C2 E3 {7 K" M) z
  28. #define SIMPLIFY_CHINESE 19 G+ G. ^% F: u, c) W- U% K9 h
  29. #define ENGLISH 22 w4 w- j: v3 k
  30. int m_iLanguage = ENGLISH;6 O5 Z, J5 L: P0 }& W
  31. /////////////////////////////////////////////////////////////////////////////# {# a0 @3 O: c! f- b
  32. // CRevAppApp* h( i3 i+ s5 z- F7 v% W- G' P

  33. 9 l# r  I. c. U7 b
  34. BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)9 Y1 g1 g+ p1 s8 W
  35.         //{{AFX_MSG_MAP(CRevAppApp)6 K5 C9 ^- Z" p/ F3 t
  36.                 // NOTE - the ClassWizard will add and remove mapping macros here.
    5 K. M' r- c; K! J" x  E
  37.                 //    DO NOT EDIT what you see in these blocks of generated code!3 f# B+ H2 g8 I6 W$ y! M) ?1 C" W! \
  38.         //}}AFX_MSG
    0 h: a/ \* L1 l
  39.         //ON_COMMAND(ID_HELP, CWinApp::OnHelp): I$ N. z! F- ]6 ?, X- `. @5 }+ m
  40. END_MESSAGE_MAP()8 s  T8 W" O+ y' Z) v+ z0 [3 n$ w  A
  41. & {- j) P, s# Z
  42. /////////////////////////////////////////////////////////////////////////////
    6 i+ L. w. N7 j% T/ ]$ K
  43. // CRevAppApp construction
    4 u. l9 G. |4 A8 q
  44. ! M: q8 Z; E/ ^! a% Z5 {! L- f
  45. CRevAppApp::CRevAppApp()
    . ~- i6 T7 x* j6 R
  46. {
    ! v/ \. C  \5 Z* Y0 R* c9 `$ X
  47.         // TODO: add construction code here,; v* W; g) Z' n
  48.         // Place all significant initialization in InitInstance. r" P7 M  s' I6 I$ B9 T% |
  49.   bDisplayIsBig5=FALSE;
    0 v. F: L, X( F8 t# F5 z
  50.   bRestartUpdater=FALSE;
    1 x0 f& N% S- _# P6 A3 l
  51.   bFinishUpdated=FALSE;
    / J) m3 i3 m4 L5 j+ n; A
  52.   if(GetACP()==950) bDisplayIsBig5=TRUE;
    / X: t/ ]- y+ C
  53.   InitChangeDataBig52GBKS();/ p5 n8 Q3 N4 @/ {. y
  54.   InitChangeDataGBKS2Big5();
    ' z4 A9 w+ @0 P" o! k% H$ q; v
  55.         //
    + v# I+ ^( f5 w1 H. L% M
  56.         bClickRunExe = FALSE;# N: t3 y3 n$ F
  57.         //0 _: N6 B0 v+ p& h! i
  58. }" }/ ]7 e2 O7 X( r
  59. 4 Q  S$ u! \4 q  s
  60. CRevAppApp::~CRevAppApp()
    ' r8 ~9 [5 |' s
  61. {
    6 @; R9 n8 R% U$ u6 C) I0 h
  62.         // TODO: add construction code here,
    ' W/ [& K0 Z" l$ ~- s0 I
  63.         // Place all significant initialization in InitInstance
    6 I2 \' L, B9 }! D8 a& |
  64.   EndChangeData();
    : Q5 `* j" u' [9 L' p1 Y
  65. }4 p. w# c) V9 ~, Y/ d
  66. ) S: g( T$ j( H, @
  67. /////////////////////////////////////////////////////////////////////////////+ E# X3 t- X# \3 B# E& D+ [
  68. // The one and only CRevAppApp object
    ( ~' S( o9 i& ^! o2 E

  69. % c4 P4 z; g/ r3 i+ p
  70. CRevAppApp theApp;/ A# e3 L5 q, _+ J% d2 u" {; {8 h
  71. 1 Z" y) j8 g, E  y+ g
  72. char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)/ J, G) ^1 q/ A( o% k7 I
  73. {
    # R- Q- R: F8 v9 {" ^7 Z% l
  74.   int iEOF=0;5 M# S* T/ b/ K7 X- `7 g- o
  75.   char szTempName[MAX_PATH];+ g+ X! I& [/ s. r
  76.   *szFileName=0;3 x+ w2 E$ R9 m$ f+ w; v
  77.   iEOF=fscanf(fp,"%s",szTempName);. q6 f+ `1 A$ _2 k, e( n: q
  78.   if(strlen(szTempName)>=1&&szTempName[0]=='(')
    7 J( P: B' y* t& K3 k, p  j. N/ @
  79.   {
    - p2 i; g" s9 `1 L! @% M% B
  80.     strcpy(szFileName,&szTempName[1]);
    * B, B! b2 d, J: e+ V
  81.     while(!strchr(szTempName,')')&&iEOF!=EOF)5 U  K; L" {5 h5 m0 j8 c/ ?+ X) z
  82.     {, h, E7 q8 }) c" [
  83.       iEOF=fscanf(fp,"%s",szTempName);! y* C& B3 C/ ~6 r" S& Q& R
  84.       strcat(szFileName," ");! s# D/ ]5 |; {2 C6 h1 Q3 ?. U2 Z
  85.       strcat(szFileName,szTempName);1 d3 d* R' o% U
  86.     }9 R- r; V& d3 v; B$ v) N; U6 f" D
  87.     if(strlen(szFileName)>=1), R9 u7 c, r# U9 _
  88.     {
    % ~+ V  Y# K! L8 b3 ~# c5 x  a  U
  89.       szFileName[strlen(szFileName)-1]=0;7 G) x; K- j' D. f
  90.     }
    + C8 v' j2 _' v* ^
  91.   }
    / r2 d- t- `7 z3 c4 E" W( Q
  92.   return szFileName;& I6 d) p8 {' m  M8 Z0 h
  93. }( i5 n% N5 ?- U7 ^: u6 i
  94. 0 S' Y2 A5 x- H- `7 P) ^  N" V- O
  95. bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)
    4 l* k' H. L, ]; S
  96. {' Y* B" n% [* M) [- Z8 a
  97.   FILE *fp;
    / ], J: n) [; `4 S. z
  98.   char *key=NULL;
    1 F& b4 ~0 g; z; a- B( U5 V# j0 a
  99.   char version[MAX_PATH];
    # Z3 T  H1 C+ t# m
  100.   LPUPDATEFILE file,olds;
    5 }6 U! `! P; f, X7 e- _
  101.   std::map<CString,LPUPDATEFILE>::iterator p;2 |$ @+ P/ M6 N4 \0 }4 S

  102. & G' P) Q4 K; {' \$ H$ F; q
  103.   UpdateList.clear();# f+ K# h% u* z6 A* j6 @  m
  104.   UpdateFile.clear();1 m8 P5 W( f6 K& Y) Q
  105.   if(GetFileAttributes(filename)==-1) return false;
    ) J! s4 y% a# f- f
  106.   if(!(fp=fopen(filename,"r"))) return false;
    & ]# R9 o! s8 f9 _
  107.   fscanf(fp,"%s",version);
    * ^0 ?- H$ t  i% h
  108.   if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }+ @0 J. Y2 f6 _9 g# f4 |- D
  109.   while(fscanf(fp,"%s",version)!=EOF)
    ( ~: u% h+ G: N' H
  110.   {
    , j8 U2 o/ a! ^2 o: f( t6 g1 K
  111.     file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    % w/ B/ c' [9 b# ~/ @4 D/ F
  112.     fscanf(fp,"%s",file->path);( C' G+ N- ^6 ]7 R
  113.     ReadFileNames(fp,file->file);
    " I0 q; k) p2 F1 ~: h# e. H
  114.     strcpy(file->full,".");
    8 _/ G' P" H9 K1 ~
  115.     strcat(file->full,file->path);& i0 t" b( `( i( P- ~2 i1 n# y; n
  116.     strcat(file->full,file->file);
    6 I/ L  ^. r9 U4 J1 O4 j# T
  117.     if((p=UpdateFile.find(file->full))==UpdateFile.end())
    ' ?3 U) o. w% U& F& h
  118.     {
    5 c3 F; x$ N: J7 V! \
  119.       file->vers=(float)atof(version);9 D+ z, i9 C5 ^
  120.       UpdateList.push_back(file->full);
    % x) X6 G  c# m! e% {
  121.       UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));% C7 p! s# N! ^  @  \
  122.     }
    " c. E8 g5 i: T* R6 }& ^, n2 g
  123.     else+ K4 }1 s' p# a
  124.     {
    6 L* U! N# `3 D5 {  y
  125.       olds=(*p).second;
    9 k5 p8 t7 p- ^$ x8 A
  126.       if(olds->vers<(float)atof(version))
    / W+ e, j9 q6 R; U3 L* k+ C
  127.       {5 t! y5 P, _6 O; T# u, X% W0 M9 L
  128.         olds->vers=(float)atof(version);7 u8 Z& B% G9 s5 t1 t7 Q3 I, J4 ?  o
  129.       }
    + M, U* J5 C. o# w  }) B8 X" {. E
  130.       free(file);; _0 i. M- x# k4 ?0 E# V& n; U
  131.     }
    + }$ ?" Q1 M! v( B* D6 U: Z
  132.   }+ l0 {, O9 \; L) v5 F
  133.   fclose(fp);
      D1 P2 v/ ?; ~" R; F& {
  134.   return true;) ]+ e  }+ T* v
  135. }
    7 O) V& r6 h. D# {  D2 w' B4 [+ z, X

  136. 8 R6 ^' e: i( l2 r0 [$ e) P
  137. DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)
    9 k& ?1 V: L- U; c& u) j3 r
  138. {
    + b8 g1 v! i: f& j3 q% F
  139.   TCHAR  szFull[MAX_PATH];
    . S0 v7 T" t  G3 H( f0 z- V' |
  140.   TCHAR *token,*inter;
    , u7 `, r$ O) z- [- L% w# I( w; q, x
  141.   *szPath=0;
    9 q$ @; h% b% L2 m7 O% W  I
  142.   strcpy(szFull,szFullPath);
    $ T. Z6 ^+ @* Q& z, x
  143.   token=strtok(szFull,"\\/");
    : d. P2 X( D8 |' `! x6 x% m) Z
  144.   inter=token;  C: n( H% n  x1 X) h; W3 L# k
  145.   while(token=strtok(NULL,"\\/"))
    3 V" @3 o' o, K$ ^; R% i4 k. V# e0 i
  146.   {
    ( c- N  L9 [4 D7 t* ^* c
  147.     strcat(szPath,inter);, I6 q2 q/ ?9 k. y% B* \. w
  148.     strcat(szPath,"\");5 W. n0 o; U; v# L7 P& j6 K) y
  149.     inter=token;5 G* E( P5 _1 \/ Q6 R
  150.   }
    ' }# U+ t3 `! u4 b( ]
  151.   return strlen(szPath);- o$ s# }3 q4 ~
  152. }8 C' [. k. ~5 F* S1 A3 [  M
  153. & K( \. f2 K9 p* F1 @5 I
  154. void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)
    7 O  q3 i& a( l1 [2 j( @" Z
  155. {9 ?7 b# Q0 l6 ]2 O) T
  156.   DWORD attrib=GetFileAttributes(Target);
      _2 m- n; Z! a6 ]* Y3 I- V
  157.   if(attrib!=-1)
    $ f( R2 ~9 ]- P
  158.   {# B3 b% e' F' l% o: S7 b, C
  159.     if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))
    - u3 N% t* p) F6 A
  160.     {: u+ r1 p5 o; I' L+ l% m/ z
  161.       attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);) y/ y" U$ b2 X9 |' @( ^
  162.       SetFileAttributes(Target,attrib);
    : Z3 V1 ]& K2 q6 z
  163.     }. ]$ S" ?( g) r' s# e" A
  164.   }. F& Y; f& i2 W1 S/ t! M; G( R
  165.   CopyFile(Source,Target,Erase);
    . F0 e  b* ~# Q& J$ j$ p9 a
  166. }" i( p# A( ^0 S  `$ U8 `& v/ q0 C
  167. 0 s. y6 y- o: {/ L
  168. void CRevAppApp::Fprintf(char *FileName,char *message, ...)
    ( D4 l* ^& N- x2 A3 \8 a
  169. {
    # z9 E& _9 W8 N, X& W
  170.      FILE *fp;$ m- t8 |& e6 m
  171.      char  szBuffer[8192];
    1 O7 ?, P9 u8 d9 B& h& b9 J9 @
  172.   va_list  argptr;
    : s. c4 s2 W$ q  ]+ I
  173. , ~( i& a# ]. z: f4 x" j& o
  174.         va_start(argptr,message);
    " @$ a; E5 |" A( M
  175.         vsprintf(szBuffer,message,argptr);
    * m5 }  P6 F  x
  176.         va_end(argptr);, E" v+ t0 r( b& h% N5 z5 p' \
  177.   fp=fopen(FileName,"a");
    6 v$ L; b% }1 v7 z7 W& F9 k
  178.   if(fp)8 I4 @9 X" B' k: S3 C+ i) k8 a* v
  179.   {6 `/ J, u+ Z8 e
  180.     fprintf(fp,szBuffer);
    : z- e& ^0 Y, f* Q* N6 [* h
  181.     fclose(fp);
    : c& M! N! X& q$ `* n& G
  182.           _flushall();
    ) R7 H) k+ t/ t6 z! z/ o; g0 J
  183.   }
    * w* i7 Z5 Q+ a4 R% k$ ~
  184. }
    & C7 y* }- k8 r( s
  185. $ E& B7 e) n3 A6 o
  186. BOOL CRevAppApp::Fclearf(char *FileName)' H/ L: N; Z% l& M6 ]# B
  187. {
    $ }1 e/ E( W/ d2 Q- J1 E
  188.      FILE *fp;  p: C9 {6 R! H3 j! [: V1 p- _+ r
  189.     DWORD  attrib;5 I5 t$ _9 |% U3 {& X* K) g/ f
  190.   attrib=GetFileAttributes(FileName);" H. n' k' f1 {) I
  191.   if(attrib!=-1)6 G& \, B, _; T
  192.   {( r" P$ d' [$ P3 v8 o
  193.     attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
    4 m$ k' k( B) m
  194.     if(!SetFileAttributes(FileName,attrib))1 b* X! N- V/ ]+ U6 V/ J+ O
  195.     {& Y: M, a& Y6 ^
  196.       return FALSE;; i+ \2 Z6 W/ d7 B
  197.     }
    $ g/ V/ w  M1 w  I' R: P
  198.   }
    $ x; Q! N* A5 c, M2 @
  199.   fp=fopen(FileName,"wb");
    % [" r! o7 G' w: m; t* M
  200.   if(fp)
    ' q- J4 ]& \, D! F: A
  201.   {8 A" J$ b2 Y/ E; @
  202.     fclose(fp);
    ) h! c* H0 T; x
  203.   }. F; e  P) K' }& k; R
  204.   return TRUE;
    9 S  t1 I& A8 ^$ D
  205. }! v8 n. g+ A1 \( [( {' F" B; W

  206. " c$ q$ [' Q3 h- n
  207. BOOL CRevAppApp::UpdateLocalVersion(void)
    8 X2 c' w. }9 c
  208. {
    % W0 @9 m3 g9 e5 I1 I3 s
  209.   char filename[MAX_PATH];
    5 `% J6 x4 @1 _3 W4 n$ Q. @
  210.   LPUPDATEFILE file,olds;5 [/ ]6 D8 `7 [/ G4 t  C! q. t) B/ C
  211.   std::map<int,CString>::iterator i;9 @& ^, i5 \4 J9 C
  212.   std::map<CString,LPUPDATEFILE>::iterator p;
    : W8 |8 f: e' U: U& w
  213.   std::list<CString>::iterator l;/ A: S9 L2 H; N: ]$ P; V& M" H

  214. $ }; ~& l0 i7 ~9 j" x, m
  215.   if(bFirstUpdate)
    ) S/ f0 G+ q& O/ Y" f4 _
  216.   {3 r6 M8 t, R& {  n( q
  217.     dwCurrFile=0;
    . J: n9 r! \0 o" f4 Z$ b
  218.     bFirstUpdate=FALSE;: R7 t4 t8 z  g2 g
  219.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())
    $ {0 _- S' U1 ?. x: C% M
  220.     {8 H- c. V; d/ Q0 _. k
  221.       dwTotalFiles=UpdateLocal.size();7 {5 ]% o5 R% W# `& @5 j
  222.       dwDownLoaded=0;
    9 b1 q- d- Y* @; d  G
  223.       bSilentStep=FALSE;' [) D% Q9 O4 `4 W" R  _
  224.       bCompressed=TRUE;
    0 L3 z' j- h5 E6 N6 J$ s
  225.       strExtLocal.Empty();
    : r2 E- e* j1 A8 a! h8 w4 j9 d' p
  226.       strFullName=(*i).second;
    2 P3 H  L6 n6 _6 N- |; R% j
  227.       dwProgramState=AP_CONNECT;; M+ F8 v! P% Y
  228.       return TRUE;
    , Z1 {. G8 U$ I8 q
  229.     }; W0 w& P1 [, s8 K/ S
  230.   }8 g0 @2 _0 e7 g9 b0 {  B6 }
  231.   else if(bRestartUpdater==FALSE)* a+ v- C: w+ i- b- J, ~3 r7 s
  232.   {3 `( g7 t4 ^: g
  233.     if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())3 @* ]- S! i. j' G2 k8 s
  234.     {8 [7 I! r1 W7 ~- C% z
  235.       file=(*p).second;6 `- C  b8 w" L3 }
  236.       if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())
    - K2 O+ X- F" D' j# a7 A
  237.       {
    , F7 u0 X" N' `# i; H
  238.         olds=(*p).second;
      Q% {5 r; ]3 }6 Q
  239.         olds->vers=file->vers;% i+ q  k: @( @
  240.       }
    + r, N" _1 e/ h4 r
  241.       else' x  }/ j8 w' n: A% e, T
  242.       {7 Y4 ]5 N/ n  H5 M4 v) U
  243.         olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    & p5 ~9 ]. W; M
  244.         memcpy(olds,file,sizeof(UPDATEFILE));  H7 L$ W' G& p/ N
  245.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
    0 a* Z0 i, [+ |. c# F$ ]+ _
  246.       }# y. _2 l7 p0 g
  247.       if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");. S' y' R* K; D  h+ R; A' e& M
  248.       sprintf(filename,"(%s)",file->file);
    2 j1 P# K4 u9 m& ^
  249.       Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);3 ~! i: h8 g* h/ V
  250.       if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }* u7 ?! T% c$ ~' y
  251.     }
    8 H; N# a- V0 d% e
  252.     dwCurrFile++;
    . v7 ]0 f# G0 v3 u! Z
  253.     if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())7 y. }0 h5 u' s6 Y6 r$ N3 ~4 H) V
  254.     {2 K1 m- m9 y/ ^1 _7 I
  255.       bSilentStep=FALSE;% K5 h  d0 _6 a5 a, }
  256.       bCompressed=TRUE;/ T, N* ?  Z" f; x4 ]7 l
  257.       strExtLocal.Empty();
    7 G8 J; b$ K- g8 h8 ]6 r* {
  258.       strFullName=(*i).second;
    8 w: M/ u6 {6 T& l& t3 N' _
  259.       dwProgramState=AP_CONNECT;
    ! L2 H: d0 a" M/ F& v
  260.       return TRUE;
    . O9 y/ E3 M! Q. g8 ]
  261.     }
    , n) A* `% P  C, t
  262.     if(!bRestartUpdater)4 O# x+ ~4 ]) q1 f* q9 Q
  263.     {9 S4 b" e# k" P$ |9 G. f4 j1 C
  264.       int iCurrSize,iFileSize;
    : k& n' x. h+ |3 N4 }2 y
  265.       iCurrSize=0;+ c% p& Y5 Q3 W7 ^. D- v. G' Q& G, ]
  266.       iFileSize=UpdateList2.size();  e; Y' j" a' H: F/ P
  267.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝戈い.....");3 u& e3 x! G& H, h2 G9 e
  268.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新资料列表回存中.....");; ?. }! o6 S! ]- {- L; k
  269.                         else                                                      dlg->m_ListText.AddString("saving updated files.....");4 @% U% k5 V  r% n
  270.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    % ?/ d7 E! S! n# U# R
  271.       Fclearf(".\\update.dat");
    6 P# b- r7 g' u" h& A; c
  272.       Fprintf(".\\update.dat","Bloodyf\n");
    . Q7 o% Q: K1 K# F! K
  273.       for(l=UpdateList2.begin();l!=UpdateList2.end();l++)" z0 ~, p1 d% }" p9 ~( Z
  274.       {
    : S  |% A: ~; Z+ y" u- U
  275.         if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())
    9 g0 L+ H$ l4 i' {- E# u
  276.         {) g& R0 t+ J3 Z  {# S4 @/ s
  277.           file=(*p).second;6 B% W0 @9 I3 A4 c2 `
  278.           sprintf(filename,"(%s)",file->file);- P, Z# K2 R1 K7 y& t8 |
  279.           Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);
    + {# h! B* S- `1 A  ^: b1 S3 K0 Q
  280.           iCurrSize++;" P# T$ h0 k& T# v7 l% t1 @
  281.           dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));- L/ j( x4 |( ^; X- t
  282.         }: I& ^) x9 V+ X' M( O$ L3 N) T
  283.       }
      n. p( ^6 L2 y% {" Y& D1 r
  284.       unlink(".\\update.txt");
    8 I+ I" k2 U6 t% e  a
  285.       unlink(".\\update.tmp");; E: q" r! I# l7 `  q; L% S& `/ |
  286.       Fclearf(".\\checkversion.dat");( |, U. Q& v: d/ k5 p. W
  287.       Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);
    / a6 U' X+ r! |+ r/ }
  288.       if(UpdateLocal.size())
    ; j, _$ j) v6 h' V
  289.       {
    ) G/ b9 V7 N4 u/ C5 u0 J
  290.         UpdateLocal.clear();0 o* O. M( p% v' U: S0 w9 A
  291.       }
    , D9 V+ x' g( L8 K9 ~
  292.       if(UpdateFile3.size())0 s" ~# ~9 D' _! Z6 B; F) V
  293.       {2 I" r# {0 d" ~$ S0 t
  294.         for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)' `% p0 E9 P: M% D  c! k8 T: C
  295.         {
    4 h1 M+ A" F( h& X* B
  296.           file=(*p).second;
    5 d* E6 p1 n4 u0 K/ {6 P8 T3 T
  297.           free(file);2 S# h9 C; R: e0 x6 u2 I
  298.         }
    1 d& @" V& u4 z  @6 a7 L' p4 i, D
  299.         UpdateFile3.clear();* S' R5 V4 C- G6 R1 n6 F: u9 t
  300.         UpdateList3.clear();! j  V' E; a6 o
  301.       }
    ) ~7 q% r/ x3 {% M) k
  302.       if(UpdateFile2.size())) ]8 t7 N4 T5 f  o' {! `
  303.       {
    * e* T# z5 I2 P1 s; W
  304.         for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
    ! E" w1 l7 E2 b: N/ L3 d7 m" L
  305.         {
    ) f  s8 A1 a) i4 ]1 D
  306.           file=(*p).second;# C  ~# W! Z% M4 [
  307.           free(file);7 Y! A0 p, Y+ t$ \  h+ f3 l/ ]
  308.         }* K  ^& k' m1 I* `
  309.         UpdateFile2.clear();3 m% c/ Z: u8 G" K0 l
  310.         UpdateList2.clear();
    8 e; i8 Y& ]2 ]6 u
  311.       }% x9 M; ?" o: C: K, \( w  b
  312.       if(UpdateFile1.size())
    / \, D$ H% T7 a4 E$ y5 R
  313.       {0 N4 |' C( o: H$ m+ U8 A' `( D
  314.         for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    $ e/ n) H- u0 ?
  315.         {0 @/ t' R) b" ]  e( O/ }
  316.           file=(*p).second;! x# m4 s, q+ E
  317.           free(file);9 c0 N; l* l0 j5 I; s% @& w5 R
  318.         }/ P4 G/ }" u) e+ r" b. e- ]
  319.         UpdateFile1.clear();
    ' a' u4 [+ t/ a8 ]0 c
  320.         UpdateList1.clear();9 ~8 ^; B, r& W! q& I9 U- C
  321.       }
    ; e4 R# N. U% a# M8 d
  322.       dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));: ]6 X$ J$ G' z# {! W) N1 {+ Z
  323.     }
    ( h$ @( \/ D( H; V
  324.   }: S5 \9 Y& z& Q
  325.   return FALSE;2 n9 b" c2 b# j
  326. }% w  l& ]2 f  j, o( x7 D
  327. 4 }# h7 {! S" Y! U5 Z
  328. void CRevAppApp::ClearAll(void)% F; R$ I, a$ X
  329. {: r0 f* ~% k( \7 O9 B8 S" N! K0 P
  330.   LPUPDATEFILE file;+ Y+ ~" t7 ]7 e  j% I! ?
  331.   std::map<CString,LPUPDATEFILE>::iterator p;+ i" V" M% K, G; E, z4 P+ \

  332. # Q3 `% I$ w1 T+ A! |* }
  333.   if(UpdateLocal.size())
    , t9 y$ w" B& x; G; ^5 n% S/ t
  334.   {
    . l2 Z: [6 W( u( @$ w+ w
  335.     UpdateLocal.clear();
    0 w" f3 k' J* D
  336.   }
    ! o/ F; S. z" q: A; \# ~
  337.   if(UpdateFile3.size())# Y1 o& [: q7 j9 K4 c( F: D7 ]
  338.   {0 y, A7 C9 \( |6 j. H
  339.     for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
    9 {' \: g- h' G1 G4 q2 a; z1 O
  340.     {
    8 O- ~; g$ \4 h  V
  341.       file=(*p).second;; Y* f3 ?% Z9 R, d& n' U
  342.       free(file);
    5 @( D; g. s$ D
  343.     }
    1 d# P" I) @  p4 g: I
  344.     UpdateFile3.clear();% N5 c% m+ ]6 H# C2 N
  345.     UpdateList3.clear();
    ( y* {8 o/ {% A& {4 `* S
  346.   }+ }- G& ?$ h: i% t1 T
  347.   if(UpdateFile2.size())6 [: j8 ]4 T  Q/ r/ i( P. @1 j
  348.   {/ P, L. o9 C0 q2 |  R: W, S$ V, s
  349.     for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++); x5 y4 R9 k% I! q3 E' s% [& S8 \
  350.     {3 W4 s( [+ v! g, q4 l
  351.       file=(*p).second;" Y9 t. p+ @& Z( c# X- Y+ P5 |( z
  352.       free(file);
    , i4 D. R% n; b9 N
  353.     }
    9 p  T5 d: s1 Y! V
  354.     UpdateFile2.clear();7 L, g& T0 ?$ m  Y- q8 {
  355.     UpdateList2.clear();
    $ U. ^' u. P: ~' |
  356.   }2 R- G" d6 R  D0 [9 W) Y" |
  357.   if(UpdateFile1.size())
    - V# L9 [0 C) S: i8 K
  358.   {  F4 a5 D9 y! M- M% }4 R( n2 T
  359.     for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
    + @; i/ R6 T! v' |
  360.     {. ^" W3 u" @* N, U, z
  361.       file=(*p).second;
    3 H7 |9 i3 k, s2 x8 d8 R1 @1 i
  362.       free(file);
    / E9 @% z0 N$ m' m+ o
  363.     }
    1 N/ u% w5 B! F: G. _7 ^" a) K
  364.     UpdateFile1.clear();( w$ p7 k+ r( b3 _6 |
  365.     UpdateList1.clear();
      a. L: K; r: [1 p$ k' D
  366.   }
    * ]+ z: D: S% E$ P9 r$ B) g
  367. }  ' ]6 `" B! x/ I) W  Z. d
  368.   
    & g% @9 L! d- R' J5 q
  369. BOOL CRevAppApp::CheckLocalVersion(void)
    * s3 W' k+ E! _
  370. {$ x* R9 A" W3 e- K
  371.   int c;
    3 {8 f$ \  q0 w' d6 D
  372.   LPUPDATEFILE file1,file2;
    + J6 e4 B( r: C2 V- k$ v7 d
  373.   std::map<CString,LPUPDATEFILE>::iterator i,p;
    : C& g  g  `3 Z0 G
  374.   std::list<CString>::iterator l;
    # |+ T6 F; y7 ?0 _5 ?+ W; l
  375. & c) Q' S2 p7 ?) r
  376.   UpdateLocal.clear();
    6 ^) y8 q' O/ O; a1 Q
  377.   LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
    : \; y3 \& j) [
  378.   LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);
    8 P# A. n4 u. z, a& }6 z/ x
  379.   LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);9 B8 d+ N5 Y, q8 ]( @0 `8 m, E+ r
  380. //  if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);
    5 j% j$ L. c+ F9 s" Y, l& V
  381.   if(UpdateFile3.size())/ J! F& s1 A3 V9 r
  382.   {& M% A, S- p) F8 I
  383.     for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)
    7 n+ n! a+ w: p) _7 U$ y8 k  H1 y
  384.     {
    5 O( ?( {9 @+ q1 A. D6 b( `
  385.       file2=(LPUPDATEFILE)(*i).second;. v7 M% v* [8 U1 s, x: Q
  386.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())5 L0 s+ B: G+ _) h; d( ]) s6 X
  387.       {* q7 J2 F1 R% y9 r- t4 [$ C) l) I
  388.         file1=(LPUPDATEFILE)(*p).second;, _( _. e5 a* a1 Z! X
  389.         file1->vers=file2->vers;
    1 T" E6 G+ Y  Z8 B! y
  390.       }" e+ P7 V$ x( T: @/ M* J# @
  391.       else
      W/ G+ K+ K9 L+ R" W: j
  392.       {% C9 n! t3 o  c- d0 K# @: |
  393.         file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
    ) ?7 Z- _1 W# `' W
  394.         memcpy(file1,file2,sizeof(UPDATEFILE));  o0 ^. j: p* z* Y
  395.         UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));2 B: l% n* d( y$ I: C; c
  396.       }
    ) r% x! d% S7 T" i
  397.     }2 v6 G4 o( v7 }, v* I
  398.   }
    ( h: s2 K4 A9 f
  399.   for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
    % C9 s7 V+ J. V. H" f9 z
  400.   {
    1 x) Z! [8 [: Q7 m0 @3 }" H
  401.     if((i=UpdateFile2.find(*l))!=UpdateFile2.end()). g# W9 D& B  D$ K
  402.     {2 y& ~$ ]8 e; u6 w) b
  403.       file2=(LPUPDATEFILE)(*i).second;
    4 }5 i# _* s" g4 q) b; _
  404.       if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())/ Y* z+ }- e, V8 R2 V
  405.       {
    2 z  [+ _7 M( R0 p
  406.         file1=(LPUPDATEFILE)(*p).second;
      V$ r5 a6 I: `  W
  407.         if(file1->vers!=file2->vers)
    $ ?- W4 z5 K/ o( |9 R( B! B" u
  408.         {3 t+ v# I. i& V2 u% E" K) C9 @
  409.           UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));7 b. H6 j& l  H4 i
  410.           c++;2 D: n& k5 ~6 T3 h1 y$ f5 D& P
  411.         }+ t1 T( T" H+ F  U5 b
  412.       }0 I5 }7 @' T4 ~( V% z
  413.       else
    $ s  `/ }' m* _- @- }
  414.       {
    ) S5 O2 }  e+ f8 ]
  415.         UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
    1 Q7 Y4 y. h  R& V7 A8 e2 `5 C
  416.         c++;
    ! J* N+ `$ \% c+ U# b
  417.       }
    . r9 t0 `3 G. ^3 w& M
  418.     }6 M9 z% _6 W7 }* y; D
  419.   }
    % s, M7 ~1 E% C& a- H
  420.   unlink(".\\DownLoad\\update.txt");
    ) Q' O  N, R' j6 G/ \( D& y
  421.   if(UpdateLocal.size()) return TRUE;4 N9 w2 d- T$ ]1 k; X- g
  422.   else                   return FALSE;0 s2 ?3 _" c- t) q7 v. S' m9 q
  423. }
    # D+ x$ }2 q) \! v

  424. 4 \- D# x& u' [/ h
  425. #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/"3 T* f3 P7 J$ V! O4 C
  426. #define DEFAULT_REG_URL   "www.wgs.com.cn"# Z3 R6 \# X5 _+ e% K

  427. + k& ~0 I1 Q" R4 r! Y7 E2 J

  428. 3 Z0 K! b6 |( m: _) O4 T! c4 D' d' E7 X
  429.   a, H, u7 }8 J8 ~% l
  430. BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)8 [0 d7 ^$ z8 y! X
  431. {0 w" \' s+ V0 ^7 |+ J+ |8 r( `
  432.   DWORD dwType=AFX_INET_SERVICE_HTTP;: B0 R% m  y. m4 U, o- s% _- ~
  433.   if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
    . h5 ~, A  j9 {& Z- Y: ?, X
  434.   {5 \9 y5 M6 `3 J( V
  435.     char szLanguage[50];
    / @9 E0 ^# z- ^5 ^* ?2 o
  436.     GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");  s+ r3 }, V+ ]- G1 s2 p
  437.     if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;
    ' o0 z. m" q  t' ]
  438.     else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    9 o6 ]) o( f. Y$ Y' k
  439.     else                                   m_iLanguage=ENGLISH;6 l) F4 t- q" `! W' q# j  j
  440.     char szRegister[100];
    & C5 Z9 N6 q  W% @- i
  441.     GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");$ k- m) k9 F" Y' R
  442.     strRegsName=szRegister;
    8 F# S% F- W: B( a
  443.     char szPatchURL[100];! ^+ j( c# |) S( h
  444.     GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    & }) T  ]& r6 b; S, {4 q( G
  445.     AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);: N, x+ y) Y# o- K
  446.   }
    + H1 E; m5 h! x: ?" e2 G
  447.   else
    3 j  y4 d. q* d) D/ s+ e0 v
  448.   {: n( i9 ^' F) x9 a2 M; a( F
  449.     AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);  k# b, I- z1 y7 b' t
  450.     strRegsName=DEFAULT_REG_URL;& l9 ~! N1 y0 T& j8 N- B
  451.   }5 I2 @* c8 {% e/ c
  452.   if(GetFileAttributes("hosts.ini")!=-1)% f6 S; x" w  a% x
  453.   {& I3 @) y% p4 Q# ~) f
  454.     char szIP[50];& W9 P0 b( B. b# ~, _) S+ E- ]
  455.     char szDIR[300];
    : c( A* @  D2 u1 K: t
  456.     if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))* f/ [  S6 U1 Y( _/ w& n2 f  B7 l
  457.     {
    1 u% z' n3 y) m+ y5 |& K
  458.       wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");; U$ Z7 o6 e& ?; q0 Q7 k
  459.       GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
    ) B& a7 P, d6 _( @' O. o1 p/ B+ F$ J0 m
  460.       strHostName=szIP;
      e9 u) C( f) |. L0 b" R+ E" d
  461.       strHostPath.Format("/%s",szDIR);$ T+ Y$ u0 H3 r. F
  462.     }0 T2 ]; q) P: I0 i- ~9 \8 A4 d5 s
  463.     else. ?; h8 v& T4 n3 t
  464.     {
    4 r" Q% p( j" t& @
  465.       if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
    8 W# \/ F" D" z; ]7 w2 S
  466.       {/ ?8 n) p4 S0 F. p* I/ ]6 o* S
  467.         char szLanguage[50];/ @+ [4 t2 g0 T6 t4 _
  468.         GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");; ~" O7 U" l  k9 a1 F! N8 M+ u, r2 ~
  469.         if(!strnicmp("BIG",szLanguage,3))      m_iLanguage=TRADITIONAL_CHINESE;2 q4 M: b! r7 l8 |
  470.         else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
    2 \1 E- \$ z! C! w; i; X- i' O' _
  471.         else                                   m_iLanguage=ENGLISH;: f4 j, D  S" f9 Q' {- q/ g
  472.         char szRegister[100];
    ( x& d; P8 ^9 ^; W/ W3 s  l& {
  473.         GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");
    ' l7 L5 O1 q4 G  ]4 m: u
  474.         strRegsName=szRegister;
    / n- ~/ }+ C1 F/ F% J
  475.         char szPatchURL[100];
    - b, p3 v2 t' ~" V  }+ l6 i
  476.         GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
    / l# ^9 M9 \$ |7 M1 x
  477.         AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
    : W3 Z8 a. g7 n0 a' H( \5 L
  478.       }
    8 \% X: ?- ?' R( K8 ^! h+ Y- N
  479.       else+ v0 h6 l) S2 H7 E; k0 R# |
  480.       {9 Z2 N' _6 f/ S" o) }: E6 J+ Z2 s
  481.         AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);* j, c0 L' \9 q. M! n
  482.         strRegsName=DEFAULT_REG_URL;9 s7 U1 z, X+ W1 N1 n( n
  483.       }
    ( b# y1 H3 [7 i" q4 t/ e& P+ ^. P/ L
  484.     }
    % |: y9 j6 a+ t+ q% c6 ]$ n( [9 }
  485.   }5 k: W4 v+ j6 C2 e9 D& y
  486.   return true;; O; [* G$ t  M9 u
  487. }
    9 G( q4 \/ t) z; j8 T
  488. 4 e4 s0 |, Q+ c# \# {9 L
  489. #include ".\ZLib\unzip.h"( C6 H4 w8 P* F: Y, h. }9 i# T
  490. extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
    . n* ^5 ^% x, B/ C. f1 ^2 j) H; n$ X; z
  491. ////////////////////////////////////////////////////////////////////////////// Q2 }4 s' C; Q' T+ o# E
  492. // CRevAppApp initialization0 E. C3 q- r7 r! v4 `, ?: l) p

  493. * i4 e" V6 G7 u% n0 S
  494. BOOL CRevAppApp::InitInstance()* _  M4 Y8 ?) \/ J3 ]1 j1 n. K
  495. {0 d9 F/ k$ r5 S5 ~
  496.   TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
    $ b- D3 O) ]5 p9 v1 ~

  497. ! c' g; R/ s4 N  b% o/ z9 F
  498.   GetModuleFileName(NULL,szPathSource,MAX_PATH);& x' @2 f: H* D2 ?
  499.   if(GetCurrentDirectory(MAX_PATH,szPath))
    : c0 G3 K7 D. S7 ?% J5 M
  500.   {
    5 M$ [. j2 R6 {  @6 L+ k
  501.     if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");
    : O0 m0 G: r7 N1 E' ^
  502.     GetPathFromFullPath(szPathTarget,szPathSource);
    ( v$ q$ D# }2 _/ @4 U9 H
  503.     if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))
    - x/ m3 u0 D+ n9 Q0 T+ P% @
  504.     {. m3 j# q# j( n9 a
  505.       strcpy(szPath,szPathTarget);
    " I* Y7 a0 `  W6 x; |
  506.       SetCurrentDirectory(szPath);
    6 T/ S1 Q) C* E: q  v+ q' W
  507.     }3 F5 H& J' w' I% L; r: q
  508.   }
    ) G/ i8 @+ o" Y/ ?6 Y& a
  509. #ifdef _DEBUG, P( J# v2 _" K, m
  510.   if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    % Y9 n5 z2 N( N! C9 @' }% Y
  511. #else
    ! e8 V' I6 y- S0 W! G! Y
  512.   if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
    - U& I* c1 `( N0 f( [1 c
  513. #endif5 X2 Z) G) H9 i1 k2 {1 O7 a
  514.   {
    - z( p7 j& {1 G1 r+ V+ A6 ~
  515.     char tempFileName[MAX_PATH];
    . d* i# `8 b3 ?" y) f. [9 `) N
  516.     strcpy(tempFileName,szPathSource);
    . j" i& I" q) q1 b6 u
  517.     tempFileName[strlen(szPathSource)-12]=0;. z7 R6 \' D4 M0 H  b( l
  518.     strcat(tempFileName,"\\$CSUpdate.exe");
    $ a" ^* S! e, u
  519.     ForceCopyFile(szPathSource,tempFileName,FALSE);- u# j/ ~* M/ R. z( n
  520.     ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);
    / b- U9 J+ t0 `8 I: O9 Q# A
  521.     return TRUE;) }- \" g: X" F/ {9 G) O$ O& b
  522.   }
    4 Z; k# O9 J1 W! w/ f# m
  523.   // Nuke 0118: Delete run.exe1 P+ p- G4 @' B3 Z% P
  524.   if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );6 k" g. l4 l1 G0 t0 R, i
  525.   if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");  e3 Z0 V$ T% j0 `; J+ ~% P
  526.   if(!ReadCfgFile("Config.ini"))8 t$ x9 d. n, |" [8 {0 y- K
  527.   {5 T! X  }) A4 |
  528.     MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);- ~% {3 n& o6 @; k0 x
  529.     return TRUE;, s: ~+ {) @& j* O: \
  530.   }/ f# d* Z; i: P4 p
  531.   HANDLE mutex;2 k4 p" U  h! b0 g1 {. u1 O) n
  532.   if(mutex=CreateMutex(NULL,FALSE,"Elysium"))" L: ]1 i- `* R1 k' ]7 H
  533.   {
    + g5 p0 O8 y+ l
  534.     if(GetLastError()==ERROR_ALREADY_EXISTS); G: f9 Y* k4 U7 e7 B
  535.     {+ r/ e, F. R* P  r" l' O
  536.       CloseHandle(mutex);
    # v( @$ g2 D1 j" h$ s
  537.       MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
    . N  L( R+ P- u- m/ l
  538.       return TRUE;
    , R8 a  L9 o. ?  K5 [# T
  539.     }7 w$ z3 C- k$ {2 c- Y  ?+ n
  540.   }  # [3 {% P; t( j- X5 V' f6 `6 @5 z
  541.   CloseHandle(mutex);5 b8 X- ^! F5 o. l5 n! ]& G3 A6 b

  542. ) ?: K4 p0 c2 y* a" k" |
  543.   if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);, Q( `6 [/ t4 R# ?; w" g- O
  544. % ^7 C1 a1 |2 L
  545.         AfxEnableControlContainer();8 \$ L" ^9 }% v* d

  546. 1 u8 X' u2 _5 ^' K
  547.   bCanUpdate=FALSE;2 s" L# @) O% y8 I
  548.   dwStartUpSteps=1;
    " r5 Q* C  E0 M
  549.   dwProgramState=AP_NOTHING;
    . ~8 z' A$ U/ _
  550. 6 A# a& O5 R0 I) X/ `( d
  551.   InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);
    * m7 ^4 o2 g5 \9 Y

  552. & x. W4 w4 A2 a. _. S8 D
  553.         // Standard initialization7 O* h4 }( v. Y/ j
  554.         // If you are not using these features and wish to reduce the size: w1 |. X& R2 @3 N8 ]
  555.         //  of your final executable, you should remove from the following0 h- I+ N* O/ |1 [+ _
  556.         //  the specific initialization routines you do not need.
    2 m/ l  n+ n# [! m; f

  557. % s# A8 [0 F+ f, z' m' M
  558. #ifdef _AFXDLL
    1 `! b. A- I7 {- q7 p* }  ^
  559.         Enable3dControls();                        // Call this when using MFC in a shared DLL7 d* d7 u3 w$ _1 G7 K$ v
  560. #else
    0 ]% b/ k. l0 h/ M# B
  561.         Enable3dControlsStatic();        // Call this when linking to MFC statically
    / G) b- F) H1 [& r7 I
  562. #endif
    : F1 M, W; p* Z! Z& d% d

  563. . C7 Q: H1 F3 f/ p4 {, [
  564.   dlg=new CRevAppDlg;
    2 C0 j  A% b$ t, S+ P/ W5 m
  565.   dlg->Create(IDD_REVAPP_DIALOG);
    6 D# \4 a5 \: [0 F3 G. ^3 o
  566.   dlg->ShowWindow(SW_SHOWNORMAL);7 t8 U! E2 {- c- Z, S  A: m
  567.   m_pMainWnd=dlg;
      [" u; n3 P6 G1 D2 N
  568.   [2 [. t$ p# @; |. ?" D
  569.   SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);/ M! j5 _# X/ t7 t$ T

  570. $ i+ Z: u! y# {2 \3 ]. E4 N: f" F3 J
  571. //  GdiplusStartupInput gdiplusStartupInput;* A+ k4 X+ |8 I$ ]7 t7 |
  572. //  ULONG_PTR gdiplusToken;, s; Z7 j$ R; E
  573. //  GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);. m: R8 z+ o+ u# O+ G2 }5 s7 m
  574. # A6 `- A! ]: B; N% k
  575. //        CRevAppDlg dlg;
    / g8 A2 i0 k$ T# U* y: O
  576. //        int nResponse = dlg.DoModal();" E" h1 v& h* \( r7 \6 r1 h
  577. //        if (nResponse == IDOK)
    % D( U9 k1 e8 `' M- U# \7 Y
  578. //        {
    # g/ C9 E* Y3 f  F" |; |
  579. //                // TODO: Place code here to handle when the dialog is
    / a; W" @1 V/ d
  580. //                //  dismissed with OK
    + ?7 C& `( F5 L6 p. n1 K$ W1 r
  581. //        }% \9 n5 T) X& A5 F9 L
  582. //        else if (nResponse == IDCANCEL)3 w. T! z9 |& V5 p  k
  583. //        {
    5 O0 o" _1 O8 _$ J& u
  584. //                // TODO: Place code here to handle when the dialog is. ]& s& G5 v8 L6 {. z
  585. //                //  dismissed with Cancel
    * n& O9 O! h  j2 K. D
  586. //        }
    ' Z7 y5 o% u5 S# n7 S6 `: b

  587. 6 J0 a/ V' g7 Y5 r) I! _; i5 D. v, D
  588.         // Since the dialog has been closed, return FALSE so that we exit the
    7 m+ E; M6 ~6 S0 G
  589.         //  application, rather than start the application's message pump.
    4 ~) S% q1 o- m$ h" K5 J
  590.         return TRUE;
    : f9 r( @* C3 ?& S/ E7 ?' [
  591. }, p' j, i4 i8 N, ?/ j- M4 Z& p" y1 p

  592. ( y' g- n: b* V, ]" T7 W
  593. char *CRevAppApp::strtok3(char *pSource,char *token)) K) K2 X' Q( @" [: U! ?
  594. {
    ! ~; U$ R# j9 {' K2 ]" Y" s- u
  595.   int i;; e, L* Z% [) t  l) x. Q
  596.   char *szRet;
    $ E( a& [  Y# W

  597. 6 K, r+ Q1 j( g
  598.   if(pSource) { itoken=0; sztoken=pSource; }  r  a9 G" o. J$ v6 ^+ K+ B
  599.   if(sztoken)+ g9 L& h& _2 t- }. N( \7 o
  600.   {! {' v/ ~# T/ t7 n# k4 W
  601.     szRet=&sztoken[itoken];/ K. ]- ~( O3 s( ~* W
  602.     while(sztoken[itoken])8 m, W: x2 u! q& Y! }
  603.     {
    ) Y$ ]7 P: l# b8 ?& i
  604.       for(i=0;i<(int)strlen(token);i++)
    # o( y" b5 r* p2 D% k# b
  605.       {; h* |. ?; X1 l" ^  a
  606.         if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])( Z) y0 y6 }; c& y7 \
  607.         {& ?; b; O: C: C6 _
  608.           sztoken[itoken++]=0;
    5 @/ O0 o( _" P& t5 R/ f
  609.           sztoken[itoken++]=0;
    + G/ B6 A9 J' B. x6 E* B* ~7 I  K
  610.           return szRet;
    , L9 d% @; ~8 T& U' t: f& L
  611.         }
    2 g# w/ b  B) S1 P
  612.       }7 u* h2 T  z5 g9 L: ^" G" }+ m6 B
  613.       itoken++;% S8 y! V8 E2 [1 _+ \- O
  614.     }( X8 R1 x4 b4 `! ]. c' U
  615.   }7 h6 r+ R; C" ?: m
  616.   return NULL;, V$ G; X& q# {; H4 t
  617. }
    7 u2 ?7 n/ z& ]# H- p' R% e# t
  618. 8 f; W6 W9 N* J+ z3 b) ?- n
  619. void ProcessProc(long Total,long Current)- I% a  U* T% p
  620. {
    9 ?8 L& o% n' l8 Z( {8 N2 \0 P
  621.         MSG msg;# X$ F, R+ o; {4 ~: J. ~
  622.         if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);6 X' H/ E5 G8 q; z
  623.   theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));9 ]3 H! D1 S/ r! z" `: P
  624.         if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))7 e" {5 X4 @/ F7 F) Z0 Y: q$ c
  625.         {
    - J7 h, t& X# Z, F7 E% \
  626.                 if(!GetMessage(&msg,NULL,0,0))
    9 w* V( Q8 P2 X, Y: s/ U% P
  627.                 {
    " i. e& C. L- }( v. l* u* f
  628.                         return;! H/ I/ a) m6 v% N* v
  629.                 }& H. o7 b, b5 ^/ y9 ^  [) |
  630.                 TranslateMessage(&msg);
    ; G7 ?+ }5 H" z% {3 W
  631.                 DispatchMessage(&msg);4 A9 H. R/ D7 }  H# P' G- k7 x
  632.         }        4 m! d) d. a  a9 O0 m6 i# Z
  633. }2 z' E/ t2 q4 e3 n
  634. , E( T# X+ b; {, @9 Y
  635. BOOL bFirstChar=TRUE;+ B) X/ r6 U4 p: O. i) m/ I4 H+ Y
  636. " W8 W" A, ]  W; ]1 _/ K
  637. BOOL CRevAppApp::OnIdle(LONG lCount)
    . E4 s% P+ q6 p8 Z( f! o
  638. {
    ' O  z$ L! h( k% l
  639.         // TODO: Add your specialized code here and/or call the base class
    % h6 e' R+ \) G9 {
  640.   switch(dwProgramState)
    2 t9 [$ A. Y4 X3 W: J
  641.   {
    $ o6 ^3 X8 K; L
  642.   case AP_NOTHING:
    % i& `7 @- ]* v3 P) p$ B
  643.     switch(dwStartUpSteps)
    + W! u( l2 ~& N6 a. n$ y7 a
  644.     {* V4 R9 [1 R" k( c! f4 Y. I- O0 Z; E
  645.     case 1:% w8 |5 b/ ]" [* W& j  _
  646.       {" y) m4 C- b( Q  L: T
  647.         int i;' [$ s$ S* \" X- \
  648.         CDC *pCDC=dlg->GetDC();# O7 I. P% t$ X9 K8 U3 I7 g
  649.         HDC hdcwnd=pCDC->m_hDC;
    - c8 v+ V+ E* g5 B+ k
  650. //        Graphics graphics(hdcwnd);! z: V; z& P6 j6 J, Y
  651. //        Bitmap bitmap(L".\\Elysium\\Back1.bmp");" R$ t  [' Y% X0 y' f
  652. //        INT iWidth=bitmap.GetWidth();
    4 i5 [, O6 l" p0 b1 M/ b
  653. //        INT iHeight=bitmap.GetHeight();5 P5 j3 \. \, ]7 i3 ]/ G- R; A
  654. //        Color color,colorTemp;
    , x, z7 \1 s2 K9 c! B
  655. //        for(INT iRow=0;iRow<iHeight;iRow++)! @0 R3 I% m# S4 m
  656. //        {
    9 d' X5 e7 _- T
  657. //          for(INT iColumn=0;iColumn<iWidth;iColumn++)) A& L- m  X( l. N9 t1 A
  658. //          {; c* }. H9 @& W1 o3 o
  659. //            bitmap.GetPixel(iColumn,iRow,&color);9 _" N; y) E' Z, d8 R
  660. //            colorTemp.SetValue(color.MakeARGB(
    . A  k  U. Q+ ]' _. L( p, U, l1 [
  661. //              (BYTE)(255*iColumn/iWidth),
    * C1 I: z. D0 U% y0 [
  662. //              color.GetRed(),
      ?; [  \0 s9 l: w: H2 f
  663. //              color.GetGreen(),
    - e, b& f8 h# G5 C5 J, c7 [: u
  664. //              color.GetBlue()));
    ' D0 u6 K6 T* c7 o
  665. //            bitmap.SetPixel(iColumn,iRow,colorTemp);
    0 j: ~0 b' r1 ?/ k
  666. //          }' H7 x/ |9 z& s) N# w; u0 {( y! F" S
  667. //        }* ]7 }  }9 D) h- S
  668. //        graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);; P3 b$ z) r1 D* T3 f. ^4 s
  669.         HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    1 C/ X. I) `0 i9 E% J4 o
  670.         HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");
    / H: G; l( C  {1 k; L# \) d9 x
  671.         HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");
    4 h3 K/ a3 z# j0 G$ u& t
  672.         for(i=0;i<240;i+=8)
    3 g. @! C+ [8 X- g
  673.         {7 K0 f5 y# P4 F# R
  674.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
      X3 p% o5 r, v. f
  675.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);% k5 {. c& z! o% Z9 k5 m/ Y# O. j
  676.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);9 `5 V+ }8 C; g4 _+ q
  677.           Sleep(33);. O, T3 e/ S4 o' ~
  678.         }  r( C, B. Y# I9 j2 r2 a$ D
  679.         Sleep(1000);
    ( `' O3 R5 F2 M) Y
  680.         for(i=240;i>0;i-=8)7 Q/ v  N1 ~, a# K" V% [1 v
  681.         {. m* m6 U! ?* K. k1 f6 X7 o
  682.           BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
    & P0 l" H# N/ p7 Q$ a; z
  683.           DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
    3 ^0 a1 ?7 E. B0 A* B* y- j
  684.           BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);
    ( C5 }0 L8 y* N  l9 k# R
  685.           Sleep(33);
    " s9 r1 [- y( l5 O8 N- n
  686.         }
    0 s  x: B1 M) }( ?$ T
  687.         SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);3 V0 V. k  Y$ p/ k, a# h# R
  688.         dlg->ReleaseDC(pCDC);
    ; K0 H( t/ H6 Z% o0 [
  689.         DeleteDC(hdctar);
    : ?- `( B& ^7 U/ e! Y* ?
  690.         DeleteDC(hdcsrc);* e7 Z# u4 ]( P( K5 e
  691.         DeleteDC(hdcorg);! E. v: p7 m  T# m; t
  692.       }
    4 J# U% r- f/ a$ y
  693. //      MessageBox(NULL,"Step 1","Elysium",MB_OK);/ @- Q( R# G% R: f  j% o( Z+ z
  694.       if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝狝竟腹 :");( ?- @: J3 D/ k# ]  b
  695.       else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新伺服器代号 :");
    5 D# O2 @8 N0 _+ N8 ?" x& z
  696.       else                                                      dlg->m_ListText.AddString("Updating the Server ID:");
    7 _7 n5 c8 V  m% n- k1 f7 L
  697.       dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    / p/ Z( a6 p& M; |7 A' X1 Z
  698.       if(!Dn.Connected())
    0 W% B0 S& E: u
  699.       {
    5 u2 U6 O- J+ r  P3 ^7 o+ M  C" `
  700.         dwTotalFiles=1;
    . `% F% b4 O1 [# y) ]" J
  701.         dwDownLoaded=0;' }. m2 p6 i9 K, o; l# T3 s; `
  702.         bSilentStep=TRUE;
    5 d4 ]/ e) j* v6 h0 D* l. K1 }
  703.         bCompressed=FALSE;
    5 m1 f8 e* y8 V
  704.         strExtLocal.Empty();
    + \$ T' x) y2 \
  705.         strFullName="readme.txt";7 K  G& m( g8 }1 q
  706.         dwProgramState=AP_CONNECT;& ^0 |9 t8 @' D& w& N5 k; ~
  707.       }
    2 t7 U6 H" I* T: y
  708.       m_pMainWnd->GetActiveWindow()->Invalidate();/ w- C$ {7 {  d; F+ l. C: h
  709.       dwStartUpSteps=2;
    ( S, q- W1 z3 K  b+ ~; Z; G, i
  710.       break;' F6 C6 k/ u/ ~
  711.     case 2:
    + }4 |9 m  q' ?7 b& Q
  712.       {
    " u1 C& X) e* y" z/ n
  713.         int iEOF;& `( w( {# ]6 {- Y6 c. N# P
  714.         FILE *fp;& x" D3 o3 K! y% K
  715.         char szString[512];0 y- h- s% `$ a
  716.         fp=fopen(".\\DownLoad\\readme.txt","r");- n+ u9 B& p7 `' e  @. e
  717.         if(fp)( n3 Z3 i( M! Y4 ^2 W1 C0 l
  718.         {
    : ~" W  S% Y) n$ [
  719.           do
    0 U+ I) B$ s  H7 O* m5 ^' q
  720.           {
      j3 C3 ^, f% O* t/ o' S( _
  721.             iEOF=fscanf(fp,"%s",szString);9 F$ a3 @# `. x/ @
  722.             if(strlen(szString))2 ~7 {' Z2 v, C
  723.             {& s3 d8 J$ {4 g/ W
  724.               if(bFirstChar)7 S! o: ~: ~* o& ^8 N
  725.               {
    5 J6 F/ `! H% B) T
  726.                 bFirstChar=FALSE;$ d2 f$ Z$ J- V3 q6 J. L
  727.                 bConnectIsBig5=FALSE;
    ! ^4 D0 c# |; i" d) u' l! H
  728.                 if(*szString=='T') bConnectIsBig5=TRUE;
    9 J. F# d* r7 e$ k, Y2 [
  729.               }3 U! t' ?6 t5 ^1 m% t8 b
  730.               if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
    ' D2 S5 f* D$ V" y+ E" R
  731.               if(!bDisplayIsBig5 &&  bConnectIsBig5) Big52GBKS(szString,strlen(szString));
    , h+ `$ S5 M+ G; N$ J) q
  732.               dlg->m_ListText.AddString(szString);
    9 r! B3 S& R1 U& U) g4 ^- Q
  733.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);4 y! D2 p% X3 s9 W$ z1 |/ h' r6 q& n
  734.               *szString=0;
    & E6 E! T2 n/ Y
  735.             }" T. w' E$ a- J& F- r) y9 o+ q) [1 o
  736.           } while(iEOF!=EOF);" e0 j0 |7 M+ ]# v) G5 c* D
  737.           fclose(fp);; @1 C6 P( L8 |$ x, D
  738.           unlink(".\\DownLoad\\readme.txt");# L) j' v) G! E. `) d
  739.           dwStartUpSteps=3;
    . G. V- O6 c* S, Y$ f. }( v
  740.         }
    ! |: O& f5 b% w/ ^
  741.       }
    7 ^$ E& C9 }! \  o; E
  742.       break;
    3 S# {0 i/ X+ I
  743.     case 3:9 a& P; ^5 k, b2 b
  744.       if(!Dn.Connected())2 k0 v  t3 B8 \9 B. `
  745.       {
    ; t7 o4 H9 C+ h3 c$ s( A" U
  746. //        MessageBox(NULL,"Step 2","Elysium",MB_OK);8 o) ^2 R9 j7 ?5 d8 u! L
  747.         dwTotalFiles=1;% [2 v3 T9 d2 v5 s' g
  748.         dwDownLoaded=0;
    3 ?: W- C7 s$ u% c* O, S
  749.         bSilentStep=TRUE;
    * x; K8 o  n  \2 C5 V
  750.         bCompressed=FALSE;) p$ ]% v" U' b  Y: h. E1 x
  751.         strExtLocal.Empty();
      u- F) }/ O' U, e/ q: F
  752.         strFullName="checkversion.txt";9 C8 @! s4 d( k! B+ H8 w
  753.         dwProgramState=AP_CONNECT;
    1 L/ y% A2 P0 ^6 Y
  754.       }* ]2 k3 m, x4 |5 j, L+ W8 ~
  755.       dwStartUpSteps=4;
    ) y' m& A% M/ N( H  J2 }
  756.       break;7 k& ]0 u0 g# L% I  l/ i5 u1 q
  757.     case 4:
    2 d, J6 N8 ]& W# J+ G. y" D
  758.       {) x" n% n: x) v, [) R( x, q2 o
  759.         FILE *fp;# i% s2 u' ?9 @, h
  760.         char szString1[128];3 u0 E6 Z* w% p8 l. T
  761.         char szString2[128];& X- E# y1 a' H9 D- e$ e  c
  762.         fp=fopen(".\\DownLoad\\checkversion.txt","r");
    " D# N9 [2 s) x; I  B
  763.         if(fp)
    + f4 T2 m1 g. U4 ]" G2 I
  764.         {
    9 G: n/ `9 _$ v/ M0 A9 x
  765.           fscanf(fp,"%s",szString1);( D- g: s# a/ `  G! M' S4 g, q) J
  766.           fclose(fp);5 A' A! x+ J! S" \
  767.           fCheckVersion=atof(szString1);/ s, ~' q& T* k4 T( H, _
  768.           fp=fopen(".\\checkversion.dat","r");
    ( ?3 i7 d$ r' H7 l2 R; \8 z; v
  769.           if(fp)% _4 S; ~3 w1 u3 h
  770.           {# w; Z2 o; ?* h8 y2 ~" f9 n# P, O. {/ I
  771.             fscanf(fp,"%s",szString2);
    7 h, M% v' t5 q$ |
  772.             fclose(fp);
    $ B5 I5 S* l( S
  773.             if(atof(szString1)!=atof(szString2))
    ! G8 y! D2 D, i3 t5 ]
  774.             {
    & q/ B# A7 O  X% c/ ~2 P3 l5 O
  775.               if(!Dn.Connected())
    ) C+ g0 a0 P* G% R7 u2 r9 k0 g+ u
  776.               {
    ! ^4 Q: o0 _# _3 G0 K( N: b
  777.                 bFirstUpdate=TRUE;
    4 @% J5 j! m  l7 w7 l) Y2 ?5 y, r
  778.                 dwTotalFiles=1;: l, i6 X  Q' _4 P0 x
  779.                 dwDownLoaded=0;1 h9 n5 }5 @" m( U
  780.                 bSilentStep=FALSE;1 w( o7 u- H% i; M7 v* d
  781.                 bCompressed=TRUE;
    9 V3 {& H+ T5 R8 ?2 `0 z6 F
  782.                 strExtLocal=".\\DownLoad\";# Q6 l$ W+ y; T- @. [1 \! @
  783.                 strFullName="update.txt";
    + L! G  M5 O- m+ h$ F  B
  784.                 dwProgramState=AP_CONNECT;
    ! }9 X8 _( l$ R& k/ p0 S
  785.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");# m% R3 {: w3 e2 o3 s9 j
  786.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");
    ! G9 R7 |8 e# Y6 Y2 I% X+ U7 l- U, c
  787.                 else                                                      dlg->m_ListText.AddString("downloading update list.....");
    3 |( q2 f) [( Z" [" X: k8 ~; y4 \

  788. # \* p5 Z- b/ l, h
  789.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    2 ]8 T! e- I% u+ J- k& ~1 z: H  S$ G/ ]
  790.                 unlink(".\\DownLoad\\checkversion.txt");
    6 x3 S8 x; b# j1 H
  791.                 if( GetFileAttributes("Wsa.zip" )!=-1)
      R5 C) C, L9 ~
  792.                 {' u& ]& g0 J( W8 m
  793.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃, 惠だ牧");  l3 g$ j2 N; X+ U0 G
  794.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");1 W! z! X' n& a6 a: s1 P6 J6 b! N
  795.                   else                                                      dlg->m_ListText.AddString("Unzip Files,        Maybe cost 10 minutes");
    $ N9 k. k: ^0 X; l5 Y6 @# U+ B
  796.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    5 a, d4 D( d7 i' H  `/ t  _
  797. 7 Q0 T5 R7 R1 }
  798.                   if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");( y7 X/ n1 y- E! F: D- ]
  799.                   else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    # L: X- j6 ]) \9 _# {
  800.                   else                                                      dlg->m_ListText.AddString("Waiting..........");
    4 K5 C4 M; }% _
  801.                                                                         dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    + ~; w* z" c: \1 ?
  802.                 }% c  E- [" p: F! y9 a4 T; \4 W
  803.                 dwStartUpSteps=5;
    1 b0 J6 h% G; A! h: }! d$ R
  804.               }$ H2 n: h% l/ E5 H' b# ]
  805.             }% f1 O- b- R- X2 K" x
  806.             else
    & _' ?8 n. r9 ~' O8 `1 N
  807.             {
    ! `: W, q9 z0 u! F: y( \  o$ ^
  808.               unlink(".\\DownLoad\\checkversion.txt");# E8 y' A$ C# N9 W) C+ z4 o8 e
  809.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");5 ]$ U' U' X# u# `" ?$ k3 E
  810.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("没有需要更新的资料.....");  p* S  Y' m& Z/ z' S
  811.               else                                                      dlg->m_ListText.AddString("no new file update.....");* N2 Z( g9 x; o  ?, {9 e7 `# q$ r
  812. 5 F# q/ G6 q/ E; r# [
  813.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);! F9 r0 [3 r7 U0 i8 F" n
  814.               dwStartUpSteps=99;+ [) Q6 r3 T& ~  B* |+ R- R
  815.               bFinishUpdated=TRUE;! M# P  b. ^5 [& Z
  816.               bCanUpdate=TRUE;% B0 d, `$ J3 ?9 X- s5 I7 w
  817.             }
    - }$ K2 o/ ]  o* e
  818.           }
    ! u% J# l- r) y7 W5 w5 Y: y4 h: i6 d
  819.           else
    * X( p/ G; r4 [9 V- j
  820.           {* @/ C1 V1 U0 z3 ~
  821.             if(!Dn.Connected())) E7 E" }8 T& |7 N4 p
  822.             {
    . E# [. _8 C1 @5 \! c1 C- S
  823.               bFirstUpdate=TRUE;
    # Z8 X9 M; p8 @: x
  824.               dwTotalFiles=1;8 u8 ?1 M! n0 ?# e  [8 W/ l
  825.               dwDownLoaded=0;
    ' q+ T: d, g% X% {/ n5 I
  826.               bSilentStep=FALSE;
    ) c* k6 j; D9 M( d! M' r
  827.               bCompressed=TRUE;7 j3 ?, z8 B8 P7 I
  828.               strExtLocal=".\\DownLoad\";8 ?5 ]! I. W7 U3 K3 z3 }1 I* c
  829.               strFullName="update.txt";/ |8 r6 [; H2 x. f! R5 P! ~
  830.               dwProgramState=AP_CONNECT;5 L+ |9 y) L: f; ]
  831.               if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("穝更い, 叫祔.....");4 a$ x, q9 t6 {5 u! ]- Q9 p2 ]; T
  832.               else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");4 Z& w3 V2 r3 f
  833.               else                                                      dlg->m_ListText.AddString("downloading update list.....");5 t) `( P5 ]6 J, a  c
  834.               dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);6 U1 k/ g0 ]1 S5 e3 v
  835.               unlink(".\\DownLoad\\checkversion.txt");8 y5 r- l3 A7 B
  836.               if(GetFileAttributes("Wsa.zip" )!=-1)# m% c! f: f$ {- R6 B* y$ o5 x
  837.               {' \7 I9 z0 u$ b
  838.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("郎秆溃......");
    . i$ z+ D& }  W' e
  839.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("档案解压.....");  ?* X* P! R9 n" S) X
  840.                 else                                                      dlg->m_ListText.AddString("Unzip Files.....");
    ; k8 ?# Y" p7 z1 ~( E2 [  y( ~
  841.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    8 |* X, u9 x: U8 d! x- D1 q. D
  842.                
    " t, V: A- ]% q$ Z+ Q
  843.                 if     ( m_iLanguage == TRADITIONAL_CHINESE )             dlg->m_ListText.AddString("叫瑻み单..........");/ F: w& y5 i7 d+ ^3 a# J  n: L
  844.                 else if( m_iLanguage == SIMPLIFY_CHINESE )                dlg->m_ListText.AddString("请耐心等待..........");
    3 Z! _, z  Z6 I$ X5 k4 @$ g
  845.                 else                                                      dlg->m_ListText.AddString("Waiting..........");. V  h6 T+ Z8 ^; p2 j" h# H
  846.                 dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
    3 Q0 a# p: j. I# M# O8 k7 ?( |9 u
  847.               }- _. l8 ?" ]2 p1 n+ ^- H* o, p
  848.               dwStartUpSteps=5;0 p- U8 s7 m. u  l& p; b
  849.             }9 M8 ?6 X6 X$ h* N* C% y* m
  850.           }( z* O& }5 q1 u& B
  851.         }: k. s9 ?% K; [2 G' K/ r2 E: ?
  852.         else% O/ {4 {% B+ B. p6 J, j
  853.         {1 O. ?- d2 g0 z
  854.           dwStartUpSteps=3;
    $ c1 ?) w8 E) F3 |2 ^9 `
  855.         }. p0 q0 V& P; g3 Q6 W+ y3 Q
  856.       }1 Z/ t- y9 |) w% }) S+ v
  857.       break;/ ]! e6 |/ t  n- z
  858.     case 5:( d( P6 n' v/ O8 C
  859.       {6 c$ e4 H( x$ }4 ]* b) m! F3 M
  860.         if(GetFileAttributes("Wsa.zip" )!=-1)1 t9 [% Z. a5 Y* y4 c4 ]
  861.         {8 N, @! l- F# t1 T- {2 V; Q  Q
  862.           int opt_overwrite=1;
    ( k/ ~; O& K* \( F( j
  863.           int opt_do_extract_withoutpath=0;& ~% ?  S. p  W7 ]* r8 b, |
  864.           unzFile uf=NULL;
    * h' h" ^) v  g9 P6 t! u  J1 X

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

7 _) {& I0 k% W7 ~" s

評分

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