稳定盈利的期货交易方法-量化趋势交易

alantop -专业量化投资者

爱好:量化投资,逆向工程,渗透
随笔 - 595, 文章 - 0, 评论 - 921, 引用 - 0
数据加载中……

通过http如何下载文件。

 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 }

posted on 2006-03-25 00:31 AlanTop 阅读(901) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理