Run Program?

Pages: 12
Apr 14, 2009 at 5:33am
How would I go about running a file like firefox or another program I created from a program i write? Is there code for this I can read about or someone can explain? Thank you!

~Mashed Pwntato
Apr 14, 2009 at 6:46am
which platform you are talking about?
Apr 14, 2009 at 7:38am
windows XP
Apr 14, 2009 at 9:01am
you can use

1. CreateProcess
2. shellexecute

both will do.
Apr 15, 2009 at 4:08pm
Okay so I didn't have Shell32.lib or Shellapi.h Which folder should I put these in? Also, where can I get Shell32.lib?
Last edited on Apr 15, 2009 at 4:16pm
Apr 16, 2009 at 10:08pm
Does anybody know? I'm completely stuck :/
Apr 16, 2009 at 10:51pm
Huh?
All compilers for Windows (except Cygwin, I think) include the WinAPI. You just need to #include <windows.h> and the compiler will do the rest. There's nothing to it.
Last edited on Apr 16, 2009 at 10:52pm
Apr 16, 2009 at 11:40pm
It comes up with an error saying that it can't find <windows.h>
Apr 16, 2009 at 11:43pm
Compiler?
Apr 16, 2009 at 11:45pm
I'm using Dev-C++
Last edited on Apr 16, 2009 at 11:45pm
Apr 16, 2009 at 11:53pm
That version includes windows.h, IIRC. Either I'm wrong and it doesn't, or your installation got screwed up. Try reinstalling it, or try using the compiler I sent you, which shouldn't give you any problems.
Last edited on Apr 16, 2009 at 11:54pm
Apr 17, 2009 at 12:10am
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;


int main () 
{
system ("echo 'Hello World'");

return 0;
}



You could replace "echo 'Hello World'" with say firefox.

i.e.

system ("firefox");

Hope this helps.
Apr 17, 2009 at 12:34am
Means that the program isn't portable though :(
Apr 17, 2009 at 12:40am
The Windows API isn't really portable, however.
Apr 17, 2009 at 6:44am
This is what I have gotten to now and it won't work! I've been trying to figure this out for forever and a half >:(
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <windows.h>
using namespace std;


int main() 
{
ShellExecute(hwnd,"open","Mozilla Firefox.exe",NULL,NULL,SW_SHOWNORMAL);
system("pause");
return 0;
}
Last edited on Apr 17, 2009 at 6:45am
Apr 17, 2009 at 8:27am
Try this:
WinExec("programname.exe",SW_SHOW);
note that you must to enter full path to your program.
Apr 19, 2009 at 11:05pm
Okay, so this is what I tried:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <windows.h>
using namespace std;


int main() 
{
WinExec("C:\Documents and Settings\Owner\Desktop\Mozilla Firefox.exe",SW_SHOW);
system("pause");
return 0;
}

It came up with [Warning] unknown escape sequence '/D'
[Warning] unknown escape sequence '/M'
[Linker error] undefined reference to '__cpu_features_init'
Id returned 1 exit status
Apr 19, 2009 at 11:14pm
'\' != '\\'

[Linker error] undefined reference to '__cpu_features_init'
Do you have two different installations of MinGW? That usually produces that linker error.
Apr 19, 2009 at 11:18pm
yeah, but I was still using Dev--c++. When I tried to install MinGW, I couldn't find the actual application to run. There doesn't seem to be a compiler or text editor or whatever there is supposed to be. I can't figure out how to use it...
Apr 19, 2009 at 11:37pm
The compilers are (of course) bin/g++.exe (C++) and bin/gcc.exe (C).
It's just the command line compiler. No IDE.
Pages: 12