| View previous topic :: View next topic |
| Author |
Message |
Flabbergasted Expert Cheater
Reputation: 0
Joined: 11 Oct 2007 Posts: 231 Location: I have alzheimer's.
|
Posted: Sat Feb 16, 2008 1:46 pm Post subject: [Help] How to open a program with C++ |
|
|
Hey, I just was getting bored with batch programming so I wanted to know how to open a program or programs in C++ and make it say something like Starting... Could someone show me an example? Thanks
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Feb 17, 2008 1:30 pm Post subject: |
|
|
Look up the API: CreateProcess, or ShellExecute.
You can find all the API and such listed on MSDN's website.
_________________
- Retired. |
|
| Back to top |
|
 |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Sun Feb 17, 2008 5:46 pm Post subject: |
|
|
#include <windows.h>
int main()
{
ShellExecute(NULL,"open","C:\\Porn.exe",NULL,NULL,SW_SHOWNORMAL);
return 0;
}
_________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Feb 17, 2008 5:54 pm Post subject: |
|
|
| ShurikeN wrote: | #include <windows.h>
int main()
{
ShellExecute(NULL,"open","C:\\Porn.exe",NULL,NULL,SW_SHOWNORMAL);
return 0;
} |
| Code: | #include <windows.h>
#include <iostream>
int main(void)
{
std::cout << "Starting...\n";
ShellExecute( NULL,
L"open",
L"C:\\Porn.exe", // Program Path
NULL, NULL,
SW_SHOWNORMAL );
return 0;
} |
|
|
| Back to top |
|
 |
ShurikeN Advanced Cheater
Reputation: 0
Joined: 09 Jan 2008 Posts: 84
|
Posted: Sun Feb 17, 2008 6:06 pm Post subject: |
|
|
can i ask?? what's the purpose of "L" in your code?
| Code: | | L"open", L"C:\\Porn.exe", |
sorry i don't know anything about winapi.
_________________
| Code: | XXXXXX XXXXXX
XXXXX XXXXX
XXXXXXXX
D I R E C T
XXXXXXXX
XXXXX XXXXX
XXXXXX XXXXXX
GameDev
|
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Feb 17, 2008 6:08 pm Post subject: |
|
|
| Unicode
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun Feb 17, 2008 10:07 pm Post subject: |
|
|
Can just use _T( ) as well. You can also use CreateProcess instead of ShellExecute to have some more control of the process launching and such as well as obtaining info at launch if needed for things like injection.
_________________
- Retired. |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Mon Feb 18, 2008 9:46 am Post subject: |
|
|
| wxExecute();
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue Feb 19, 2008 11:20 am Post subject: |
|
|
| Wiccaan wrote: |
Which would require the person to be using the wxWidget library. You should inform them of that if you are going to suggest it. ;) |
You can find all the API and such listed on wxWidgets' website.
Are you happy now? :P Googling shouldn't be so hard...
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
|
| Back to top |
|
 |
|