|
|
|
|
![]() ![]() |
Apr 14 2006, 05:51 AM
Post
#1
|
|
|
Newbie ![]() Group: Members Posts: 3 Joined: 14-April 06 Member No.: 21,823 |
Hi Guys!
this is a wonderful place.. although i wasnt a member till now i have referred to these forms quite a few times for my programming solns My problem is ::: I am writing a Code in C using Bloodshed Dev C++ 4.9.9.2 on Windows XP. I wanted to open an executable file from my code. After using the solution mentioned on these forums, I used QUOTE system("myprg"); It works fine.. But the prob is that i want my C program to execute this command and then return to the next statement without waiting for me to close the program "mrprog.exe".. Right now wat happens is suppose my code is: QUOTE system("myprog.exe"); printf("Hello World"); ""Hello World" isnt printed on the screen till i exit the program myprog.exe Is there any function that can do this job??? Kindly help me plz! Thanx |
|
|
|
Apr 14 2006, 06:57 AM
Post
#2
|
|
|
Advanced Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 106 Joined: 1-April 06 Member No.: 21,148 |
As far as I know the only way to do what you want properly is to use threads and the fork and wait functions. Implimenting it is non-trivial, but if you really need to be able to do it, do a search for c, threads, and fork on google. You'll need to download an extra library and learn about interrupts. Alternatively, if you're running linux you might be able to get away with system("myprg &");
|
|
|
|
Apr 15 2006, 05:39 PM
Post
#3
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
On Windows then you should be able to use the command "start." I'm not sure if it would work in this context, but it does in command prompt- usually if you start a program or batch file, it does the same thing that you're talking about, but start runs it independently. This is what I would do:
CODE system("start /D. /B myprg"); /D. is the path, so if it's in a different directory, use /D"path to its directory"/B says not to make a new window. If it's a text based thing then take that out. |
|
|
|
Apr 30 2006, 06:59 PM
Post
#4
|
|
|
Newbie ![]() Group: Members Posts: 3 Joined: 14-April 06 Member No.: 21,823 |
Thanks a Zillion for the help guys
I will try out ur instructions n tell u if it works.. I'm keeping my fingers crossed!!! |
|
|
|
Apr 30 2006, 07:34 PM
Post
#5
|
|
|
Newbie ![]() Group: Members Posts: 3 Joined: 14-April 06 Member No.: 21,823 |
It works!!!!!!!!!!!!!!!!!!!!!!!!
well i tried QUOTE system("start /D. /B myprg"); N it worked to perfection... Thanks a lot Beeseven n Windandwater But there is a small new problem.. In my code written in C using Dev C++ created by Bloodshed (OS: Windows XP) i want to access the serial ports.. I.e send data to them in order to control a motor that is connnected to my computer... I know its easy to do that in win16 using turboC and function outportb()...but in win32 (i.e Dev C++) how do i do it??? I read some info on stuff like win API but a newbie like me found it really really confusing to do it.. are there any simples functions like outport() which i can use in my compiler??? Thanx a lot for all the help guys! Eagerly awaiting ur reply |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 07:46 PM |