3,881
社区成员
发帖
与我相关
我的任务
分享
HINTERNET hInt = InternetOpenA( UA , INTERNET_OPEN_TYPE_DIRECT , NULL , NULL , 0 );
if( hInt == NULL ){
return 1;
}
HINTERNET hConn = InternetConnect( hInt , "dl.hdslb.com" , INTERNET_DEFAULT_HTTPS_PORT , NULL , NULL , INTERNET_SERVICE_HTTP , 0 , 0 );
if( hConn == NULL ){
return 1;
}
// https://dl.hdslb.com/mobile/latest/iBiliPlayer-bili.apk
HINTERNET hTar = HttpOpenRequestA( hConn , "GET" , "/mobile/latest/iBiliPlayer-bili.apk" , "HTTP/1.1" , NULL , NULL , INTERNET_FLAG_RELOAD , 0 );
if( hTar == NULL ){
return 1;
}
if( TRUE != HttpSendRequestA( hTar , NULL , 0 , NULL , 0 ) ){
return 1;
}
CHAR dwContLength1[200];
ZeroMemory( dwContLength1 , 200 );
DWORD dwContLenBufLen;
if( TRUE != HttpQueryInfo( hTar , HTTP_QUERY_CONTENT_LENGTH , dwContLength1 , &dwContLenBufLen , NULL ) ){
return 1;
}
DWORD dwContLength = atol(dwContLength1);
cout << "Buf length=" << dwContLenBufLen << endl;
cout << "Returned " << dwContLength1 << endl;
cout << "Length got!\n" << "app size=" << dwContLength << " Bytes\n" << "app size=" << dwContLength / (1024*1024) << " MiB\n";
InternetCloseHandle( hConn );
InternetCloseHandle( hInt );
getch();