作者在 2008-05-31 17:19:35 发布以下内容
void
OnDownload_thread(
void
*
p)
{
CClientDC dc( static_cast < CMainFrame *> (p));
dc.TextOut( 50 , 100 , " 正在下载最新版本迅雷,请等待 " );
char * Url = " http://down.sandai.net:8080/Thunder5.1.5.189.exe " ;
HINTERNET hSession = InternetOpen( " RookIE/1.0 " , INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if (hSession != NULL)
{
HINTERNET handle2 = InternetOpenUrl(hSession, Url, NULL, 0 , INTERNET_FLAG_DONT_CACHE, 0 );
if (handle2 != NULL)
{
printf( " %s\n " ,Url);
byte Temp[MAXBLOCKSIZE];
ULONG Number = 1 ;
FILE * stream;
if ( (stream = fopen( " d:\\Thunder5.1.5.189.exe " , " wb " )) != NULL ) // 这里只是个测试,因此写了个死的文件路径
{
while (Number > 0 )
{
InternetReadFile(handle2, Temp, MAXBLOCKSIZE - 1 , & Number);
// fprintf(stream, (const char*)Temp);
fwrite(Temp, sizeof ( char ), Number , stream);
}
fclose( stream );
}
InternetCloseHandle(handle2);
handle2 = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
// CClientDC dc(this);
dc.TextOut( 80 , 100 , " 下载完成。 " );
}
{
CClientDC dc( static_cast < CMainFrame *> (p));
dc.TextOut( 50 , 100 , " 正在下载最新版本迅雷,请等待 " );
char * Url = " http://down.sandai.net:8080/Thunder5.1.5.189.exe " ;
HINTERNET hSession = InternetOpen( " RookIE/1.0 " , INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
if (hSession != NULL)
{
HINTERNET handle2 = InternetOpenUrl(hSession, Url, NULL, 0 , INTERNET_FLAG_DONT_CACHE, 0 );
if (handle2 != NULL)
{
printf( " %s\n " ,Url);
byte Temp[MAXBLOCKSIZE];
ULONG Number = 1 ;
FILE * stream;
if ( (stream = fopen( " d:\\Thunder5.1.5.189.exe " , " wb " )) != NULL ) // 这里只是个测试,因此写了个死的文件路径
{
while (Number > 0 )
{
InternetReadFile(handle2, Temp, MAXBLOCKSIZE - 1 , & Number);
// fprintf(stream, (const char*)Temp);
fwrite(Temp, sizeof ( char ), Number , stream);
}
fclose( stream );
}
InternetCloseHandle(handle2);
handle2 = NULL;
}
InternetCloseHandle(hSession);
hSession = NULL;
}
// CClientDC dc(this);
dc.TextOut( 80 , 100 , " 下载完成。 " );
}