1
void
OnDownload_thread(
void
*
p)
2
{
3
CClientDC dc( static_cast < CMainFrame *> (p));
4
dc.TextOut( 50 , 100 , " 正在下载最新版本迅雷,请等待
" );
5
6
char * Url = " http://down.sandai.net:8080/Thunder5.1.5.189.exe " ;
7
HINTERNET hSession = InternetOpen( " RookIE/1.0 " , INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
8
if (hSession != NULL)
9
{
10
HINTERNET handle2 = InternetOpenUrl(hSession, Url, NULL, 0 , INTERNET_FLAG_DONT_CACHE, 0 );
11
if (handle2 != NULL)
12
{
13
printf( " %s\n " ,Url);
14
byte Temp[MAXBLOCKSIZE];
15
ULONG Number = 1 ;
16
17
FILE * stream;
18
if ( (stream = fopen( " d:\\Thunder5.1.5.189.exe " , " wb " )) != NULL ) // 这里只是个测试,因此写了个死的文件路径
19
{
20
while (Number > 0 )
21
{
22
InternetReadFile(handle2, Temp, MAXBLOCKSIZE - 1 , & Number);
23
// fprintf(stream, (const char*)Temp);
24
fwrite(Temp, sizeof ( char ), Number , stream);
25
}
26
fclose( stream );
27
}
28
29
InternetCloseHandle(handle2);
30
handle2 = NULL;
31
}
32
InternetCloseHandle(hSession);
33
hSession = NULL;
34
}
35
36
37
// CClientDC dc(this);
38
dc.TextOut( 80 , 100 , " 下载完成。 " );
39
}

2



3

4


5

6

7

8

9



10

11

12



13

14

15

16

17

18

19



20

21



22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39
