Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i send a dos app paramaters

Status
Not open for further replies.

aaroncox

Programmer
Jun 28, 2006
2
0
0
AU
hi

i want to get the ip of a website that is entered into an Edit1 (singe line text box) here is my code in Button1:
AnsiString xxx = Edit1->Text;
system("ping " + xxx);

I get an error message on system("ping " + xxx); how would i get passed this?

once i have gotten past the error message i want to record the output. how would i do this?

i am fairly new to c++ builder, that is the only way i can thin of to get the info. is there any windows api command that would give me simular results or am i on the right track?

thanks in advance
 
What does the error message say? You may have to pass the AnsiString as a character array.
Code:
system("ping " + xxx.c_str());

Otherwise you can try ShellExecute, ShellExecuteEx, or CreateProcess but they are more complex.

James P. Cottingham
-----------------------------------------
[sup]I'm number 1,229!
I'm number 1,229![/sup]
 
The problem is that the function system requires a pointer to char, but you are giving her a AnsiString.
Try:
system(strcat("ping ",xxx.c_str()));

Because you can't add to pointers to char, i'm guessing that's the error you got when using "ping "+xxx.c_str().

If you wan't to record the output, you could create a log file with the output of "ping..." like this:

system(strcat(strcat("ping ",xxx.c_str())," > event.log"));

However, I'm not quite sure how you can hide the shell window, during the process of the command.
 
thanks for your help i really appreciate it... it worked well
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top