Эксперт
Покинул форум
Сообщений всего: 4465
Дата рег-ции: Нояб. 2017
Репутация: 585
|
Узнать пинг (Отобразить)CODE:#define STARTF_USESHOWWINDOW 1
external(INT, "CreateProcess", "CreateProcessA", "Kernel32.dll");
external(INT, "WaitForSingleObject", "WaitForSingleObject", "Kernel32.dll");
external(INT, "CloseHandle", "CloseHandle", "Kernel32.dll");
#define INFINITE -1
int result;
result = ping("kibor-bot.com");
messagebox("ping = "+format(result));
result = ping("google.com");
messagebox("ping = "+format(result));
function ping(string website)
{
string tmp;
char c[99999];
PS("Test-NetConnection "+website+" | out-file -encoding ASCII "+tempfolder()+"ping.txt");
if(fopen(tempfolder()+"ping.txt", "rb"))
{
int count_sumbol=freadb(#c[0], sizearray(c))-1; fclose();
if(regexsearch(1, #tmp, format(#c[0], count_sumbol), "\d+(?= ms)", RIGHTTOLEFT ))return formatsn(tmp);
}
return -1;
}
function PS(string CommandLine)
{
int STARTUPINFOA[17], PROCESS_INFORMATION[4];
initialarray(#STARTUPINFOA[0], 0);
STARTUPINFOA[0]=68;
STARTUPINFOA[11]=STARTF_USESHOWWINDOW;
if(CreateProcess(0, "powershell.exe "+CommandLine, 0, 0, 0, 0, 0, 0, address(#STARTUPINFOA[0]), address(#PROCESS_INFORMATION[0])))
{
WaitForSingleObject(PROCESS_INFORMATION[0], INFINITE);
CloseHandle(PROCESS_INFORMATION[0]);
}
} |