" D) s g+ Y1 j- d" K( ?0 l2 u; o- / RevApp.cpp : Defines the class behaviors for the application.
# _! F, t* ?+ I0 W* K - //$ O( M3 _3 h8 P. F5 i6 V T
7 f+ Z& q! l# T! \0 n- #include "stdafx.h"
; N& q7 I }8 b* O4 ?* E
7 ]2 j; t4 I( o# L# U, I- //#define UNICODE0 ]! n# ?9 _# D# v: v% R
- //#include <gdiplus.h>' {, t2 d: T! ?0 u1 i* {3 m
- //using namespace Gdiplus;
" d* B* c; R0 c
3 s# o, \6 V$ T' y- #include "RevApp.h"
9 W0 r2 Z' {, z& v* J* q - #include "RevAppDlg.h": L) j% F* n; r, \/ h3 d: X
- ! t. C K% t0 g( O
- #pragma warning(disable:4786)0 {& t3 [4 V% @+ Q0 n% k
- #include <map>
0 X6 W3 l1 W1 l0 m9 E5 j, T - #include <list>8 }$ S& q1 z3 k9 G# U% V, @) B$ ?
- #include <direct.h>% A/ r: ?" V; P9 k! d; Q3 x
( w$ W+ w% V* ]' `8 [9 P7 M- #ifdef _DEBUG
; j" `' P# a/ n* E* ?3 E7 b7 i( X1 R - #define new DEBUG_NEW5 x2 e4 `) |' }- ^2 b1 z* u; ?
- #undef THIS_FILE; D7 D: Y1 K# Q% ~6 r& P, l
- static char THIS_FILE[] = __FILE__;% l( |8 M! Y- _# t
- #endif
- n D4 a: R9 Z, ]4 h. X - #include "SkinResDef.h"6 I9 z) |' o* K3 a( i! B) X5 F
- #include "ChangeBG.h"3 I7 S8 Q8 N* i1 T" ~. {+ ]' U9 [
- #include "AFXINET.H"
+ y% h0 {+ h6 p4 I# _7 F s
) Y5 k6 ?% e, @4 f2 E( F$ |( ?) D- #define TRADITIONAL_CHINESE 0- u# ? q8 S$ M! z1 s. X6 p, I
- #define SIMPLIFY_CHINESE 1
& {! P$ z7 h- H- ~4 J( Y - #define ENGLISH 2
" }/ l5 |5 C% R - int m_iLanguage = ENGLISH;
" F. {4 {2 e, ]/ d - /////////////////////////////////////////////////////////////////////////////( L( B4 A" j9 j5 H& O
- // CRevAppApp
/ `- h9 h, O) `6 q) f0 F) j! Q1 O
3 |: U+ ~' }5 q A4 S1 j. T- BEGIN_MESSAGE_MAP(CRevAppApp, CWinApp)/ V# |% e- Z# ^9 O9 A2 z" O$ z
- //{{AFX_MSG_MAP(CRevAppApp)
7 X7 v$ P& X% v* t' p+ Y7 f - // NOTE - the ClassWizard will add and remove mapping macros here.
, V/ K7 s0 o2 s- q0 I- N- c6 { - // DO NOT EDIT what you see in these blocks of generated code!
) G t6 `" \+ Z$ s, X# Y. B7 @ - //}}AFX_MSG
3 j. x: G+ X1 {3 x0 {+ L& `; s( ] - //ON_COMMAND(ID_HELP, CWinApp::OnHelp), ], _" ?" [( c) Z1 W b
- END_MESSAGE_MAP()
: [- L v. ~9 t( h
6 [. G* N) `6 q. E# Z% ?- /////////////////////////////////////////////////////////////////////////////
% a9 w/ ~/ \" l; C9 s0 V - // CRevAppApp construction
& C& {# V: R/ G( n0 I - + R! A# l* m( {7 U
- CRevAppApp::CRevAppApp()
2 ^# K8 T; O+ A/ K* ~, d ~5 d - {* r" z" q% N* a: R, W
- // TODO: add construction code here,
) ~4 M: ~# N, ]4 }6 Z5 y - // Place all significant initialization in InitInstance9 h: \ x. Y7 Y2 H+ u& P) k" K/ `
- bDisplayIsBig5=FALSE;
2 @9 F% r/ V* G# o - bRestartUpdater=FALSE;2 q! m) f" N m& z. \
- bFinishUpdated=FALSE;
2 i, z. W) J: J+ z - if(GetACP()==950) bDisplayIsBig5=TRUE;
9 Q8 L* g8 _5 a# P0 e. }0 S' p! u - InitChangeDataBig52GBKS();
; B8 d2 e ?- _9 n - InitChangeDataGBKS2Big5();
4 m% X- o( U) P- B5 F - //0 [; h4 I& E6 l* _! v& \% x# J
- bClickRunExe = FALSE;2 Z# V- |. |. y* t
- //- A2 o! D6 r: x8 [- A9 \; T, g
- }2 L/ _% d1 q# d. @3 m( }" }) S( L$ u
- 0 \4 R; x5 t+ A& p
- CRevAppApp::~CRevAppApp()
( X' L% N# X4 }3 H - {4 b9 ]1 N# L, W3 U _
- // TODO: add construction code here,) [" g. H2 R) E2 J
- // Place all significant initialization in InitInstance
# Q' \, L+ u- n/ ^2 g% }/ W& k" G - EndChangeData();
" h, I. C) I2 {- a# D( t - }
X$ N4 Z9 {6 ]: C# G7 f
( i' Y! d/ [7 ~4 `- /////////////////////////////////////////////////////////////////////////////
% a9 A7 }$ }% Q$ o. I& X1 F - // The one and only CRevAppApp object+ j) R1 @$ E/ ?7 `
- ' K6 ^5 E+ h$ }# j% K
- CRevAppApp theApp;8 B( x0 t* x! Z: w7 A' q P
- ; ^$ |+ Y+ q- x* K2 C
- char *CRevAppApp::ReadFileNames(FILE *fp,char *szFileName)& @1 L, U4 ?* x
- {+ y3 x9 X; E) z/ ?# G2 F
- int iEOF=0;" r) l, r+ ~: E' D
- char szTempName[MAX_PATH];
* `4 ?2 w' H4 C" v- n4 R8 U" p - *szFileName=0;4 V; [# E* v5 | d( x
- iEOF=fscanf(fp,"%s",szTempName);2 F6 m8 t, P* b" f1 X W1 h" R
- if(strlen(szTempName)>=1&&szTempName[0]=='(')0 ~6 \5 M8 \3 a1 {
- {
" ~' I7 [9 P4 v( R - strcpy(szFileName,&szTempName[1]);% G" O% W" _, U$ D8 K
- while(!strchr(szTempName,')')&&iEOF!=EOF)' X8 j$ M, Z& U% V
- {
. s) K3 L- K$ S u* f& r - iEOF=fscanf(fp,"%s",szTempName);
& x+ }) s; j2 u0 r3 { - strcat(szFileName," ");
5 M2 Q+ ] m9 t( V( ? - strcat(szFileName,szTempName);
0 b( X" r% f \* O - }9 r% u! S+ p5 O$ D# x
- if(strlen(szFileName)>=1)) X0 a% |" g+ j) G0 Y( g* o+ I/ m& k
- {: y- ?$ C$ ]6 p* D$ h0 U
- szFileName[strlen(szFileName)-1]=0;. `$ I( V9 g" \# y/ H9 F) z' h
- }
. e& r" K$ D8 V! G - }7 K/ M4 F9 d# w$ }* Q+ p2 P* f3 D4 C3 ~ P
- return szFileName;
; {0 V i$ q6 V1 o, `* Y* ^ - }
5 _ S/ n! b. }. r2 p3 s - ) {5 e6 x+ \; _
- bool CRevAppApp::LoadLogFile(char *filename,std::list<CString>& UpdateList,std::map<CString,LPUPDATEFILE>& UpdateFile)( c1 G9 k- a* R+ D4 q
- {
! ~& e+ H9 J" m3 q% `! a0 g; F - FILE *fp;
5 t- s. A7 O. | O4 e8 q. \4 S - char *key=NULL;3 d* r6 @# h3 k9 A2 u. K
- char version[MAX_PATH];/ Q# o8 N6 T. L' r+ r
- LPUPDATEFILE file,olds;0 m7 S' v+ h) b+ B0 Z! j
- std::map<CString,LPUPDATEFILE>::iterator p;2 ]: x! S$ k+ u0 s( ~
- % I, ?5 F' ]9 R, \! z# H
- UpdateList.clear();; f% g! }& `7 w6 H
- UpdateFile.clear();
v& @3 _8 Z0 b0 f* q6 w& ^0 l - if(GetFileAttributes(filename)==-1) return false;
# b' J- ~- _ b8 i - if(!(fp=fopen(filename,"r"))) return false;/ Z9 @# i3 w. k& s" p; G, S6 D
- fscanf(fp,"%s",version);
. R. ^! ?3 D' j; U - if(stricmp(version,"Bloodyf")) { fclose(fp); return false; }
. T2 |+ R4 h3 D8 r9 o& H- A - while(fscanf(fp,"%s",version)!=EOF)# h# V6 b' Z/ u* d1 M; I9 s0 A
- {
; b2 ?/ V# i$ v4 s( K - file=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
/ z+ Y9 A; ] ^( ?2 Z, W! D - fscanf(fp,"%s",file->path);
# _' y( M7 R: L" t% Q4 W - ReadFileNames(fp,file->file);
6 G0 K# h- m' ?7 n - strcpy(file->full,".");1 W, |- k9 a) j% K: s |
- strcat(file->full,file->path);
6 B3 m8 r4 x8 x6 k3 r* `, I - strcat(file->full,file->file);
+ L2 A! ~; a* Y \' Q - if((p=UpdateFile.find(file->full))==UpdateFile.end())- G8 w! {% @ c0 n# V8 t, _& K
- {- J8 o4 j ^- N1 z# x. |: S: `
- file->vers=(float)atof(version);
" Z) P1 l# B' I" i+ x% a - UpdateList.push_back(file->full);! _+ R) `! V1 F* y+ h& W# O3 P4 t) C
- UpdateFile.insert(std::map<CString,LPUPDATEFILE>::value_type(file->full,file));5 N* C6 `; c. Z/ c) v9 g
- }
8 ]. L. q, m. Y% G - else! g1 J- h7 q( `# O/ g: S J- O4 G' x
- {
8 w1 N( y. }6 x; d! k& f/ c - olds=(*p).second;
; p8 v) M4 Y8 t - if(olds->vers<(float)atof(version))- p* j$ C9 Y# k9 V
- {
- V6 v* F b. q5 I1 [( w. n4 q; ^8 G; N - olds->vers=(float)atof(version);
! T* z( m- k) P# J4 w - }
) L/ n# j2 |: |3 E - free(file);
. M( l0 v3 U- Z! u9 F4 o- M - }. T! a" f5 [! Q4 F" S9 Y5 A7 b
- }' r- x4 y Z6 {8 ]& k( x. A+ w* I% o
- fclose(fp);
$ i, r' ~3 A8 A - return true;
7 T. T4 f2 j7 g) A5 d. W. u - }
; k4 L/ N$ ^# l" P7 c, @6 ^ - " P% g' u# y, j7 n/ T. h) t4 I: @ x
- DWORD CRevAppApp::GetPathFromFullPath(TCHAR *szPath,TCHAR *szFullPath)
+ t) `# } b7 J3 e - {
' h6 R% E3 S: W6 D6 Z5 ? - TCHAR szFull[MAX_PATH];, |1 [, W" |* N
- TCHAR *token,*inter;0 i) c* _* D( M2 i7 a s& O
- *szPath=0;4 W6 y0 J4 U! V$ O& y0 `6 `
- strcpy(szFull,szFullPath);. t3 f" L% k5 u7 I
- token=strtok(szFull,"\\/");! _, o" |. }* a+ R0 M: C
- inter=token;
/ p) l/ e6 @; N2 `5 A) H - while(token=strtok(NULL,"\\/"))6 D+ K( G& P- r1 P
- {
+ n8 p7 @9 a8 M" B% s. v - strcat(szPath,inter);% S) b9 n H* y
- strcat(szPath,"\");' e) k2 B$ f) R K! Y' z7 X9 g# i ~
- inter=token;4 H5 I% K5 Y+ Q1 w
- }# B v2 K( @* u9 D& V* O9 D+ R
- return strlen(szPath);
* S( n2 w# G! ^$ m/ W- O( n8 o - }
7 c/ J; |& W6 R! j6 `4 ^
4 M1 A$ B: _3 ~- void CRevAppApp::ForceCopyFile(LPCTSTR Source,LPCTSTR Target,BOOL Erase)
. {4 {; Z* P9 V. }8 O - {
: ~- \0 s( L1 ?/ x - DWORD attrib=GetFileAttributes(Target);
; T. k! n( P. {; g - if(attrib!=-1)9 S# x# e) F& p" ^
- {% \9 d; q6 [) a1 g0 ^* e
- if((attrib&FILE_ATTRIBUTE_HIDDEN)||(attrib&FILE_ATTRIBUTE_READONLY))! C2 n( u0 O% F- A. ?$ Z! O( c
- {2 Y# k' i/ s2 Q; k* e
- attrib&=~(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_READONLY);! z7 e. S2 g& z6 |7 z5 r! W. I
- SetFileAttributes(Target,attrib);! z' _& m8 L6 d# e
- }2 w8 w1 R5 Y: ^* K$ h6 [8 W
- }
6 l1 j9 w; ^( }. t - CopyFile(Source,Target,Erase);
" P. N9 H) g$ P" M - }3 h4 ]0 V; M' z5 V- N P, q- v! C
`) D( P- B/ g- void CRevAppApp::Fprintf(char *FileName,char *message, ...)
2 a2 D/ w6 v0 _ - {6 o9 D2 \6 H8 [, G' F+ g
- FILE *fp;
4 ~' [6 O4 P5 s* u9 X1 d0 E8 E4 e - char szBuffer[8192];
5 S2 K5 `9 [8 o, ?; q; O1 h- V - va_list argptr;. ~: A3 Q4 y; ]" u
- 9 c5 G! c& @! V+ m3 _+ j
- va_start(argptr,message);7 {5 r" y n H7 Y# u
- vsprintf(szBuffer,message,argptr);
# f' s) ^( q2 f' e) x. ~ - va_end(argptr);
/ S4 j" ]/ @. o; z# P% v/ E - fp=fopen(FileName,"a");. d5 ^8 L5 Y& n; D- S
- if(fp)
) X/ f3 s; I" F2 t( Y - {* G3 c) [9 |$ P) O7 @1 v
- fprintf(fp,szBuffer);) ]: i, g' Q( _; ^
- fclose(fp);4 a: J& o# C* l, F w
- _flushall();* m" d/ f* {, y
- }
9 W6 p' }6 ~* U8 ^( l; G5 O - }/ j4 R3 T7 r4 S8 T" y
- " \. e; k, ?2 F1 i- v
- BOOL CRevAppApp::Fclearf(char *FileName)
9 C2 V9 k0 w( f7 e: w - {% c1 N: g5 e1 X4 y5 z
- FILE *fp;& J8 f" z0 I8 A2 A
- DWORD attrib;1 L j2 Q! \- X b4 T* N9 [
- attrib=GetFileAttributes(FileName);
9 e& ^, g% |* v9 `/ ?1 w - if(attrib!=-1)) }9 D6 C Q9 r6 l. D. q3 l
- { g7 k+ O7 p' g# Z6 f* U. ]0 [
- attrib&=~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN);
" X; d' e: I! v; w - if(!SetFileAttributes(FileName,attrib))
2 j1 V" z p6 c2 n0 Q - {# m) r$ j/ y- Y& A7 d5 @4 z
- return FALSE;1 k4 R( A. ~& p& Z+ U
- } \ q. y; T& Q k, a5 M4 [
- }/ p& j/ E5 G. C
- fp=fopen(FileName,"wb");, h" c' O0 P; K$ f: Q
- if(fp)
7 \+ N. T; S" o, A1 v9 `' [: ~ - {
! O4 D! n, L- f7 v - fclose(fp);* }4 X9 A9 |/ |: E, i3 g! K
- }. u- t [5 o; ^7 O! R! m
- return TRUE;
' J* a1 c$ F) y* i1 I2 A - }
: F9 |$ s1 H' K+ O/ q - . R& w) j5 {+ f
- BOOL CRevAppApp::UpdateLocalVersion(void)4 D: {+ x6 N$ s. s8 I9 L
- {# q3 [& z0 s7 l% m8 c) _
- char filename[MAX_PATH];
1 U4 ?% i4 P- l" K5 ^9 g - LPUPDATEFILE file,olds;4 G7 V; r' y0 J- r; H. q
- std::map<int,CString>::iterator i;
O: j! Z$ _4 E! C - std::map<CString,LPUPDATEFILE>::iterator p;( ~! `) W. T F5 r' b/ c
- std::list<CString>::iterator l;
2 W+ ] M- B3 U; c5 T - 4 p% b6 Y% b& i+ V* M3 L/ \ {" I3 _
- if(bFirstUpdate)* ~ Q0 F) e3 o1 G
- {
- q. ~! k1 t' P9 X! m. I# R* }0 X - dwCurrFile=0;1 _ P; _1 k: X
- bFirstUpdate=FALSE;
T0 r: @- v* M! s. a; @ - if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())' `' K! u! [3 f% Z- O7 H
- {
& D! \* O" u5 z# J6 I b - dwTotalFiles=UpdateLocal.size();
* m, P5 [: E9 T - dwDownLoaded=0;
: f* S/ s9 T3 a2 I - bSilentStep=FALSE;: D- h" P4 p0 F# F W
- bCompressed=TRUE;8 G- w- A( X# {! w; j2 J
- strExtLocal.Empty();. R1 k" q) w* o' R( Y P
- strFullName=(*i).second;9 |1 {) k6 r) g
- dwProgramState=AP_CONNECT;" G9 I" W, r6 o
- return TRUE;6 v% S7 a" D* K1 B$ C
- }& `! b7 T8 x5 p' Q6 v% ~
- }
* u v% g+ R! W) u7 K2 A8 n# M1 U - else if(bRestartUpdater==FALSE)
2 I( `6 W$ Y, j+ Z) V% B+ m3 R7 m - {
% Y& L$ F- Y& w) z: F- |9 J; o - if((p=UpdateFile2.find(strFullName))!=UpdateFile2.end())3 s5 H/ k( N. N2 D! }
- {
! {, y- }; C) W% j# y6 u7 V - file=(*p).second;
5 N' K- L4 l% U* i0 G( Z0 e% U) K - if((p=UpdateFile1.find(strFullName))!=UpdateFile1.end())4 j) k |' `5 W- W6 g
- {6 ?: w1 X* X& A& |/ F8 ]; |
- olds=(*p).second;$ i8 W6 t' d/ N! {1 v8 O
- olds->vers=file->vers;
" x! a& n* a( s& B1 ^& | - }! I' J& w0 P+ X0 j
- else2 I7 z. } m) @- N3 ^/ `- T
- {
7 P9 i) [; f/ J) p, S- Z2 u" y* N' o - olds=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
f1 Y* e6 F5 X* m - memcpy(olds,file,sizeof(UPDATEFILE));6 f ~3 V& X1 _& s. V/ j# h
- UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(olds->full,olds));
6 k! u& E T: _" r( u. `) h( F8 x - }& A. }$ h9 [+ L/ o V% b+ ?
- if(GetFileAttributes(".\\update.tmp")==-1) Fprintf(".\\update.tmp","Bloodyf\n");4 ]5 Q0 L: K( ~
- sprintf(filename,"(%s)",file->file);/ v/ r- T Z: N. K: ?# B
- Fprintf(".\\update.tmp","%4.3f %-48s %-24s\n",file->vers,file->path,filename);9 W* Z8 y) S+ B4 g
- if(!stricmp(file->file,"csupdate.exe")) { bRestartUpdater=TRUE; return FALSE; }. J% X$ d3 X& D) ?6 A6 _/ A
- }5 G8 j5 N8 F7 Z9 M! Z! j% R
- dwCurrFile++;; l+ J3 H( ^; i& g% P
- if((i=UpdateLocal.find(dwCurrFile))!=UpdateLocal.end())3 M4 \- l& m( C0 }0 ^' m
- {5 G/ t' D# \* B2 ~1 l
- bSilentStep=FALSE;- T" k; y% O* T
- bCompressed=TRUE;, ~2 g$ H: I" g! `& O( m
- strExtLocal.Empty();: ~/ u% E( s0 w f% K
- strFullName=(*i).second;' t- r8 L2 n! }: b7 i Q
- dwProgramState=AP_CONNECT;. @+ a, @+ X2 ^; o! `# v) G. U6 ^
- return TRUE;7 I F+ H- R6 f+ [2 c- l
- }/ L1 }& x; R3 ~; S
- if(!bRestartUpdater)1 h/ h$ h( Z! J7 |9 q: o
- {' u1 A* m1 t; i
- int iCurrSize,iFileSize;# ]$ }" ]5 e( S, ~
- iCurrSize=0;
+ y6 D$ f! J& t y( M - iFileSize=UpdateList2.size();
9 h H w! _/ a; x - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝戈い.....");
3 x. c. B$ j+ a. S - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新资料列表回存中.....");7 y, J! ^/ Q2 @' ?/ M
- else dlg->m_ListText.AddString("saving updated files.....");
" `) E: y* E( U" @% \ - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
" J# b' U6 Q. Y! ^( s. o. u/ k; U - Fclearf(".\\update.dat");* h% |. R6 A" C' I. h% g; Q# H0 e: z
- Fprintf(".\\update.dat","Bloodyf\n");
6 \8 _" v) `0 q! |6 b+ t - for(l=UpdateList2.begin();l!=UpdateList2.end();l++)
3 g# b: M, p7 N: m - {6 D( |. T3 e# q$ J$ u
- if((p=UpdateFile1.find((*l)))!=UpdateFile1.end())
7 q! N8 [5 j$ C; ~. |7 F! G - {
' ]" c+ t+ \. n& N& e9 G! k% ] - file=(*p).second;2 W# {3 F$ M; s* O' ~# h7 ?) @0 F1 S* `
- sprintf(filename,"(%s)",file->file);
. W% g- w/ @$ H - Fprintf(".\\update.dat","%4.3f %-48s %-24s\n",file->vers,file->path,filename);; \+ \: p, Z+ P1 x4 Y' Z& Z: C4 P
- iCurrSize++;
( C1 k9 a0 c, V K& b# J - dlg->m_Process2.SetPos(100*iCurrSize/(iFileSize<=0?1:iFileSize));+ I% @4 h! S' f6 o, c5 n7 z
- }
8 z; X# A) ?5 p; Y - }
9 Y2 k! u& n0 N* _7 u t/ O - unlink(".\\update.txt");9 {8 I# y- a4 ?& p' _4 ?7 f( D
- unlink(".\\update.tmp");& e3 S3 L1 u+ h: s7 V0 _
- Fclearf(".\\checkversion.dat");
5 p/ ]* ?0 D$ Z X - Fprintf(".\\checkversion.dat","%4.3f",fCheckVersion);. D) z! i9 f( G6 ?3 y) K/ K, @% `% q
- if(UpdateLocal.size())( x; W5 ]2 A9 b0 }- T6 q! r
- {
6 e+ t6 \9 R+ O( f' T+ z& S - UpdateLocal.clear();
# M5 S' p4 J! |1 P) H& G - }: j3 Z, X% f [ ^# e, m; v" R
- if(UpdateFile3.size())4 H+ p4 c" E9 I0 j* T3 x% f
- {4 a$ I6 d4 Z1 j
- for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)5 v: _4 V/ s1 U" U) K
- {* h+ g, b6 d) V# _7 r
- file=(*p).second;
0 l+ r5 }8 {9 [+ d! ~ w - free(file); [- ^/ H, N0 C6 |7 {
- }
) e0 B6 v: Z# ? - UpdateFile3.clear();. Y: o* B* J& l
- UpdateList3.clear();+ D1 ^& B+ J5 g8 w
- }5 m) C/ m8 t, ^
- if(UpdateFile2.size()), ]/ L2 z/ ]' }; h
- {
# j$ a6 E. }% O8 J - for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)! a$ |2 r3 D. K$ G- F4 R7 A
- {
. @! j0 j2 K% ~- S* {. P; o0 u7 a4 r- ? - file=(*p).second;7 M5 K# x6 B- ^' p7 V7 ?& m& H
- free(file);: L" J6 `) P5 ?8 k+ ]
- }
* y9 t, S2 ~: Q m/ j - UpdateFile2.clear();* A5 R" H) M4 z# S
- UpdateList2.clear();
' ^4 d/ V3 Q# C4 i: `! ] - }/ L0 N, d/ i2 O0 y% h0 w4 A7 P0 u% x/ u
- if(UpdateFile1.size())! i s. j3 t, {$ ?( ?
- {
( r3 ^5 x) R9 V" C - for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)! ^# W' q" ]# `8 a6 c4 a
- {
6 b" _% u: M4 r5 l, [' [' ~ z - file=(*p).second;/ [1 m2 z+ h8 R4 K" J; F* Z+ c
- free(file);
, n+ t* K7 O' q7 }$ w+ i' H0 u - }
' ^: J0 I0 |4 Q+ l' S# y - UpdateFile1.clear();8 R* u) d- f n7 J" x4 t
- UpdateList1.clear();
- b. B P8 p1 Q4 z/ P) [ - }
9 T& l$ G5 D1 f5 s. v- W - dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));
# `: N. C: {/ Q I2 H - }# @3 H1 ~* U m) {6 f6 E3 t9 z" p
- }7 L- B. ~; A" @ e. [
- return FALSE;
2 w+ W* E) y* S6 y8 I9 r - }+ \1 P. K( R& @5 r9 U" K
_+ R! _+ a/ J% T- void CRevAppApp::ClearAll(void)0 x$ G( n, } k, x: _
- {# a5 S: H: [3 c7 J: d
- LPUPDATEFILE file;! h0 t7 l( e! `- J8 e
- std::map<CString,LPUPDATEFILE>::iterator p;
, t* z, ]' ^9 {4 D - 0 f1 `3 [3 \" H- d# e P* y2 }% h6 _
- if(UpdateLocal.size())
4 n) b- \! l% _. Z) G2 y - {0 {) l' [4 N4 z5 c4 O5 v
- UpdateLocal.clear();
9 u! `5 @, @0 C1 E E - }
! u2 ~- I. |9 i/ U( P9 z h! r+ V - if(UpdateFile3.size()); {8 s- y3 M& {, a
- {1 h2 ~7 c, _; ]+ s8 j- s3 `
- for(p=UpdateFile3.begin();p!=UpdateFile3.end();p++)
: |" ?1 [' [5 K# }7 l! N# n - {: v3 a r" g) v7 q7 T- H) ?
- file=(*p).second;
0 L5 h. `6 _5 {# b; @5 D& X - free(file);
+ [8 k! L( l3 ^0 c - }- K/ F" U! P: N' }
- UpdateFile3.clear();
- ?1 Z# _. ~' a9 ?4 l - UpdateList3.clear();
. r+ w" D4 w8 i$ d5 f1 a$ H9 `7 c - }
1 w# ]+ |5 e i8 I t X+ P! k - if(UpdateFile2.size())& P' S- {9 _) x0 G
- {
7 K2 `; |+ `. P2 D - for(p=UpdateFile2.begin();p!=UpdateFile2.end();p++)
T, S# ~. E, n) d - {
/ i. {; ^ [: V8 U. \4 i - file=(*p).second;; z+ n! b- g, @% Y& V& x# b
- free(file);! Y( _3 ]% m1 h6 i% e& O
- }
' H: K4 a" f4 Y' _/ Z- a8 q - UpdateFile2.clear();. [( Q3 e* [* ?+ s
- UpdateList2.clear();
8 k; r2 I& k n) l) _0 J0 y, F2 j; v - }$ J8 c5 G% v {3 k: G, J+ H* ~
- if(UpdateFile1.size())0 N2 o. L! Q' a! {. E
- {& x2 N1 [/ N$ w4 u$ D
- for(p=UpdateFile1.begin();p!=UpdateFile1.end();p++)
4 G4 ?# x! b x( v) p/ j, B8 v - {
0 k& _# Q, b' n% D) S+ ~2 i - file=(*p).second;9 ~/ ~0 }1 @( W* A' \4 @
- free(file);
, p$ o$ G" B$ Y+ I% P8 J+ B) ? - }
/ S: C3 R% ^6 \9 |# ^! p' B" p0 | - UpdateFile1.clear();
3 ~2 e/ O5 p! T4 g2 |3 J/ w; {2 T" d - UpdateList1.clear();
$ Q8 A! R3 ]6 n/ C# l0 o8 G) X" q - }
4 g5 ~, B; g+ c- A* H0 @ - }
! E3 M8 _) ?- ]# ^ -
6 Z* a/ v/ [7 d; r - BOOL CRevAppApp::CheckLocalVersion(void)
% b4 H5 K3 w% u: ?/ {4 f& [0 y - {
% G) D& C" t: V3 o( X- f7 v - int c;0 t* |( \( k$ O
- LPUPDATEFILE file1,file2;
5 ]- D1 Z" V0 [ U - std::map<CString,LPUPDATEFILE>::iterator i,p;. f) q6 h1 ^, O; B
- std::list<CString>::iterator l;
/ ~# f* U" D6 s2 [* v
4 t! \; v. `* ^+ @% \( L/ D- UpdateLocal.clear();, X3 H7 J9 N i6 D" f9 _
- LoadLogFile(".\\update.dat",UpdateList1,UpdateFile1);
5 t* I p8 A# T - LoadLogFile(".\\DownLoad\\update.txt",UpdateList2,UpdateFile2);7 s6 ?( U' D) r" H/ p
- LoadLogFile(".\\update.tmp",UpdateList3,UpdateFile3);, h; X& M/ a+ K1 l9 I, @9 X
- // if(!UpdateList1.size()) MessageBox(GetActiveWindow(),"Cannot read update.dat file !","Error",MB_OK|MB_ICONERROR);# o" t x4 y# ?. b( V* l
- if(UpdateFile3.size())
1 n3 p# ~2 }* M! u o9 t - {
: q0 W5 Y3 e% ^+ Z. d2 H9 Q/ ? - for(i=UpdateFile3.begin();i!=UpdateFile3.end();i++)/ I# d. ?: {$ z5 k6 x7 Q( _
- {: p- w* w s; F# j; Y; t- d$ u. W
- file2=(LPUPDATEFILE)(*i).second; Q+ ?' l4 s' B1 B a( A5 ^
- if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
8 u4 Z$ G j1 {& k% \9 F - {
% k: c: x2 H4 \# P - file1=(LPUPDATEFILE)(*p).second;0 C4 T* s' C9 x) S# F2 O
- file1->vers=file2->vers;5 w7 b2 C- ~/ r, P% X+ m
- }
% ~( `3 e. m3 Q& C7 F8 S - else. N8 b, x2 r4 }% y2 n* S& X; a
- {2 z3 ~+ F% E( }6 p; r4 Y: Y
- file1=(LPUPDATEFILE)malloc(sizeof(UPDATEFILE));
+ d. L- C$ ~8 o8 Y. o; m - memcpy(file1,file2,sizeof(UPDATEFILE));
3 o3 J+ c' X" G6 u5 o - UpdateFile1.insert(std::map<CString,LPUPDATEFILE>::value_type(file1->full,file1));
6 B9 `( [! J( h3 i) ?: K/ p8 E - }
' h/ i# p! w3 b - }7 ^' o9 c- I: b' D- p; N7 B
- }# n9 Q& V+ m; u% l( `" K
- for(c=0,l=UpdateList2.begin();l!=UpdateList2.end();l++)
) n% H& a( N4 B: y8 ]/ r0 m - {
% M+ R, w" y9 D3 M5 i$ G, d - if((i=UpdateFile2.find(*l))!=UpdateFile2.end())3 C$ u2 o6 ~" h8 _0 ~
- {
. m$ ~/ ~6 R6 E* z8 U$ L1 Y - file2=(LPUPDATEFILE)(*i).second;
8 o* i( p6 r# k - if((p=UpdateFile1.find(file2->full))!=UpdateFile1.end())
+ w6 V' X3 e/ o# a - {4 o8 M/ y5 b+ H/ T; q% G
- file1=(LPUPDATEFILE)(*p).second;
# u j1 y* }8 g, l# R - if(file1->vers!=file2->vers)
) k4 M0 R. \6 \* p S - {
8 U v) @- ?% R3 P - UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full)); b7 ^! Z# g' w4 E7 ?4 g* m
- c++;2 @4 l$ s' w- v/ R6 m: F
- }9 P; l4 [& S) t+ r$ e8 V+ z/ @
- }
! |- L1 T7 X f _9 o - else }4 l' T/ a5 K0 M0 H
- {
( x9 w8 G/ E0 S - UpdateLocal.insert(std::map<int,CString>::value_type(c,file2->full));
9 j8 z. _2 W0 ?6 L& H& u; Y+ i( E - c++;3 M* H( r& \8 _$ ^( g& f; P
- }# R) q: i) |# q5 w: H% L- C) ]
- }
( v# B, [3 U" q! O - }
/ N# g( I) W& [1 z4 O- G7 ]# {* b - unlink(".\\DownLoad\\update.txt");
/ z8 E: A. i. r8 y, T - if(UpdateLocal.size()) return TRUE; t: k4 o+ Q E: }: Y- {
- else return FALSE;' k/ w6 }$ g( D5 _) `
- } e( A/ k! v# |* ?9 |/ k$ p% w
- 4 @' U' o' x+ ?8 m7 O
- #define DEFAULT_PATCH_URL "http://elysium.waei.com.cn:8080/~elysium/Alpha/". H- U& z) @: ^6 G
- #define DEFAULT_REG_URL "www.wgs.com.cn"
4 e- ]) B0 e& D3 h3 S* y - 7 e5 x2 y6 y4 j
* b0 Q) K2 @3 V- 1 Y; @6 Y8 U1 t
- BOOL CRevAppApp::ReadCfgFile(CString sCfgFile)' A1 }7 f' q" \; H
- {4 H) G% L! S( u8 h5 \
- DWORD dwType=AFX_INET_SERVICE_HTTP;
J' j& b- o3 D# [% p/ Z% P - if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)4 @, E* k; u+ u8 Z( `* D1 b
- {6 y: \4 u% \& T+ v6 k# k& u
- char szLanguage[50];
8 Q7 [ T' S n6 b6 ~8 i - GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");
2 t0 R3 Q7 ~4 A - if(!strnicmp("BIG",szLanguage,3)) m_iLanguage=TRADITIONAL_CHINESE;9 q4 w7 G) ?2 r, O& C
- else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;
; b, V% y1 Y9 O - else m_iLanguage=ENGLISH;
2 i. q! ]* ]0 U+ `2 p - char szRegister[100];
/ k! ^ Z2 w5 T3 ~4 P! N - GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");# S4 |0 b" _) w% I4 O( _* C5 i3 C2 v
- strRegsName=szRegister;
+ N" w6 f6 B, n- N2 W% |- j - char szPatchURL[100];
{8 h! W* _) \ - GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
) V. |7 [8 I) j* N - AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
; b! @& N* ~: T7 I* r) [2 s E - }4 D. U0 l; P7 j: ~; l+ @$ w$ S
- else: {7 z4 ~5 O6 x( Z9 V4 v
- {8 V6 s) ~6 r {; A5 @! P1 I7 t9 w: U
- AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort);
- U2 q0 Z7 ]8 q: h" ~2 M - strRegsName=DEFAULT_REG_URL;
+ Z: P' ]* b9 V4 N2 q4 T5 @ - }
, F3 @# F) P# ]8 X6 y - if(GetFileAttributes("hosts.ini")!=-1)
/ y5 Z9 x3 t& q# h, B; C - {6 H, P9 v- L; n$ |8 \( @ X1 z$ s7 d9 ~
- char szIP[50];4 w, a* ^% }+ G6 v
- char szDIR[300];
* ~' j$ m+ T1 W' D6 Y) X& c8 L - if(0!=GetPrivateProfileString("update","ip","",szIP,16,".\\Hosts.ini"))
: V! C7 H: K: @/ \5 f. \, u4 D - {
$ A8 s" O; E3 V- i: v8 b# C - wPort=GetPrivateProfileInt("update","port",0,".\\hosts.ini");7 z7 g4 \4 K: B& V: p
- GetPrivateProfileString("update","dir","",szDIR,300,".\\Hosts.ini");
. L* Q( b- A. ^, t7 {+ [8 @+ G - strHostName=szIP;+ @7 e# R K, C5 {" u. X4 T
- strHostPath.Format("/%s",szDIR);, X8 @0 q1 o3 P
- }, C2 @/ b6 a- l8 p3 q
- else8 l7 h, y- b) a' K0 V0 a
- {# u4 i. g# a3 k1 |
- if(GetFileAttributes((LPCTSTR)sCfgFile)!=-1)
( L4 N) S0 a$ ?+ `! T' s) p8 D2 k - {
3 J# k' c h3 D+ T - char szLanguage[50];
5 d& t1 C( ?, E, h6 `$ k3 p - GetPrivateProfileString("Interface","Language","",szLanguage,50,".\\Config.ini");% J8 D2 M. Q0 g7 `9 ~/ z# g$ E
- if(!strnicmp("BIG",szLanguage,3)) m_iLanguage=TRADITIONAL_CHINESE;
. [7 q8 S9 @1 f5 Y - else if(!strnicmp("GBK",szLanguage,3)) m_iLanguage=SIMPLIFY_CHINESE;: ], E' F2 a8 R5 ~: d
- else m_iLanguage=ENGLISH;' @) h% B. t% x- ]1 ?7 S
- char szRegister[100];: F. \! ]4 S% K: h4 Y
- GetPrivateProfileString("Function","RegisterURL","",szRegister,100,".\\Config.ini");7 W+ S D) l% y8 j; J) c8 e
- strRegsName=szRegister;" m' K' m' j/ R8 h7 E! ]- g& g
- char szPatchURL[100];
& B6 f- Y0 Z! X, W3 u - GetPrivateProfileString("Function","PatchURL","",szPatchURL,100,".\\Config.ini");
' J8 s; o3 ?& Y7 H+ p( R! O' G: Q - AfxParseURL(szPatchURL,dwType,strHostName,strHostPath,wPort);
8 p* A9 e. z8 z* b - }
( Z" A" { \/ p" ^1 u: r* N - else. L6 a( H# i$ u& o% S9 ^
- { f- V, h) F& A( Y2 b$ X- @
- AfxParseURL(DEFAULT_PATCH_URL,dwType,strHostName,strHostPath,wPort); D H7 i6 c) V t
- strRegsName=DEFAULT_REG_URL;
$ x5 c- s& g e) d( V - }0 U1 ?1 c4 D3 [2 ^2 ~
- }
0 H4 K& u* ~( o: T+ S4 r - }- ~. ?5 D+ k3 t6 [* O. ^3 O9 Z# k
- return true;
2 k; g2 M3 u$ {$ ~ - }
* n9 E2 G2 e7 \* k8 W _- U1 Y6 I3 _ - # P: h- a( {: O |8 w8 f$ j) E9 p
- #include ".\ZLib\unzip.h"4 R! e- p6 a- |3 W, O
- extern "C" extern int do_extract(unzFile uf,int opt_extract_without_path,int opt_overwrite,char *extra_path,ZIPCALLBACK zip_callback);
9 X" O- m; A" l3 B0 ^. c7 g - /////////////////////////////////////////////////////////////////////////////% X$ V: p H8 p7 e; Y- B. M
- // CRevAppApp initialization
" c6 ?3 o9 b4 a2 {) F0 X4 ` - ! d; r! g" y8 u" x4 g
- BOOL CRevAppApp::InitInstance()! _2 `& \1 F' x
- {
' w/ f' j9 e8 |/ s# s0 j' f - TCHAR szPath[MAX_PATH],szPathSource[MAX_PATH],szPathTarget[MAX_PATH];
4 w2 ^" |$ U" X5 d - % W. H( Y k. J* q: T. m! k. n) F
- GetModuleFileName(NULL,szPathSource,MAX_PATH);5 d! k- F0 [5 Z; ]# @4 o' P8 m
- if(GetCurrentDirectory(MAX_PATH,szPath))
7 ]: x8 T' ]3 z6 |) u5 D - {
) `& {4 ]$ k2 {5 Q- M# Z; A3 a - if(szPath[strlen(szPath)-1]!='\\') strcat(szPath,"\");5 T5 n5 N: c. l) \; B6 \; w
- GetPathFromFullPath(szPathTarget,szPathSource);% I3 |: L" \* ?. M; c
- if(strnicmp(szPath,szPathSource,strlen(szPathTarget)))& P: j' j' O; {4 W0 ] H% L1 i, }6 X
- {! _4 O7 c9 `! }
- strcpy(szPath,szPathTarget);. Y" t1 C4 {! [" T# a
- SetCurrentDirectory(szPath);* x8 P- e* N, B" F) i
- }
( L/ W( E6 [# B2 l1 W3 b' V - }/ C" A6 _/ i8 [5 @: B; j' @
- #ifdef _DEBUG% l$ p$ W, H7 e
- if(strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))/ {. |8 G% j+ u
- #else" X- a- h4 F3 R3 Y3 \" a
- if(!strnicmp(&szPathSource[strlen(szPath)],"CSUpdate.exe",12))
2 s8 V1 i. ?+ m - #endif; L: T. R/ l8 n! ?
- {, F4 N% c' x, l, p9 f- }
- char tempFileName[MAX_PATH];
: }9 ]% Y# }9 i - strcpy(tempFileName,szPathSource);' D6 n& u/ j' P" [ w7 w
- tempFileName[strlen(szPathSource)-12]=0;/ `. y- t4 B& h
- strcat(tempFileName,"\\$CSUpdate.exe");
6 k: V* @. Q% N+ e, s* }8 d/ |% R - ForceCopyFile(szPathSource,tempFileName,FALSE);. C/ Z' I' a: k6 l
- ShellExecute(NULL,"open",tempFileName,NULL,NULL,SW_SHOW);: v; Z) y2 P& c
- return TRUE;
* w& J* \& ]8 m - }. ]8 O$ R% X4 h. `1 m( G
- // Nuke 0118: Delete run.exe( ^7 L) D: x2 @. Z
- if(GetFileAttributes("Run.exe" )!=-1) DeleteFile("Run.exe" );) j4 {4 W. x+ ?/ G
- if(GetFileAttributes("$Run.exe")!=-1) DeleteFile("$Run.exe");
+ [4 Y0 d' o; K& o N# t - if(!ReadCfgFile("Config.ini"))
: i4 b) r" H) p3 b0 R - {! t! _' \3 B7 U) N! h, B6 I: u
- MessageBox(GetActiveWindow(),"Cannot read Config.ini file !","Error",MB_OK|MB_ICONERROR);, R- U( z; y% Y6 W
- return TRUE;6 W: a7 T8 H& b6 X* A
- }( i* V# C% F3 n C& q; [3 Z- ?
- HANDLE mutex;0 [' `( t+ a( Q- N0 u" c
- if(mutex=CreateMutex(NULL,FALSE,"Elysium"))
; l: k' O& i7 z2 r# u. v - {
4 `: W$ g9 L. t e$ C; s& N6 j - if(GetLastError()==ERROR_ALREADY_EXISTS)
. Y& T' z& H" Q - {
3 [; ^" X2 a4 o - CloseHandle(mutex);+ X, u! K' X- `8 S3 W
- MessageBox(GetActiveWindow(),"Please shut down your Elysium !","WARNING",MB_OK|MB_ICONERROR);
0 w$ F1 O* Q. P - return TRUE;; S J4 k6 v+ k' R; V \
- }
4 q _" D4 L6 o/ k - } 4 l! X4 S: f( [* }4 f9 z2 h
- CloseHandle(mutex);! m4 ^1 a- r; k8 Z: H
" r) A: V0 j" J$ L- if(!strnicmp((LPCTSTR)strHostName,"http://",7)) strHostName.Delete(0,7);! a! f$ A# j. _8 j2 x, E
- 0 C2 ^; p7 C; i% @( u& R
- AfxEnableControlContainer();
- k& U! I; l( T3 x
7 L4 }+ @" p; v5 _8 [1 ]$ ~$ p2 \6 w- bCanUpdate=FALSE;% s2 H, M# A) Z. F" K# G) w
- dwStartUpSteps=1;
2 `8 K5 C! J) ?* I/ E& ]$ ]; l - dwProgramState=AP_NOTHING;; Q7 {& c6 d0 F m2 M
# F( I: x# h. T' s- InstallRevUI(m_hInstance,&g_UIDefine,&g_ResIndex);
* l- T6 J" t9 K2 a+ o
. `- Q) R/ @( P" [1 d, W- // Standard initialization
& O$ h6 p0 i- ~; e5 H: x; b" _# h* q - // If you are not using these features and wish to reduce the size- u# l& P: [+ ^$ N& y% M( o; ]8 u
- // of your final executable, you should remove from the following4 g! R, T* w( N5 C4 D
- // the specific initialization routines you do not need.7 s4 @+ P5 b. s3 b+ O: O8 [
( P- O9 h/ d# @. P! D- #ifdef _AFXDLL5 J& W) C3 X! ^8 j, z
- Enable3dControls(); // Call this when using MFC in a shared DLL
) E" H5 Q6 u' G! G& N2 ? - #else
8 `! X+ J) I p) h M4 ] - Enable3dControlsStatic(); // Call this when linking to MFC statically
* H |: a8 h4 X - #endif% E E3 t( u9 z& ^" o
' }! \/ T3 x5 Z: x$ o* C4 H- dlg=new CRevAppDlg;2 {% j( _* m2 S. j- D
- dlg->Create(IDD_REVAPP_DIALOG);
/ M4 S/ C/ L: F0 |* h - dlg->ShowWindow(SW_SHOWNORMAL);
1 ~, K& L4 k4 p$ X1 { - m_pMainWnd=dlg;
+ Z+ x' e( b7 h( G - ( T) Z- V) r2 t( I
- SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,0,0);1 ] H& H- f" l- Z' Z# O- \ g
# J1 @% P: K/ i$ _- // GdiplusStartupInput gdiplusStartupInput;, U! q, R+ L1 W) P. x5 c$ f9 }0 M
- // ULONG_PTR gdiplusToken;
; V i Q. p: K+ ~0 |; u - // GdiplusStartup(&gdiplusToken,&gdiplusStartupInput,NULL);
2 E0 C/ N) T7 v* s) N - ; o. b9 B1 a' q1 q/ L4 M$ R; J+ e- G
- // CRevAppDlg dlg;: U1 G. z8 j' q+ E1 ` O2 ?7 K
- // int nResponse = dlg.DoModal();; k/ I1 a+ W3 X
- // if (nResponse == IDOK)8 T: | u9 I( g( e# y) x& Q3 O, v$ V
- // {. b' |, S" q5 u9 n
- // // TODO: Place code here to handle when the dialog is& D; }( X3 J+ e
- // // dismissed with OK
& \( [! d# w1 b( u - // }
! t+ H* j n' z; S3 G4 x+ X - // else if (nResponse == IDCANCEL)# l8 I: x* h$ ]4 o
- // {
. B# E6 a4 l: G8 B9 \ - // // TODO: Place code here to handle when the dialog is
" T. ^9 n6 k2 w! [7 a$ U e1 B: A - // // dismissed with Cancel
- \) t' [1 Y/ P9 w; X - // }
& b' v/ b1 A& r0 Y* u- ~6 \2 l3 g2 J - 5 s# [3 j. G$ g( z& S- l2 y. {$ \
- // Since the dialog has been closed, return FALSE so that we exit the' F O: }9 u- A3 c9 a# Q
- // application, rather than start the application's message pump.
& u# ~* | W, y) s7 |9 l - return TRUE;
! r" w; ]; C# E* p' o I: D5 p% N - }
. q# x0 v( |% M; {5 H. |0 q& n6 d - * H7 t! C1 v, a+ a0 R
- char *CRevAppApp::strtok3(char *pSource,char *token)
" Q ]1 S5 z! _6 M# ?% g$ G( _ - {4 A1 b7 s- ]$ f5 y
- int i;8 ^2 Q3 @) Z9 {& t: ^3 t
- char *szRet;* h- ~& ^! X5 U9 M7 C8 \* j# r
- : ^& C: D" ~: ^& O
- if(pSource) { itoken=0; sztoken=pSource; } F- o( Y9 e. }! L! v5 H$ @9 C
- if(sztoken); t9 ?$ u1 U- p O6 I) H# u2 y
- {
( r. n, o) N+ p. B9 b+ b - szRet=&sztoken[itoken];( ^7 U* b% N. P4 Q
- while(sztoken[itoken])( x( f j* z, [( ?
- {$ J2 _! r( q6 @' n
- for(i=0;i<(int)strlen(token);i++)4 `/ m2 F2 E! A/ E, S
- {
8 f2 E" J" {; u9 M U: `! I - if(sztoken[itoken]==token[i]&&sztoken[itoken+1]==token[i+1])7 u q9 l; A0 @$ x
- {6 w J I5 @9 N2 ?8 v9 m& w k
- sztoken[itoken++]=0;2 P" c3 p8 b, F' o# ]
- sztoken[itoken++]=0;
3 p0 Q4 K. h7 R0 w' i! o - return szRet;
9 s' A/ h6 F& W% j1 C, d5 L) T - }
# }) `6 M* ^, D$ }+ C - }
1 L4 I8 u; L4 S" S0 R8 K - itoken++;0 o8 ]) Q6 N, I+ Y1 M8 E7 C, B( `
- }7 v3 L/ j6 v7 q0 k+ ^
- }
, o" ~0 v( T7 M+ y/ ~ - return NULL;
& K* j7 T& W( J% H9 n6 e1 P/ \ - }
" P& W) ]4 m# Y' ]$ O3 p+ }4 p - # O4 @2 V) Y. U( Y" y$ i
- void ProcessProc(long Total,long Current)9 r7 f( x+ I$ i( y; M& s6 ]
- {+ t' @+ `, @4 |& x) @0 {
- MSG msg;
% T& J% r+ I+ Z' d, i- f - if(!IsWindow(theApp.dlg->m_hWnd)) exit(1);! l: i; p7 {+ Q, ]. T' O
- theApp.dlg->m_Process2.SetPos(100*Current/(Total?Total:1));7 e/ w! r1 {* A" `; _
- if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
& M% N! D. G: _ - {
+ ` a5 Q/ E% {3 Q; o5 ~" X, n - if(!GetMessage(&msg,NULL,0,0))
, h( N! v2 z$ v- k( d( G9 T4 | - {+ ]' `: X5 B1 f8 D% y) o/ }. `
- return;. p" d' i+ ^2 R/ B2 G7 \
- }* W/ k! E2 J4 g; ~% z
- TranslateMessage(&msg);
) J" c h1 Y) V1 o& D0 E+ j( v - DispatchMessage(&msg);# ~, _+ A7 {2 x" _" V) S4 H8 W
- }
) b5 N/ M" Q2 c - }9 i1 u) d4 V* K: @2 c% Z
- % m6 |6 j% s' K: e5 D
- BOOL bFirstChar=TRUE;
% C! q5 r$ p- v$ Z0 O5 |1 k - 0 k' ]! y1 u4 H: T
- BOOL CRevAppApp::OnIdle(LONG lCount)
' X! o; z7 l1 X - { D5 N4 [- R* ?
- // TODO: Add your specialized code here and/or call the base class7 P/ g" M- }, c3 N }! P4 r
- switch(dwProgramState)9 O. L8 g: ~* H% d9 @
- {
( e9 t8 {; P: `; Z# M3 G- w - case AP_NOTHING:- J, M8 ?: f8 I I! I/ A# F, M
- switch(dwStartUpSteps)( ?# A& Y4 Z5 X' b( D) K9 Y' `
- {
5 d" W& W: u- o% w1 R' A - case 1:% o* D1 }( O+ x' j* k) g* s+ P
- {$ ]; U4 N! s9 g( c- P( [! N3 a
- int i;0 l. w5 x/ u8 g* d- x: b# }; E
- CDC *pCDC=dlg->GetDC();
2 s( I) o, v4 S) J+ G) _ M - HDC hdcwnd=pCDC->m_hDC;7 j$ A/ z( @! x: X/ K& v* M2 g" X
- // Graphics graphics(hdcwnd);
! i$ J# e9 q7 t! Y. i1 l3 D - // Bitmap bitmap(L".\\Elysium\\Back1.bmp");3 Q9 f+ t6 H/ v! i, z
- // INT iWidth=bitmap.GetWidth();5 F c8 r B7 T2 a
- // INT iHeight=bitmap.GetHeight();
0 i# T! p0 |8 H# j& M - // Color color,colorTemp;. r& U& O& d" L2 v* Q- F4 Q
- // for(INT iRow=0;iRow<iHeight;iRow++)/ `6 v4 m# d7 }' i4 {0 N
- // {/ _+ I! G; c. j" W
- // for(INT iColumn=0;iColumn<iWidth;iColumn++)4 d; ^6 t8 g& J' e: n! L. H
- // {8 m' u6 X* U7 W6 P1 ^
- // bitmap.GetPixel(iColumn,iRow,&color);+ Q+ K, ?( p' ?, E. I9 u
- // colorTemp.SetValue(color.MakeARGB(7 L+ S6 L% R |* K( I; R
- // (BYTE)(255*iColumn/iWidth),) J! ]2 I- P- \( I) w' u, D
- // color.GetRed(),
) b, n* w' K$ b' V7 b7 ~7 Q - // color.GetGreen(),
9 s3 M* n+ e9 \6 \( R1 W: ^+ T - // color.GetBlue()));! A8 C% K( V; ^ p9 }) Q/ p
- // bitmap.SetPixel(iColumn,iRow,colorTemp);' r# H% g3 i! E" U
- // }1 [: O9 g( w4 Y6 q0 Y. Y
- // }7 _' L3 ^# q |# r
- // graphics.DrawImage(&bitmap,0,0,iWidth,iHeight);$ w) D" M( y' h* d- n# h
- HDC hdcorg=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");6 I/ ?, E& \3 y8 u) |& F
- HDC hdcsrc=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back1.bmp");" U* x; j9 h1 O& P" J( v
- HDC hdctar=ReadBMPRGBA(hdcwnd,".\\Elysium\\Back2.bmp");( v, R9 g6 q3 c) Y
- for(i=0;i<240;i+=8)
5 H( M" Q% y* b1 \% U) e/ R - {
/ K' Q7 y8 h" E) D, Q3 j - BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);* T$ v5 [# G! l, a& t6 [
- DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);
& D% A. X8 w, w+ R+ y! E% z/ V - BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);' t L) g: d6 S0 t/ g
- Sleep(33);: b5 D6 j( |5 L
- }
' ^; q8 z3 Y. A1 m* }5 \ - Sleep(1000);
( V- e: ]; W; f7 N - for(i=240;i>0;i-=8)* R$ D* {+ f+ Z* h" S. ~" S
- {
2 g& i, ^- n1 D: y, c$ @ - BitBlt(hdctar,164,72,408,318,hdcorg,164,72,SRCCOPY);
/ U4 R: H# y% Z$ h4 {1 ? - DrawAlphaBlend(hdctar,hdcsrc,164,72,408,318,i);7 T7 O6 ?+ }0 g w& |6 t' x8 G
- BitBlt(hdcwnd,164,72,408,318,hdctar,164,72,SRCCOPY);% r0 e3 T; X8 F; ?6 Q
- Sleep(33);7 `5 u* ^ y7 [1 t1 o" Y0 P4 k
- }
, L( g6 d2 R& H* K8 E - SendMessage(m_pMainWnd->GetSafeHwnd(),WM_USER+1,1,0);, m0 f# }1 ?. R4 M; n
- dlg->ReleaseDC(pCDC);
1 |3 w* N4 W( K m* ] - DeleteDC(hdctar);
3 o1 q% _4 F2 |! q" W- a- a! m - DeleteDC(hdcsrc);
5 g. J. C2 f2 U4 s' G+ ?7 Z4 Z - DeleteDC(hdcorg);4 M) K. ~7 X. C5 F
- }) k9 R+ l" W7 z6 {% `
- // MessageBox(NULL,"Step 1","Elysium",MB_OK);
: {$ ?; _8 u( U, C& V/ r - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝狝竟腹 :");
! v! I3 y& m( T - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新伺服器代号 :");3 Q& V, ]1 v- `2 c+ j) K
- else dlg->m_ListText.AddString("Updating the Server ID:");8 @/ n6 E6 k" c# t4 k
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
( C) A8 N- t8 A - if(!Dn.Connected())/ h. y+ j4 j6 h2 `8 ^: ?" a
- {9 q1 X7 ~* c7 o/ g- h& w* b. @; i0 p
- dwTotalFiles=1;
" V% Z9 E. h, \ - dwDownLoaded=0;
& \$ c" A o! t- J! }) h$ ~ - bSilentStep=TRUE;
' H8 W! N; `! R6 m- Q" v - bCompressed=FALSE;
& x i5 X0 m* Q& l - strExtLocal.Empty();- h2 }- L0 |8 j: q. x& P- U
- strFullName="readme.txt";
- b+ w7 H6 W. C# c) k, c" _, {2 H+ B - dwProgramState=AP_CONNECT;
1 ~% q9 h/ @: p r - }
+ f. N- g) V2 T1 o - m_pMainWnd->GetActiveWindow()->Invalidate();! ~+ r( e- ?& ^" e
- dwStartUpSteps=2;" a8 E! {- _4 d% d, q5 d) B ^1 O
- break;* g- D$ ^) m- E( Y; f9 L
- case 2:
3 A2 i8 w3 K2 w' Q - {
7 W7 h) X; K$ W+ q: Z - int iEOF;
: t2 D3 l% \5 C - FILE *fp;
9 q: w: e+ W e3 ?( L - char szString[512];: ]8 w0 R* |! c5 [' p
- fp=fopen(".\\DownLoad\\readme.txt","r");
2 \* @# k3 X; I8 M* J( @7 D) ~" F - if(fp)3 f7 p# y* q$ B3 {% M& z
- {
9 u' y9 M$ `$ K# S - do
& ^. Z" K2 n6 j& Q& P0 x3 `1 E - {
7 X* q1 o% ~7 N9 |; P8 b - iEOF=fscanf(fp,"%s",szString);, T' C( W, e! z# T; U, J
- if(strlen(szString))7 S) V. c8 t b2 {5 k
- {3 P" G6 x* A7 i' u- u) a
- if(bFirstChar)
, h2 C- e/ I4 q9 m4 G, @/ |1 U - {
4 ^) \. M7 ~/ b - bFirstChar=FALSE;
1 ]7 B& T' L1 H/ U0 n - bConnectIsBig5=FALSE;) T& y ]# D+ U7 x# Z
- if(*szString=='T') bConnectIsBig5=TRUE;
5 f6 S$ o, \& x6 f- @/ C/ H - }3 ~0 B1 C- R0 H; V) Y
- if( bDisplayIsBig5 && !bConnectIsBig5) GBKS2BIG5(szString,strlen(szString));
: j L) Y& F" B6 u5 p* D( ? - if(!bDisplayIsBig5 && bConnectIsBig5) Big52GBKS(szString,strlen(szString));
7 F$ s9 U2 Z9 Q1 \' c& D' m - dlg->m_ListText.AddString(szString);% x2 l+ R* E+ |* P5 v
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);6 F0 r% s7 M6 {! o$ C8 N
- *szString=0;
/ u/ J* `8 b& E: g2 s - }7 p2 s: Y% d; k: z' S
- } while(iEOF!=EOF);; m% O6 z7 P6 q0 _- j
- fclose(fp);) ^# V. v& }: w3 F: B& b
- unlink(".\\DownLoad\\readme.txt");+ U9 O4 V, R- i: R
- dwStartUpSteps=3;6 E* r2 M7 W- I0 g
- }
+ E% K- c* e8 g' F/ Y. P - }% i! x# j5 k$ _2 O6 d
- break;
. [" |$ F6 [# V% | - case 3:
( Y( m! Q2 ?! `. N - if(!Dn.Connected())6 |' ?3 J$ P, u
- {
A8 B4 q! z8 C" B7 e' x; N4 i' v - // MessageBox(NULL,"Step 2","Elysium",MB_OK);1 p2 i$ `0 P( a/ s
- dwTotalFiles=1;
3 n. b0 y) E4 V& N8 V - dwDownLoaded=0;' `: S3 e3 v8 Z7 { S( B
- bSilentStep=TRUE;
0 O+ P# r& E: i( [/ u. c' Q6 Z - bCompressed=FALSE;
7 [/ y0 E- r/ T" C L% O - strExtLocal.Empty();- n' v+ j1 C, o& P0 x
- strFullName="checkversion.txt";7 [. s/ z5 o! z9 Y; C4 w) k. s
- dwProgramState=AP_CONNECT;$ Y4 `; A" O) C+ z
- }+ y, \" j0 Z6 @9 B% I% I& y
- dwStartUpSteps=4;+ n' h; x9 ]: |8 i& S4 F
- break;* n5 S( S; {; d. y6 V
- case 4:: U& J" @7 ]: T) O
- {1 ^6 @ W3 w; a
- FILE *fp;
. a; k. V X. A! q3 N - char szString1[128];! r3 f$ r8 \* e+ S
- char szString2[128];; C' W* f7 `, Z4 W. D
- fp=fopen(".\\DownLoad\\checkversion.txt","r");
* ?: e$ q Y: V' O$ I - if(fp)6 `% r0 v& u1 V( B/ x& t; O
- {
- A$ q. x! x: E - fscanf(fp,"%s",szString1);
9 g/ `$ X. C$ R2 \ E - fclose(fp);0 U5 \; i$ z# J% j1 u9 V
- fCheckVersion=atof(szString1);6 H9 Y8 `! z& `1 R
- fp=fopen(".\\checkversion.dat","r");7 }9 [0 q( V$ L; U& Q6 L+ T
- if(fp)
* @5 `% V2 [. y - {. }/ ~9 X! K" Q3 r
- fscanf(fp,"%s",szString2);7 `+ v& q! Y3 B. ], T+ o# _4 | `! ?
- fclose(fp);4 i( O9 t: D. f
- if(atof(szString1)!=atof(szString2))
, N9 M& S1 r+ l( ~2 O/ d9 a+ C - {
7 { ]5 e" ?+ B - if(!Dn.Connected())
; L' F6 y( ?& o P) P - {
: c6 M! Z! x; S F% L A! N' m - bFirstUpdate=TRUE;. x* l3 o) o. s" t8 m$ d _' A
- dwTotalFiles=1;
8 h9 S3 v, ^! z - dwDownLoaded=0;
; L" S4 H, j* L - bSilentStep=FALSE;
, P8 z2 E0 B" }. G& X" `# U. ^ - bCompressed=TRUE;
0 R0 B; n# e3 [ - strExtLocal=".\\DownLoad\";
7 ^( A+ F$ U! j# s2 s$ G8 \4 o - strFullName="update.txt";
: ?. q! E! D6 Q8 b2 X - dwProgramState=AP_CONNECT;- i- [! |- f; Y% o3 `
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝更い, 叫祔.....");
' f5 g4 N3 ?: V e5 G - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");" K: ?9 f: I4 A2 [
- else dlg->m_ListText.AddString("downloading update list.....");
( z1 {, J& `5 q6 `3 { - ( D& ^% ]6 O8 c6 H3 f% g( C/ w
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);4 A. c+ E8 @4 `$ ]" h% i
- unlink(".\\DownLoad\\checkversion.txt");
8 x; e$ O1 P8 I - if( GetFileAttributes("Wsa.zip" )!=-1); X- N( k* D" W+ K9 P
- {- N* F0 J2 b! T2 e
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃, 惠だ牧");
) e& f/ {' R0 @( C# T - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压, 约需耗时十分钟");: ^: k: G z0 h8 ]9 P
- else dlg->m_ListText.AddString("Unzip Files, Maybe cost 10 minutes");- s) H- i! ]6 r
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
* z/ F ^6 J% v5 E! _ - # w( O! X- b) u/ n
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫瑻み单..........");9 O/ S: o& _3 L4 h
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请耐心等待..........");& \" `* ^( p0 z2 @4 f! p
- else dlg->m_ListText.AddString("Waiting..........");! S+ S2 c7 K3 W( i5 h' V0 \
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);! x) _4 j! f: a# R
- }
' i; G& J/ Y* ?: I5 T - dwStartUpSteps=5; i" @+ e8 s6 |
- }: I7 v! J7 D% V6 Q9 b& o
- }. q( D& A. s* {. ~% v! |
- else( d) o. b( S- b1 M
- {, g( ~! p' n4 E3 S( s# Q0 }
- unlink(".\\DownLoad\\checkversion.txt");
B( u& `; {/ @8 t$ `, ? - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");6 ~0 _$ u7 `" Q3 h4 b/ F* v" c7 \
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("没有需要更新的资料.....");7 a' J& k0 _8 ]7 T2 V0 f
- else dlg->m_ListText.AddString("no new file update.....");' N$ \* ?) ^6 M$ L
- & x! n9 J0 N2 K. c3 R
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);% Q# O7 q W$ i4 [
- dwStartUpSteps=99;
! F1 D' l2 B) _9 Q - bFinishUpdated=TRUE;
6 R' p9 m2 t: X - bCanUpdate=TRUE;& l% T. ^% z9 Y- z7 R
- }
# @( D* x- a: C/ c - }' l- I2 j2 K& S% U
- else& j* ?/ I7 c4 Z8 F! F3 J% u
- { }: q p9 H; T% r# }
- if(!Dn.Connected())9 E% ~5 g% W; e/ }4 u- F' l
- {" b% [$ f& B0 b) e4 }9 g5 R
- bFirstUpdate=TRUE;( N. {: V S* R, V' _/ p
- dwTotalFiles=1;# B( u0 w7 W. l8 ~* ]5 A
- dwDownLoaded=0;
- h! Z$ Q( P" { - bSilentStep=FALSE;
; R/ \8 m' ]: _$ `% [ - bCompressed=TRUE;6 E& N' {: s8 {, q& H
- strExtLocal=".\\DownLoad\";" k& L5 H; _ Q/ F* i
- strFullName="update.txt";
$ o+ _, ]/ i. I3 L - dwProgramState=AP_CONNECT;
& S9 `# w0 Z/ J3 N+ D - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝更い, 叫祔.....");
, ^* `3 s: a, A5 V4 N" z9 B6 ? - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新列表下载中, 请稍待.....");$ ~: x1 \- [* z- P' E$ X
- else dlg->m_ListText.AddString("downloading update list.....");
/ S1 c+ K& K6 c, M. o+ V - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
& P; `$ t8 Z- i3 F6 X7 L - unlink(".\\DownLoad\\checkversion.txt");2 A5 T7 ?( n) B
- if(GetFileAttributes("Wsa.zip" )!=-1)
! c' b- v5 K& y5 j2 G& a, L - {! Y1 ^! n/ R! ?8 ?$ z, Y
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃......");
4 ] I% ~7 _; Q+ x! D! O* Q - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压.....");- A) z& L& _6 U' b& `
- else dlg->m_ListText.AddString("Unzip Files.....");
]0 u6 ?! X" `0 m - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);4 Z/ B( N, E: X
- " F' ]2 N+ \2 r1 B; g5 r6 n! O
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫瑻み单.........."); E" N* [/ I+ O2 f
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请耐心等待..........");; ]+ p- c9 O) b
- else dlg->m_ListText.AddString("Waiting..........");1 b( B6 y' S: \6 p
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);& ~+ F6 B/ C+ N4 I
- }
. Q+ y; }/ a9 p M/ { - dwStartUpSteps=5;
3 D* |% y+ Q. J8 K' Q- a" t - }
8 M* S6 R1 ?* \5 O) T2 G( j% A. H: E - }
9 p- m' m8 U/ ^8 j* k1 e - }
5 Y$ b- c! N- [, s& I- }! v - else( c- k" u3 w1 S/ S0 l/ ^
- {# p8 p$ q, _$ ~2 d5 v# \: I2 c( t
- dwStartUpSteps=3;0 g4 F3 ?' c- a
- }% V, t. g. h& R
- }4 ^6 Q! c" L" W' w& b
- break;
8 m# e P# b {4 P# ` - case 5:
$ K( B: M7 c+ a3 b8 L$ X+ E& l - {
$ n7 V6 T2 Z, n4 j - if(GetFileAttributes("Wsa.zip" )!=-1)
* V7 ?* l8 j! `2 V( a" U& P - {
2 o+ T9 A& A/ z - int opt_overwrite=1;
" m, w+ s& a# Q! b {; X( ` - int opt_do_extract_withoutpath=0;
. \# C2 C& o; P% S - unzFile uf=NULL;
9 G+ j/ S6 a: n$ U ? - . i B4 |- ?1 S
- uf=unzOpen("Wsa.zip");- d9 C6 I8 h9 U3 C
- if(uf); u4 t' u( w0 i c$ E g
- {6 }7 ^) z( s/ d2 m! B. E" H+ B
- do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,NULL,ProcessProc);
$ c. y; f4 f1 a2 o% P( \6 C - unzClose(uf);* H& m+ g; X$ [
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("郎秆溃ЧΘ.....");* K2 v3 m; d* H- _: Z$ l
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("档案解压完成.....");1 k$ _4 K( z5 F- w- w1 N9 l, i
- else dlg->m_ListText.AddString("Unzip OK.....");8 d& P J) e$ [+ ]2 Y8 J
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
5 Y; }5 [, v. [7 K$ e6 r7 M - }
- U* N& S# C V s% v1 R - DeleteFile("Wsa.zip" );$ f- |4 o# G+ l( L4 M
- }
2 s# J( U1 G5 [" v# G3 N$ m2 `7 M - 0 K3 z9 C+ \8 T6 W* K( i4 i
- if(CheckLocalVersion())
( v0 F/ L9 M, l% U2 R9 o F - {
$ }9 x/ P8 m, Y4 x- J# r; i6 J - if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("叫磅︽絬穝戈.....");2 J' x: {8 J! F" a0 c0 Y% ^
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("请执行线上更新资料.....");
5 a% w& t6 x0 L9 _9 l - else dlg->m_ListText.AddString("Please update.....");/ C6 w) L( @/ u( o+ V$ i& ]! I
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
5 q) E' A: y5 e7 \/ K - SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,3,0);0 _* C, p4 n% ?) b3 i
- dwStartUpSteps=99;2 Q7 G' [* N1 {
- }
) |; I( X& t( [- m% Q - else
5 L: s, ^ @7 r, E% c9 V - {3 i' V, d" D V1 x2 t E" m# @
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("⊿Τ惠璶穝戈.....");4 ?) ]1 w5 P! Q. f* S0 U3 [8 `
- else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("没有需要更新的资料.....");
5 U4 c3 k5 X$ v( F M1 E$ u - else dlg->m_ListText.AddString("no new file update.....");
4 n3 W/ a; Y: w, T$ B - 1 H! R d. d' m& m3 d
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
9 V4 T6 O5 o: l! s$ u( E - dwStartUpSteps=99;
0 U% S5 P6 {; ^/ F - bFinishUpdated=TRUE;, K# S3 u. l0 J6 M. ?% o( N" N3 A
- }0 u! Z7 S$ p* B9 z9 x6 v( z
- bCanUpdate=TRUE;4 L. U* r+ A, `) R0 w2 L
- }' g" n! Q0 V; c
- break;
& R: S2 m. R# x, ^ - case 6:4 x5 w- p# {# v- q/ g4 d
- {! R: I6 f. g0 K2 h4 R. q
- if(!UpdateLocalVersion()); p8 T9 [ v5 C5 H& J. C' ^7 l
- {
8 o# C* Z6 t. o0 l$ }! C - if(bRestartUpdater)) {4 z+ k, }1 @2 X* }
- {
- h( U$ z9 x( N# d( A - if ( m_iLanguage == TRADITIONAL_CHINESE ) MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);
& V2 p# l7 Z5 P0 g; Q3 J1 } - else if( m_iLanguage == SIMPLIFY_CHINESE ) MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);! Q h, L& p7 u
- else MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);
8 v! k N, b, }6 P- u' c - DestroyWindow(m_pMainWnd->GetSafeHwnd());+ _* H* g' D6 F! [* S
- dwStartUpSteps=99;
7 l8 @6 q- u6 { - }
|! A! ]+ x* }$ x% a7 x* v+ l - else! Q; x5 r3 f/ m$ c+ _, p: b2 K
- {0 A* i2 k& [7 `" T# I9 q3 w
- if ( m_iLanguage == TRADITIONAL_CHINESE ) dlg->m_ListText.AddString("穝戈竒ЧΘ.....");
; p/ n% P8 a0 y* R/ P t1 q7 n# i - else if( m_iLanguage == SIMPLIFY_CHINESE ) dlg->m_ListText.AddString("更新的资料已经完成.....");* S! E% f8 P3 J
- else dlg->m_ListText.AddString("updated file ok.....");
/ k3 ?& y* X- ~( f* U - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
7 ^0 u! V, n" U4 D4 |9 @+ _+ { - SendMessage(GetDlgItem(m_pMainWnd->GetSafeHwnd(),IDC_BUTTON1),WM_USER+2,0,0);0 V8 Y. r. _! C4 _/ C% g
- dwStartUpSteps=7;
1 s; x& n9 J8 f% Y& m - bFinishUpdated=TRUE;7 T4 S. y9 }4 Y
- }
8 u( ?' j8 x0 `; _: O+ J - }/ @; \; R0 D* F3 ^0 e {
- else
/ M) J/ m% C% c - {
9 E& g2 ?) _! J9 P8 ~, | - if(bRestartUpdater)
5 x; z& ]" h& l# t% a8 Y - {
% C- H1 l8 K' ?. N& [+ \; @4 U5 _7 Q& j - if ( m_iLanguage == TRADITIONAL_CHINESE ) MessageBox(GetActiveWindow(),"叫穝磅︽穝祘Α.....","Elysium Updater",MB_OK|MB_ICONERROR);
8 {3 j0 K. y- g+ f2 s9 A. [1 y - else if( m_iLanguage == SIMPLIFY_CHINESE ) MessageBox(GetActiveWindow(),"请重新执行更新程式.....","Elysium Updater",MB_OK|MB_ICONERROR);
9 B0 S6 ^+ v9 s. m4 X& U - else MessageBox(GetActiveWindow(),"Please Restart Elysium.....","Elysium Updater",MB_OK|MB_ICONERROR);
- R( X1 f( M5 m - DestroyWindow(m_pMainWnd->GetSafeHwnd());! M! @( d2 P/ ]+ o
- dwStartUpSteps=99;
z& {4 ^& y& W$ G - }
/ m d* `, Q7 k2 C/ W - }
. `/ D4 _4 l1 \$ D - }
0 b9 B7 F& w( h" { - break;. K) y. Z: V* c% {2 j8 K) d
- case 7:+ P+ @2 J& f4 s8 G7 I
- {# n- M' s. J* I! E9 e" @! p
- char szExecuteFile[14]="Bf_Client.exe";
/ K; M) ]9 N: w* m3 d8 j% E( q( L! b8 } - if(GetFileAttributes("Run.exe")!=-1) strcpy(szExecuteFile,"Run.exe");
; H+ j9 X3 g& R7 c2 B1 f: j* \ - if(m_iLanguage==TRADITIONAL_CHINESE) ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);& _+ s' t( {2 X
- else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open",szExecuteFile,"updated2",NULL,SW_SHOW);
: j) K! s( a3 j6 D5 B" G4 W+ y - else ShellExecute(NULL,"open",szExecuteFile,"updated" ,NULL,SW_SHOW);
7 K+ L1 s0 d6 z! ? - DestroyWindow(m_pMainWnd->GetSafeHwnd());' k0 v, r+ Q$ q5 T
- dwStartUpSteps=99;* ^: ~. z8 y9 L. x# [9 r
- }+ e% w( T' ^' M9 ]6 S( F
- break;
Y/ g5 ]2 e+ r; n( d1 Q6 Q- L - //add by cece
& T" l( |4 N9 b+ K7 e, C9 e. H - case 8:
! P3 K( b* {- J& ` - {( i' w6 y; i7 W R
- if(!Dn.Connected()) Z1 u2 r% p& k e+ u6 t( E; Y2 }& o
- {
9 W. {( h- m$ e' j; o+ o - dwTotalFiles=1;. L( J- i3 J" J3 Q1 |0 X4 l
- dwDownLoaded=0;9 ]; T0 S* J* k5 C% J
- bSilentStep=TRUE;& x/ { I: L3 a9 {$ M4 I
- bCompressed=TRUE;1 `3 ^3 _' ?& h6 p
- strExtLocal.Empty();; j" Q! O) q8 d& R7 c6 n
- strFullName="download/CRCTable.txt";
. e& j1 B# b& F* ?! ` - dwProgramState=AP_CONNECT;' W ]+ i4 T0 u( y: X! s
- }
0 }, {6 o# D4 K y7 ?$ {- z! m - //
1 b/ p( o7 d1 n0 g3 y7 o - dwStartUpSteps = 9;: ] h. K! C: n
- }
; Y0 ~! I- B6 ~- }7 S - break;
5 [* V5 P9 O0 m3 ~ c - case 9:
& K1 q/ K9 e; V% X3 f0 ^+ ^9 n - {: K9 u4 m6 x/ ]8 o& E( w9 D( D
- if(!Dn.Connected())# k0 \- h. v: T N1 e3 i: [
- {# B5 K& d! e t
- dwTotalFiles=1;( V; K) E3 u8 k8 Q
- dwDownLoaded=0;
8 k/ {/ H7 K: s" x. @* M$ m - bSilentStep=TRUE;: P! O R' I- |! y2 V
- bCompressed=TRUE;5 E, M o7 o1 s/ ]7 }
- strExtLocal.Empty();/ z, f! S) n( s, ]
- strFullName="Run.exe";
& _4 E: o/ s1 B! z4 o - dwProgramState=AP_CONNECT;2 n& e( b( q2 L @7 ? U# g
- }
# R* r: i# h) h" c' S5 v - //
. c2 H% Y( S/ W9 L - dwStartUpSteps = 10;4 A5 ~- l7 h% U; `0 X% c
- }
3 b* u" x8 X9 {2 k* _( J - break;$ T7 o. y4 E: v0 C8 z7 R: e3 v- E
- case 10:
1 g/ Y* [/ \7 t/ b+ k; D - {5 c+ K0 m2 q! x0 K6 p# I
- if(m_iLanguage==TRADITIONAL_CHINESE) ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);
: s! r9 M5 y$ q; T; @ - else if(m_iLanguage==SIMPLIFY_CHINESE) ShellExecute(NULL,"open","Run.exe","updated2",NULL,SW_SHOW);4 H$ T! c4 v. S+ H
- else ShellExecute(NULL,"open","Run.exe","updated" ,NULL,SW_SHOW);
+ T! U9 R9 d3 X7 u$ q+ l6 c. z6 r - DestroyWindow(m_pMainWnd->GetSafeHwnd());
& J6 Z" C5 [6 p+ Q5 \ _; _ - theApp.bClickRunExe = FALSE;
5 \3 z* {: O, G - dwStartUpSteps = 99;
- y# ~. G5 ]8 _ - //
: s8 ^7 b, z8 k3 i0 F* S0 l - }3 {, O; U! }- b3 ~- x0 ^
- break;% S% Q/ v8 q0 G2 C. Q
- //# U% w' Z Q8 h7 r/ _
- }
+ ~3 {5 G' r* I, p; s - break; y! v6 S9 \" @" { h* U
- case AP_CONNECT:; A, B$ x5 ^; B- e+ x+ t
- if(Dn.InitNWSSock(4096,4096))
9 L4 n' J2 f8 B; h& Y - {
( e* \) f7 v2 e; l - char szPathName[MAX_PATH];- \5 G) T* S1 o- S( ?9 x2 Y# v
- dwLastSize=0;1 X/ w5 e; A% ~4 B% A4 g, y! k
- GetPathFromFullPath(szPathName,(char*)(LPCTSTR)strFullName);+ p3 K' j/ R1 }
- strFilePath=strExtLocal+szPathName;
$ l9 i. m* S6 O2 O' V2 S2 r - strFileName=strFullName.Right(strFullName.GetLength()-strlen(szPathName));
- K8 n* I9 I5 J9 h' E# J - dwResumeNums=0;
+ b! D8 f( b, p+ a a# ^! A* s - CString strTempName;: Z; m J: W7 L
- if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);
8 _, P! \/ G5 \+ b8 S9 c - CString strCountData;$ b: Y m- L( d2 [- @4 o: ?* D9 K
- strCountData.Format("%d/%d",dwDownLoaded+1,dwTotalFiles);
& J6 k) O, U( z8 p1 x - dlg->m_FileNumber.SetWindowText(strCountData);' ]1 [1 Y; Y4 y) h) O
- dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));4 m& X+ P* B% N
- if(bCompressed)
& i0 A( j+ S' n) J - {
7 x% X/ P4 V: F7 d. i; e7 r+ h* t - strTempName.Format("GET %s%s.zip HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);
, p1 K T: ]1 e& Z! T3 u - }
6 b: r% r6 u3 z/ Z$ R$ u4 w& Y, ] - else
2 V: w. U1 n( f: D: y - {: L" ~& y; C) k3 K
- strTempName.Format("GET %s%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n",strHostPath,strFullName,strHostName);) D, y' n9 x0 k6 w2 M8 B
- }
) l9 W3 I+ H: j- i# D/ @" [ - Dn.Connect((char*)(LPCTSTR)strHostName,wPort);
- X' r0 J) W. M& d5 r* T9 q - Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());
8 ]- E* E( d" A; y4 `8 i! p: ?- S - LastTickCount=GetTickCount();0 }4 s1 Z+ C( |3 D' M7 F/ O' N
- dwProgramState=AP_SENDING;. H; L% s1 ^1 g4 D. Z# x0 R! _5 b
- }. \) q7 H$ Z6 W
- else
; W! D1 s1 u5 Y; S; w - {
6 k n' v' s7 u: H& Y; h/ s3 n - Dn.QuitNWSSock();+ j( _+ @$ T& j3 `5 y% e
- dwProgramState=AP_NOTHING;
2 n$ y+ C/ z! ^0 ?5 p* k - }1 Q" ]. x5 Q1 d2 r
- break;9 j \# Z7 C) D$ D# U0 O; Q
- case AP_RESUMED:
8 ~- A2 e: r/ y. Y3 d/ Q4 a% ` - if(Dn.InitNWSSock(4096,4096))
- y% a% ~- X0 g - {4 K* `2 }) K/ p# B d- ~# i/ y
- dwResumeNums++;
/ j$ i3 v3 D- y# O o2 d' ^* T - CString strTempName;2 ^5 ] J/ F: V3 V
- if(!bSilentStep) dlg->m_FileName.SetWindowText(strFileName);8 s9 e6 S5 _3 |1 T. V0 S
- CString strCountData;
( k8 F: V7 Q( ]9 @ - strCountData.Format("%d/%d",dwDownLoaded,dwTotalFiles);2 O# m) \( z0 J1 S( S* Q
- dlg->m_FileNumber.SetWindowText(strCountData);
8 r) ]/ z- w j2 ? a - dlg->m_Process1.SetPos(100*dwDownLoaded/(dwTotalFiles<=0?1:dwTotalFiles));( {! t" [, p; v/ _/ t3 W1 v
- if(bCompressed)" G) E7 S1 g# f$ R6 z) w+ _
- { r: ?- E7 l: a. I% t) v, i
- 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);1 x |0 J$ }' ~6 t/ w/ e4 S# d @
- }
# H7 [6 X$ g$ S1 c1 q s | - else: `' T ?7 T& k$ a) C ~
- {
( h5 S P3 v7 }% U# n8 B - 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);
0 F' N" q+ u$ g- R+ E7 h( @ ~9 M - }" v4 G; `! H( O
- Dn.Connect((char*)(LPCTSTR)strHostName,wPort);
" q; {4 I* C$ |$ e! U% h6 O - Dn.AddSendData((char*)(LPCTSTR)strTempName,strTempName.GetLength());7 t0 h: a/ t+ b% J; V: q; m0 i
- LastTickCount=GetTickCount();# G! u/ J8 T7 y! p
- dwProgramState=AP_SENDING;
/ W' Z5 F, J7 a @0 ?* R3 X/ f - }. s4 x5 W' ?1 P$ B/ ]
- else
8 @- j2 Z5 \+ |- s& O - {
2 {# t' @7 {1 l' M- `4 @ - Dn.QuitNWSSock();
* g8 c6 {; j! Z2 L" m+ X0 f! {) P - dwProgramState=AP_NOTHING;
8 c0 ?9 Y6 P- F) B, K. N% I0 L/ f - }
; a) z5 K1 V3 k2 G1 e9 T. ` - break;9 p8 V$ \4 p- i: X
- case AP_SENDING:* [6 h% K1 F8 [, L5 m
- {
6 I- ^& g+ Z; |2 L5 W) Q I - DWORD RecvLen,SendLen;# L& s( u. j& T# `
- if(Dn.NetworkLoop(RecvLen,SendLen))
. S6 A2 Q: C# i. R - {! g3 l& \7 a* N4 G9 l7 P
- LastTickCount=GetTickCount();0 O) U. r( I/ r- \ d u9 v
- if(SendLen)! o. @! Q: V$ k7 r1 R, Z
- {
: q- T1 _- I [9 F x3 ?8 o' V - bReadHeaders=FALSE;1 n$ U- N1 J1 b# W G2 t6 J# t
- dwProgramState=AP_RECEIVE;
& `% @, @2 e4 R l - }. |3 y$ {% q4 x+ ?/ k( S8 z
- }
/ e% k# I4 P8 x0 o+ t+ x; a$ z - else
* y8 i5 z Y3 Y - {
/ V1 L0 y! B: Y- J) o4 l - if(GetTickCount()-LastTickCount>3000); v7 P; C; {, ^( r, H
- {" e/ k- H, _7 j/ e% r
- Dn.QuitNWSSock();
& N/ ?, G. r& w2 ` - dwProgramState=AP_CONNECT;
# F2 v& E7 K8 `. W7 @: W - //
5 _4 F: {, a" E2 e: Y3 S - static DWORD s_dwCount = 0;8 c% r1 j9 K$ ^$ O
- s_dwCount++;3 t' |$ \1 V+ S+ q" A
- if( s_dwCount > 10 )% l5 n0 P% X) f9 _8 V; C; l# t
- {
. A4 F" }. ]% X - if(m_iLanguage==TRADITIONAL_CHINESE) MessageBox(GetActiveWindow(),"硈钡穝狝竟ア毖叫浪琩眤呼蹈砞竚 ","Error",MB_OK|MB_ICONERROR);
+ R7 |8 m5 ?5 Z& K2 O+ Q! E - else if(m_iLanguage==SIMPLIFY_CHINESE) MessageBox(GetActiveWindow(),"连接更新伺服器失败,请检查您的网络设置 ","Error",MB_OK|MB_ICONERROR);
) @6 i c# M$ N" g - else MessageBox(GetActiveWindow(),"Connected Error, Please Check Your Network Status ","Error",MB_OK|MB_ICONERROR);' y( e+ z% d! U: i" h
- DestroyWindow(m_pMainWnd->GetSafeHwnd());: s, W/ g( A: W1 T
- }9 q" i( ?/ {1 z
- }
8 ?, ]& G, J) v7 | - }
( }( {. M; f8 q" m8 j/ T. J4 d0 F - }
! V2 G1 @3 K4 Z% X - break;( U6 ]! `+ v2 B% s6 C
- case AP_RECEIVE: _/ ~! Z4 h* t4 m4 ~
- {) @0 ~! |: p1 A
- int Count;% T n. ]0 R& U+ ~0 K* _
- DWORD RecvLen,SendLen;
2 k: c& u: v9 u% A1 f! p$ F - if(Dn.NetworkLoop(RecvLen,SendLen))
' ?( J3 C8 z5 m8 R - {) q7 x" |9 h5 Z$ n! F+ h. \. f
- LastTickCount=GetTickCount();
& q! y3 P/ H/ S+ C5 [ l( a' g' r - if(RecvLen)
# m. V& ?: s$ h; Q7 b: Z - {
7 ?- q& w) `2 J' j/ L0 ? - if(!bReadHeaders)
3 l+ N. p: O5 Y1 g* J( o - {
' }0 Z. M- j! C4 p2 }/ n - char *token=strtok3(Dn.szRecvBuff,"\r\n");7 C% p& ?/ w: z
- if(token): k" b; r* P: _ g: w
- {
9 m: I7 s' ^ E - dwFileSize=0;
% j3 v, \# X( o5 u/ F4 _0 t - for(int i=0;i<(int)strlen(token)-3;i++)
6 R, m; R( Z" ]+ q& t. b; j9 v - {3 T& k8 a- q/ D- w5 d8 q) j& ]6 p
- if(!strnicmp(&token[i],"206",3))* l7 |1 U' w, d* p- b! p1 Y3 @
- {# c5 n0 @7 E/ K3 ]7 J! S5 U
- if(!bSilentStep)
" I: G' v9 @% G# b5 ^ - {
4 y! ` K$ c2 [" H, V- D. u - CString strTempName;
0 k* @' x9 E( e& ]/ }; [0 F6 W' I - strTempName.Format("%s.....resuming(%d)",strFileName,dwResumeNums);
, I A5 O- ?* \/ g T - if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);4 a# ~: d5 D" j0 X4 ~
- dlg->m_ListText.AddString(strTempName);. V3 a5 ^6 Y1 X& N3 H
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);! V% @0 I5 F3 E
- }+ C& W$ L% s' `- g8 k4 r
- bReadHeaders=TRUE;6 N! t- y7 ]- f8 S
- while(token=strtok3(NULL,"\r\n"))) y* H2 z D, u9 n. R
- {5 O' p$ P4 h: U
- if(!strlen(token)&&dwFileSize)" j4 g( v8 Y( V9 W+ A: m- b
- {: i z) C2 V( W) N4 c
- Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;( I! p6 q6 @9 N# }! U/ @6 c
- if((int)Dn.dwRecvLeft>0)
" b; x5 X- s7 c - {3 C7 x" p! Y# ~9 }% w& w
- if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)" W' u8 M# t0 S+ d
- {
/ b& y$ k" O! G2 T' [+ x5 b f - dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;0 h# ]. w. K) ^- p
- Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);* L- ?8 z- q+ ^; L: S% t
- }
4 s4 d0 a" z# C% ~: L# b - memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);' l# V- X; u8 y5 L. a4 u. p, p
- dwCurrSize+=Dn.dwRecvLeft;/ W+ B& c1 e& m0 f5 F1 E1 x, b
- Dn.dwRecvLeft-=Dn.dwRecvLeft;0 x8 N$ {; t4 e- n, c" \
- if(dwCurrSize>=dwFileSize) goto SaveFileJump;
x3 |% T8 C9 O2 I8 q4 @; g - }5 Z4 U( ^- v. r
- break;, \, p) C* T7 s7 v+ B% P
- }
& ^3 \2 s4 e9 o: k - else
9 Y, E5 c5 V2 q+ A8 O0 A - {# s8 C2 Z f( E7 e* [( Y+ m8 T# @
- if(!strnicmp(token,"Content-Length",14))- c6 d" K! o+ x3 r* G/ Z! B& V0 J( }
- {& y1 O1 D9 j3 W5 X5 R3 I3 M7 m' g" F
- if(!Dn.szCompBuff): @6 p9 e+ L1 G
- {7 g' L4 N9 U* h2 I$ u) D# D
- dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;, S1 u) r% ^2 [+ t0 O
- Dn.szCompBuff=(LPSTR)malloc(dwFileSize);
3 {$ }8 E4 ^3 i6 g$ F' Y - }+ x' P, v# [2 |' Q
- else if(dwFileSize!=dwLastSize)
5 j$ i( B! `8 [- b2 c - {5 W8 {( P/ g! V/ g
- dwLastSize=dwFileSize=atoi(&token[16])+dwCurrSize;+ w* s/ U6 j2 k( B" I
- Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);3 m! u: Z$ H% Q$ y
- }
2 i) o" Z% F7 K6 o - }. N4 i6 H0 h+ s
- }
( I4 h1 I0 Z6 l! w* f - }
: C+ b+ ~6 O% W1 O0 l! \5 L - break;
( I/ p; _7 I! z5 T( d7 ] - }
& P9 x! a8 [" l2 I9 l9 @ - if(!strnicmp(&token[i],"200",3)) c1 f8 A+ z& ]( e* {
- {
% G+ s9 N# D6 d2 L% O3 b - if(!bSilentStep)6 H+ ~8 d+ `$ h9 ]1 C% x
- {/ ]3 a9 ^, ?( F1 K/ e% s
- dlg->m_ListText.AddString(strFileName+".....downloading");
" L2 D1 _' q! F6 b% l+ b+ T - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);, c; l# [* w) r: L' M7 f6 `
- }, x4 V* H/ J. Y% z) n
- dwCurrSize=0;: t" z6 ^. [ `% t8 {. U
- bReadHeaders=TRUE;
?# O g2 z" c" U9 q2 h& F6 _ - while(token=strtok3(NULL,"\r\n"))5 b# M4 y Q+ ^( k8 n8 ~
- {
# z/ o V) t! \% ?! R - if(!strlen(token)&&dwFileSize)
9 y* E8 V4 R$ q V5 [: G: m - {
; r2 o& s4 f8 s: C2 C) t - Dn.dwRecvLeft-=token+2-Dn.szRecvBuff;
& g8 V/ Z d* O* Q$ l - if((int)Dn.dwRecvLeft>0)
& z' u1 x `/ L3 q; W M, p - {. P/ R3 @( o- n ~: A' A( K
- if(dwCurrSize+Dn.dwRecvLeft>dwFileSize)# c' k. _ l3 N8 J$ y; z' l4 t
- {
0 g7 o. R& \* W% H6 D: }1 w# t - dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;
: [9 k& N- o5 A; u( U - Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);" f0 |, n; U! ]9 l* U/ S' `# e
- }' G# f6 W& V. z- {# T7 m
- memcpy(Dn.szCompBuff+dwCurrSize,token+2,Dn.dwRecvLeft);
0 t9 l) \' p. d% {! b3 v+ J7 S& \ - dwCurrSize+=Dn.dwRecvLeft;1 B) p* ^& o# Y* T$ S. [* g6 v) n
- Dn.dwRecvLeft-=Dn.dwRecvLeft;
. `! `$ o1 E* \+ V - if(dwCurrSize>=dwFileSize) goto SaveFileJump;
5 T R* e( w U; L+ v1 U+ u7 D - }3 l4 c0 G( i9 p$ f) ~
- break;9 r$ ?: H# Z, p9 l+ S7 {# \1 @
- }) G4 v% T. I! \3 J
- else& M1 ^# M9 z; @$ h* r2 V
- {
1 q6 W9 v( ]1 ?, ~7 f8 M - if(!strnicmp(token,"Content-Length",14))* J$ @8 i# D2 J/ L: E
- {
$ T. X' e/ r' i2 K - if(Dn.szCompBuff) { free(Dn.szCompBuff); Dn.szCompBuff=NULL; }
+ D7 c' ]" i" U - dwLastSize=dwFileSize=atoi(&token[16]);
4 ~. Z1 X" ^9 O7 B A; [ - Dn.szCompBuff=(LPSTR)malloc(dwFileSize);* Q1 _1 \) k& t$ H0 R! Z# E7 ~
- }7 K- l0 I! {( R4 U& b7 D
- }
8 ^2 N, w" E9 X0 z9 D/ C' f: G$ N - }
- y) ?6 F& t/ S+ e( P - break;
" ]1 g/ z* {3 O+ Z& i' y* Z - }
9 e+ U8 ]0 \* x6 { |$ `* Q - }" w8 Y# M' k5 l
- if(!bReadHeaders||!dwFileSize)
8 Z5 W- T: x0 _4 U& S - {
! ?1 i; ~0 y% Q- i, @. e | - // Wrong Header or Reading File Size Error
6 Z+ V" w$ w6 z% n/ @0 g$ Y+ {+ S - Dn.QuitNWSSock();3 C S1 ~, b7 T& K6 w
- dwProgramState=AP_NOTHING;- x' C& P+ c4 u5 a8 S# i {
- CString strTempName;
4 Z' {" f- H- \7 G+ K5 @4 M8 B - strTempName.Format("Navigate %s File Error !",strFullName);4 E5 }! T& o- G3 T- n. O
- MessageBox(GetActiveWindow(),strTempName,"Error",MB_OK|MB_ICONERROR);
# b/ w, ?8 l( l2 e. z4 O/ @# Z - bRestartUpdater=TRUE;% t/ Z+ u- i, |1 b" H9 S
- }8 l6 B# @( y' N
- }5 |3 u: C" u3 p/ g( M. \! c* A0 n: }$ {
- else5 o3 V, e& T1 ~" ?0 z! l( u7 g3 X
- {
8 ?2 T( c# ? m; N; G - // Have No Header4 L) Q g! F1 Q
- Dn.QuitNWSSock();
! A n+ {1 o% o+ c1 {) S - dwProgramState=AP_CONNECT;) v% v7 i# B) u* ^; }
- }
. L5 o# R2 H! ]" P! G$ u - }
& g5 \0 v. b* |1 F% F& Q: @% z - else; h, E1 v7 M, ^0 }# l
- {+ L" d/ ~0 W7 N) z9 [
- // Reading File From Web' V- X, _2 m) }9 |3 {
- if((int)Dn.dwRecvLeft>0)" R ?: D% l O% G6 z) n
- {
7 e2 F+ X( w! m8 z3 }8 ~% G - if(dwCurrSize+Dn.dwRecvLeft>dwFileSize), o- u3 _ @& `( S
- {
B9 s; w) I3 j - dwLastSize=dwFileSize=dwCurrSize+Dn.dwRecvLeft;+ S; R9 r" a1 J* z: ]3 ^
- Dn.szCompBuff=(LPSTR)realloc(Dn.szCompBuff,dwFileSize);
% E: T( e9 L3 @5 K- N$ F0 o, E3 w - }
9 b3 V1 _" z- B4 Y - memcpy(Dn.szCompBuff+dwCurrSize,Dn.szRecvBuff,Dn.dwRecvLeft);/ c) I6 ?! t3 X1 R( a) W
- dwCurrSize+=RecvLen;" s \. s& J( a, @, a4 _
- Dn.dwRecvLeft-=RecvLen;
6 K' H! G- M% B3 x1 `/ L6 U, b - }
/ `5 Q' i( `( ~5 q* J0 n - dlg->m_Process2.SetPos(100*dwCurrSize/(dwFileSize<=0?1:dwFileSize));, r* i% W( B5 t% n, t+ |7 ]
- // int iRate = 100*dwCurrSize/(dwFileSize<=0?1:dwFileSize);5 r9 [* l5 r9 H8 [
- // dlg->m_Process2.SetPos(iRate);7 p$ ]* x# d8 Q
- // if(iRate < 0) iRate = 0;" R( `1 t7 O8 f1 [; ]: G
- // if(iRate > 100) iRate = 100;; e% F9 m: _) I. d$ i# K- z; r
- // char szShow[5];$ e4 j) {# R3 e3 S; {
- // sprintf(szShow,"%d%%",iRate);( @; C) `6 B/ V* q
- // dlg->m_SingleRate.SetWindowText(szShow);: N; Z) [8 s9 t( X
- if(dwCurrSize>=dwFileSize) goto SaveFileJump;
0 P: g: p2 f6 ?7 | - }
3 t( w) z" M, Z9 Y `! z- E - }8 V& ^4 U" z# A* D0 k
- else if(dwCurrSize<dwFileSize)2 A* w) r, J0 y- D2 h* t2 V
- {7 G' _$ M& i- i4 k9 S4 H4 W* V
- // Disconnection But Size Error3 g) {. ~: L, y1 y+ |* U9 r
- Dn.QuitNWSSock();
0 y; P; ~+ ~! } - if(dwCurrSize) dwProgramState=AP_RESUMED;) q/ ], V' w+ J1 H7 S( V
- else dwProgramState=AP_CONNECT;
% l/ h4 R. ^5 T2 u, L2 `" o - }3 \4 e. d& E$ j7 W, F0 j, \, T
- else% _) h: y: Q4 E P
- { Z1 }# ?* O/ D w
- SaveFileJump:) g1 ^) D u* ~8 V' z2 j5 I
- // End of File and Disconnect5 E8 q# q- T: C: |; g% U
- FILE *Fp;8 b& ^2 R8 ?& S4 d' Y
- char szTempName[MAX_PATH];
) E" G! x3 ^! K4 z - strcpy(szTempName,".\\DownLoad\");1 T; g, K! l1 S% U
- strcat(szTempName,(char*)(LPCTSTR)strFileName);6 B3 y1 F0 v! Y+ W$ J" j
- if(bCompressed) strcat(szTempName,".zip");
8 j' L3 e* U+ a5 z2 q+ J - if(dwCurrSize)$ j) [) c3 _6 R5 ~
- {5 r1 P$ F4 k8 }- `& @! g7 k
- Fp=fopen(szTempName,"wb");
% y% \/ W# ~! g+ A - if(!Fp)
2 N# n, v7 @' n& j - {
& d* \" I. o8 U% s+ @, ~ - _mkdir("DownLoad");' p. ^4 q. s% c3 P! `3 X
- Fp=fopen(szTempName,"wb");
+ F. d5 @3 J8 [5 z - }
0 B1 @! Q9 ^0 L! s - if(Fp)
8 ?5 t/ \ |" A' }9 k [ - {
2 u. p3 L7 E2 O0 Q/ e+ X6 l( S - fwrite(Dn.szCompBuff,1,dwCurrSize,Fp);
" M* q% N3 ~/ t& {2 A - fclose(Fp);
/ N X X& P. x$ m0 a4 m* L. I - }! D6 ~! A8 `' G6 u6 }& m0 ?/ K5 o
- }; ]2 s! W( n9 b( z0 F: W/ ]0 Q
- if(!bSilentStep)* c0 z2 Y) B' s0 W( }9 b: ~% V
- {' v- d( p5 X9 N
- if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
9 N& A( P6 W* l2 f - dlg->m_ListText.AddString(strFileName+".....saving"); v2 u7 |' X$ F j2 T3 L- a1 V
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
6 Z, r& p/ I5 S U) ] - }( S$ r" g' b% s! U2 t7 g
- if(bCompressed)
( _( I- ]; G# K - {
5 Q) G& r# J6 |& h, R! @6 `, Q - int opt_overwrite=1;8 X6 f) Z, f/ F/ z! k
- int opt_do_extract_withoutpath=0;3 `9 t$ ^: T1 R1 s
- unzFile uf=NULL;' T8 Q4 j: X. T) Y7 f
- uf=unzOpen(szTempName);8 Q4 X2 l/ R \ F
- if(uf), J/ K1 n3 r4 H
- {
/ ^4 O8 N+ M8 s& o - if(!bSilentStep): F9 l y- S0 b3 i3 F& G
- {
9 D/ |, K3 X1 U - if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
) t2 T0 G( ?% y- z5 ], u - dlg->m_ListText.AddString(strFileName+".....extracting");
7 _6 M$ ~1 I& V/ X$ ~ - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
8 _! Y% L! r- n; g - }
8 r, ~6 h' y& F. c8 R) | - if(do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,(char*)(LPCTSTR)strFilePath,NULL)==UNZ_OK)2 H& r% a2 X1 N0 z2 }0 d% L; P& C
- {3 V) i: i1 O5 I- W- f& U1 c% J
- if(!bSilentStep)
9 Q: H+ ?* ~9 A& ^$ T8 R2 C - {! ~% `0 q0 r1 g5 V
- if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
( c- R6 i5 Z5 L8 s% m6 \' ^9 @& T) z1 R - dlg->m_ListText.AddString(strFileName+".....done");5 c" X, H+ v3 r+ }; y
- dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);
/ s) i+ K, p6 n( q9 | - }
7 K4 ?$ |, L+ G; M, n* j3 B0 z - dwDownLoaded++;
% v6 B' M; D/ x/ M* n6 @ - dwProgramState=AP_NOTHING;& {$ j; h4 i- L# U: p
- }! `, B3 J0 c( g& E' W
- else
. _5 u$ J7 T: I% P+ O1 O - {
L* D% Z: w1 x& n: o7 S( W - dwProgramState=AP_CONNECT;
$ N! x; `( n! Y" \: R - }
6 t& y6 p* k. W- o: r; ^- l6 R: C - unzClose(uf); J C1 x( |% N9 F
- }
0 y9 n+ @" P9 _4 o" { - else
% X: C" x' ?. _, N, c/ b - {
, q1 d, z) D( P" x' s - dwProgramState=AP_CONNECT;
$ g6 Z) v4 F9 j. D7 w$ l - }
, u' N/ y6 \6 ?8 q' n7 a - unlink(szTempName);
6 W0 u( g+ V/ l& q4 N0 h - }. v, E1 M+ x. S" t$ r- q8 R0 A
- else# w$ Y4 I* K* e1 e
- {
4 |& _ O4 B8 L7 e& |4 ` - if(!bSilentStep)
9 a& O* A* i$ \, o1 Z6 }5 p - {
7 O3 Z0 G' q8 ]# M7 u1 @ - if((Count=dlg->m_ListText.GetCount())!=LB_ERR) dlg->m_ListText.DeleteString(Count-1);
7 m3 n" P& }4 _: W. z - dlg->m_ListText.AddString(strFileName+".....done");
) ?- V5 y+ G. W" O; e - dlg->m_ListText.SetCurSel(dlg->m_ListText.GetCount()-1);* J' \ @4 L4 p: Z
- }( N6 x! C! @5 L: N% X8 _9 ~
- dwDownLoaded++;
3 w/ i- h) R7 ^ - dwProgramState=AP_NOTHING;9 C5 R8 L. m" t# b% K: D7 C* A7 J2 l
- }
. t) L# r g6 b0 y% E4 S - Dn.QuitNWSSock();
! a) N) d. F7 [0 A! h. f - }
: e2 X3 l* Z; v - }: h5 [' J# M! _2 q
- else
' B$ C$ h& f5 B" V# W6 E - {% P8 A$ j( I: ?7 o. O4 |+ m
- // Connect Timeout% }- z# P7 y1 x6 Z
- if(GetTickCount()-LastTickCount>30000)
Q1 Y# ?0 f+ a, e0 _5 \ - {
1 c' T9 F1 u0 v3 } - Dn.QuitNWSSock();: ^3 g- V2 L! m% U. p7 y9 M: _% M
- if(dwCurrSize) dwProgramState=AP_RESUMED;
* `4 R2 {7 E0 A/ }/ z- U - else dwProgramState=AP_CONNECT;+ ^& {& y8 d M1 x
- }
; ?8 Q/ ]+ t" V - }
8 J' s; o) g& w& y& D - }- \6 u9 B1 e1 l( Q2 s) l
- break; @( n% B) S: A# e) l
- }
* _# z x( r: I/ `: N: z7 \ - return CWinApp::OnIdle(lCount); s, {9 R0 c! N; K8 a7 h
- }# ?* T: ]9 P w/ |# L
複製代碼 其实登陆器也就是这么一回事儿……
* _, A, N" d& n, T1 Z! ^' r S附件有编译教程和源码
% q9 V' S* w3 m* g( ^( }. d2 `4 w% s0 J0 f( ^ y# g
b& D- n/ W2 \8 d; ]% Z4 f |