system() param

Started by
7 comments, last by Pipo DeClown 21 years, 1 month ago
What would I write in system(...) to get it to launch a executable with parameters(for the executable)? .lick
Advertisement
system( "executable.exe arg1 arg2" );


"If there is a God, he is a malign thug."
-- Mark Twain
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
You could use ShellExecute

  int main(){ShellExecute(NULL,"open","notpade.exe mydoc.txt",NULL,NULL);return 0;}  
Luke, the function takes 6 parameters!!!
What the code thén?

.lick
quote:Original post by Pipo DeClown
Luke, the function takes 6 parameters!!!
What the code thén?


ShellExecute(GetStdHandle(STD_OUTPUT_HANDLE), "open", "myExecutable.exe", "-param1 is_this", "C:\Space\Chocolate\etc", SW_SHOWNORMAL);


Passing null to the directory argument will result in opening the file from the current directory. Passing null to the parameter argument opens the file without passing any parameters.

I think you can use system(), but I'm not exactly sure how. Maybe the start command.

[ Google || Start Here || ACCU || MSDN || STL || GameCoding || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on March 6, 2003 1:05:02 PM]
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || [email=lektrix@barrysworld.com]E-Mail Me[/email] ]
O sorry bout that didnt notice here try this:

    int main(){ShellExecute(NULL,"open","notepad.exe mydoc.txt",NULL,NULL,SW_SHOW);}    


[edited by - Luke1 on March 6, 2003 1:06:34 PM]
Thanks everyone!

.lick
system("Start C:\Programs\Program.exe") //you have tostate the full file name


Homepage
Luck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.
For any total noob out there Here is a like to my tutorials, thry them out
BoC HomepageLuck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.
I think it''s someting with the ''-''sign before the parameters, but in my version of XP(Pro) it works, but on the other versions of windows(9x, Home) it doesnt work.

.lick

This topic is closed to new replies.

Advertisement