Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] How to open a program with C++

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Flabbergasted
Expert Cheater
Reputation: 0

Joined: 11 Oct 2007
Posts: 231
Location: I have alzheimer's.

PostPosted: Sat Feb 16, 2008 1:46 pm    Post subject: [Help] How to open a program with C++ Reply with quote

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 Smile
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Feb 17, 2008 1:30 pm    Post subject: Reply with quote

Look up the API: CreateProcess, or ShellExecute.

You can find all the API and such listed on MSDN's website.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
ShurikeN
Advanced Cheater
Reputation: 0

Joined: 09 Jan 2008
Posts: 84

PostPosted: Sun Feb 17, 2008 5:46 pm    Post subject: Reply with quote

#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
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Feb 17, 2008 5:54 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
ShurikeN
Advanced Cheater
Reputation: 0

Joined: 09 Jan 2008
Posts: 84

PostPosted: Sun Feb 17, 2008 6:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Feb 17, 2008 6:08 pm    Post subject: Reply with quote

Unicode
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Feb 17, 2008 10:07 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Feb 18, 2008 9:46 am    Post subject: Reply with quote

wxExecute();
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Feb 18, 2008 8:14 pm    Post subject: Reply with quote

Jani wrote:
wxExecute();


Which would require the person to be using the wxWidget library. You should inform them of that if you are going to suggest it. Wink

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Feb 19, 2008 11:20 am    Post subject: Reply with quote

Wiccaan wrote:
Jani wrote:
wxExecute();


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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Wed Feb 20, 2008 7:21 pm    Post subject: Reply with quote

Jani wrote:
Wiccaan wrote:
Jani wrote:
wxExecute();


Which would require the person to be using the wxWidget library. You should inform them of that if you are going to suggest it. Wink

You can find all the API and such listed on wxWidgets' website.

Are you happy now? Razz Googling shouldn't be so hard...


You know the people on these forums wont google for help. Wink

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites