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