PDA

View Full Version : استفاده کردن از دستورات داس



dada_vahid
پنج شنبه 12 خرداد 1390, 23:17 عصر
با سلام دوستان ارجمند من می خواستم بدونم برای اینکه بتونم از دستورات داس استفاده کنم باید از چه بخشی از کتابخانه c++ استفاده کنم ممنونم

یوسف زالی
جمعه 13 خرداد 1390, 03:22 صبح
سلام.
تا اونحا که یادمه یه کتابخونه به اسم Dos.h داشت.

ehp_kz6597
جمعه 13 خرداد 1390, 05:56 صبح
سلام
ببین این کارت رو راه میندازه




system
------------------------------------------------------------
int system ( const char * command );

Execute system command
Invokes the command processor to execute a command. Once the command execution has terminated, the processor gives the control back to the program, returning an int value, whose interpretation is system-dependent.

The function call also be used with NULL as argument to check whether a command processor exists.

Parameters

command
C string containing the system command to be executed.


Return Value
The value returned when the argument passed is not NULL, depends on the running environment specifications. In many systems, 0 is used to indicate that the command was succesfully executed and other values to indicate some sort of error.
When the argument passed is NULL, the function returns a nonzero value if the command processor is available, and zero otherwise.

Portability
The behavior and return value are platform-dependent.



Example


/* system example : DIR */
#include <stdio.h>
#include <stdlib.h>

int main ()
{
int i;
printf ("Checking if processor is available...");
if (system(NULL)) puts ("Ok");
else exit (1);
printf ("Executing command DIR...\n");
i=system ("dir");
printf ("The value returned was: %d.\n",i);
return 0;
}

dada_vahid
جمعه 13 خرداد 1390, 10:19 صبح
تشکر میتونی در مورد کدها توضیح مختصری بدی؟؟؟

dada_vahid
جمعه 13 خرداد 1390, 10:21 صبح
من اگه بخوام مثلا دستور ping معروف رو پیاده سازی کنم باید چه کار کنم؟؟؟

ehp_kz6597
جمعه 13 خرداد 1390, 14:42 عصر
اون متن بالای سورس درواقع توضیحاتش هست
ولی دردسرت ندم ، اون کد رو بیخیال
همش اینه که باید از تابع system() استفاده کنی
فکر کردم که نمونه کد کارت رو راحت تر میکنه
این یه مثال ساده تر که هم نحوه کارش دستت بیاد هم به جواب سوال دومت برسی
//واضحه که به جای اون x ها باید ip مورد نظر رو وارد کنین


#include<windows.h>
int main()
{
system("ping xxx.xxx.xxx.xxx")
return 0;
}

dada_vahid
شنبه 14 خرداد 1390, 22:01 عصر
آقا خیلی باحالی دمت گرم فقط اگه بخوام کاربر Ip رو وارد کنه باید چه کار کنم فقط روش کار رو بگو کد نمی خوام

یوسف زالی
دوشنبه 16 خرداد 1390, 01:36 صبح
IP رو تو رشته ازش بگیر دیگه.
بعد الحاق کن به رشته ای که توش ping هست.

dada_vahid
دوشنبه 16 خرداد 1390, 20:29 عصر
تشکر عزیز که پاسخ سوال من رو دادی