Zdravím, jde jen pouze o kosmetickou úpravu programu, při tomto příkazu
system(("ping " + ip2 +"." +ret3+ "." +ret4+"."+i + " -n 1" + " -w 10 > data.txt" ).c_str());
problikne cmd, jde ho nechat nějak běžet na pozadí, nebo ho prostě jakkoliv skrýt, aby nebyl vidět?
Tady je případně celý program.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <stdio.h>
#include <conio.h>
#include <string>
#include <windows.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
char ret[20];
int x=0,y=0;
char ret2[20],ret3[20],ret4[20],ret5[20],ret6[20];
FILE *sou;
FILE *vys;
int n=0,rozsah=2,sta=1;
char slovo[20],slovo1[20]="bajty=32";
AnsiString ip2;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
strcpy(ret,Edit1->Text.c_str());
for (int i=0; i<=20;i++) {
if ((ret[i]=='0')||(ret[i]=='1')||(ret[i]=='2')||(ret[i]=='3')||(ret[i]=='4')||(ret[i]=='5')||(ret[i]=='6')||(ret[i]=='7')||(ret[i]=='8')||(ret[i]=='9'))
{
ret2[x]=ret[i];
x++;
}
else
{
x=i;
i=20;
}
}
x=x+1;
//------------------------------------------------
for (int i=x; i<=20;i++) {
if ((ret[i]=='0')||(ret[i]=='1')||(ret[i]=='2')||(ret[i]=='3')||(ret[i]=='4')||(ret[i]=='5')||(ret[i]=='6')||(ret[i]=='7')||(ret[i]=='8')||(ret[i]=='9'))
{
ret3[y]=ret[i];
y++;
}
else
{
y=i;
i=20;
}
}
y=y+1;
x=0;
//------------------------------------------------
for (int i=y; i<=20;i++) {
if ((ret[i]=='0')||(ret[i]=='1')||(ret[i]=='2')||(ret[i]=='3')||(ret[i]=='4')||(ret[i]=='5')||(ret[i]=='6')||(ret[i]=='7')||(ret[i]=='8')||(ret[i]=='9'))
{
ret4[x]=ret[i];
x++;
}
else
{
x=i;
i=20;
}
}
x=x+1;
y=0;
//------------------------------------------------
for (int i=x; i<=20;i++) {
if ((ret[i]=='0')||(ret[i]=='1')||(ret[i]=='2')||(ret[i]=='3')||(ret[i]=='4')||(ret[i]=='5')||(ret[i]=='6')||(ret[i]=='7')||(ret[i]=='8')||(ret[i]=='9'))
{
ret5[y]=ret[i];
y++;
}
else
{
y=i;
i=20;
}
}
y=y+1;
x=0;
//------------------------------------------------
for (int i=y; i<=20;i++) {
if ((ret[i]=='0')||(ret[i]=='1')||(ret[i]=='2')||(ret[i]=='3')||(ret[i]=='4')||(ret[i]=='5')||(ret[i]=='6')||(ret[i]=='7')||(ret[i]=='8')||(ret[i]=='9'))
{
ret6[x]=ret[i];
x++;
}
else
{
x=i;
i=20;
}
}
x=x+1;
//------------------------------------------------
vys=fopen("vysledek.txt","w");
sta=StrToInt(ret5);
rozsah=2;
n=32-StrToInt(ret6);
for(int i=1; i<n; i++){
rozsah=rozsah*2;
}
rozsah=rozsah+StrToInt(ret5);
ProgressBar1->Min=StrToInt(ret5);
ProgressBar1->Max=rozsah-1;
//------------------------------------------------
for(int i=StrToInt(ret5); i<rozsah; i++){
if(i<=255)
{
ProgressBar1->Position=i;
Label8->Caption=sta;
Refresh();
ip2 = ret2;
system(("ping " + ip2 +"." +ret3+ "." +ret4+"."+i + " -n 1" + " -w 10 > data.txt" ).c_str());
sou=fopen("data.txt","r");
while (!feof(sou))
{
fscanf(sou,"%s",&slovo);
if(!feof(sou))
{
if (strcmpi(slovo1,slovo)==0)
fprintf(vys,"Stanice %i ... OK\n",sta);
}
}
sta=sta+1;
fclose(sou);
}
}
fclose(vys);
Memo1->Lines->LoadFromFile("vysledek.txt");
system("del data.txt" );
system("del vysledek.txt" );
}
//---------------------------------------------------------------------------