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