CODE:#define NULL 0
#define FALSE 0
#define INTERNET_OPEN_TYPE_PRECONFIG 0
#define INTERNET_DEFAULT_HTTPS_PORT 443
#define INTERNET_SERVICE_HTTP 3
#define INTERNET_FLAG_SECURE 8388608
#define INTERNET_FLAG_NO_CACHE_WRITE 67108864
#define GWL_HINSTANCE -6
#define WS_VISIBLE 268435456
#define WS_CHILD 1073741824
#define PBM_SETRANGE 1025
#define PBM_SETPOS 1026
#define PBS_SMOOTH 1
#define PBM_SETBARCOLOR 1033
#define PBM_SETBKCOLOR 8193
external(INT, "InternetOpen", "InternetOpenA", "Wininet.dll");
external(INT, "InternetConnect", "InternetConnectA", "Wininet.dll");
external(INT, "HttpOpenRequest", "HttpOpenRequestA", "Wininet.dll");
external(INT, "HttpSendRequest", "HttpSendRequestA", "Wininet.dll");
external(INT, "InternetReadFile", "InternetReadFile", "Wininet.dll");
external(INT, "InternetCloseHandle", "InternetCloseHandle", "Wininet.dll");
external(INT, "CreateWindow", "CreateWindowExA", "User32.dll");
external(INT, "GetWindowLong", "GetWindowLongA", "User32.dll");
int Size_Bute=35000;//Сколько байт ждем
int histance, progress_bar1, progress_bar2;
createdialog(0);
showdialog(0, "Загрузка ресурсов", 100, 100, 400, 100, 1, 1);
///////////////////////////////////////////////////////////////////
int Size_B;
string fr;
int read_b=50; //Какими порциями и с какой скоростью загружать 1024
enabletimer(0);
load();
disabletimer(0);
sendmessage(PBM_SETPOS, Size_B, 0, formatiw(progress_bar2));
messagebox ("Загружено "+format(Size_B)+" байт");
messagebox (fr);
/////////////////////////////////////////////////////////////////////////////////
CREATE_TIMER(0, 10)//Номер таймера, выполнение таймера через мсек.
{
sendmessage(PBM_SETPOS, Size_B, 0, formatiw(progress_bar2));
}
function getmessage(0, WM_CREATE)
{
histance=GetWindowLong(gethwnd(0), GWL_HINSTANCE);
progress_bar2=CreateWindow(0, "msctls_progress32", "", PBS_SMOOTH | WS_VISIBLE | WS_CHILD, 5, 15, 380, 25, gethwnd(0), 0, histance, 0, 0);
sendmessage(PBM_SETRANGE, 0, 0+Size_Bute*65536, formatiw(progress_bar2)); // минимальное и максимальное значение (от 0 до Size_Bute)
sendmessage(PBM_SETBARCOLOR, 0, 14130224, formatiw(progress_bar2));///черная полоса
sendmessage(PBM_SETBKCOLOR, 0, 12631996, formatiw(progress_bar2));/// красный фон
}
function load()
{
Size_B=0;
fr="";
int hInternet = InternetOpen(
"My bot",
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,NULL,
0);
if (hInternet != NULL) // открываем HTTP сессию
{
int hConnect = InternetConnect(
hInternet,
"kibor-bot.com",
INTERNET_DEFAULT_HTTPS_PORT,
NULL,NULL,
INTERNET_SERVICE_HTTP,
0,
1);
if (hConnect != NULL)
{
int hRequest = HttpOpenRequest(
hConnect,
"POST",
"forum",
NULL,
NULL,
0,
INTERNET_FLAG_SECURE | INTERNET_FLAG_NO_CACHE_WRITE,
1);
if (hRequest != NULL) // посылаем запрос
{
int bSend = HttpSendRequest(hRequest,
NULL,
0,
NULL,
0);
new char szData[read_b];
int dwBytesRead;
loop()
{
int bRead = InternetReadFile(
hRequest,
address(#szData[0]),
sizearray(szData)-1,
address(#dwBytesRead));
szData[dwBytesRead]=0;
fr=fr+format(#szData[0]);
Size_B=Size_B+dwBytesRead;
if (bRead == FALSE || dwBytesRead == 0) break;
}
delete szData;
InternetCloseHandle(hRequest);// закрываем запрос
}
InternetCloseHandle(hConnect);// закрываем сессию
}
InternetCloseHandle(hInternet);// закрываем WinInet
}
}