Programming & Scripting

View unanswered posts | View active topics


Post a new topicPost a reply
Previous topic | Next topic 

User avatar   Trained Modder Trained ModderMember since: 27.10.2008, 12:02Posts: 201Location: CHINA Likes: 2
 

 Post Topic: How to launch a external exe inside Cryengine?
PostPosted 21.08.2012, 09:24 
hello everyone!
I want to achieve a function that launch a extenal exe via press key or click a button? So how can I do that?
Any suggestion will be appreciateļ¼

User avatar   Hardcore Modder Hardcore ModderMember since: 11.10.2011, 18:41Posts: 903Location: Germany Likes: 10
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 21.08.2012, 09:52 
Hi,

check CreateProcess of winbase.h

see: http://msdn.microsoft.com/en-us/library ... 85%29.aspx

greets,
Oliver
User avatar   Trained Modder Trained ModderMember since: 27.10.2008, 12:02Posts: 201Location: CHINA Likes: 2
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 21.08.2012, 11:22 
I'm new to c++ :cheesy: . Thanks for share the info and another question - If I want to close the ce3(or minimize launcher window) after I launch another application. So how can I do that?
User avatar   Uber Modder Uber ModderMember since: 29.05.2010, 11:46Posts: 1252Location: Germany Likes: 147
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 21.08.2012, 23:58 
exit() in C/C++
or "quit" in commandline.


User avatar   Trained Modder Trained ModderMember since: 27.10.2008, 12:02Posts: 201Location: CHINA Likes: 2
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 22.08.2012, 07:52 
Thanks hendrikp! I will give it a try.
User avatar   Trained Modder Trained ModderMember since: 27.10.2008, 12:02Posts: 201Location: CHINA Likes: 2
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 27.11.2012, 17:01 
I put these lines into PlayerInput.cpp:
Code:
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );
    CreateProcess( NULL,"E:\\Program Files (x86)\\Notepad++\\notepad++.exe",NULL,NULL,FALSE, 0,NULL,  NULL, &si, &pi );


But I get these error informations in the output window after complie

Code:
2>  PlayerInput.cpp
2>PlayerInput.cpp(1233): error C2065: 'STARTUPINFO' : undeclared identifier
2>PlayerInput.cpp(1233): error C2146: syntax error : missing ';' before identifier 'si'
2>PlayerInput.cpp(1233): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1234): error C2065: 'PROCESS_INFORMATION' : undeclared identifier
2>PlayerInput.cpp(1234): error C2146: syntax error : missing ';' before identifier 'pi'
2>PlayerInput.cpp(1234): error C2065: 'pi' : undeclared identifier
2>PlayerInput.cpp(1235): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1235): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1235): error C2070: ''unknown-type'': illegal sizeof operand
2>PlayerInput.cpp(1235): error C3861: 'ZeroMemory': identifier not found
2>PlayerInput.cpp(1236): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1236): error C2228: left of '.cb' must have class/struct/union
2>          type is ''unknown-type''
2>PlayerInput.cpp(1236): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1236): error C2070: ''unknown-type'': illegal sizeof operand
2>PlayerInput.cpp(1237): error C2065: 'pi' : undeclared identifier
2>PlayerInput.cpp(1237): error C2065: 'pi' : undeclared identifier
2>PlayerInput.cpp(1237): error C2070: ''unknown-type'': illegal sizeof operand
2>PlayerInput.cpp(1237): error C3861: 'ZeroMemory': identifier not found
2>PlayerInput.cpp(1242): error C2065: 'FALSE' : undeclared identifier
2>PlayerInput.cpp(1242): error C2065: 'si' : undeclared identifier
2>PlayerInput.cpp(1242): error C2065: 'pi' : undeclared identifier
2>PlayerInput.cpp(1242): error C3861: 'CreateProcess': identifier not found


What is wrong? help
User avatar   Skilled Modder Skilled ModderMember since: 19.04.2009, 01:21Posts: 731Location: Germany Likes: 100
 

 Post Topic: Re: How to launch a external exe inside Cryengine?
PostPosted 27.11.2012, 17:41 
Using create process is a bit more complex then just throwing in those functions you have there.
It doesnt just start an .exe file like windows normaly does when you click something.

Here is a little example how an exe starter with the CreateProcess function looks like.

http://pastebin.com/57xKEe0d
And dont forget to declare the functions in the header file.
http://pastebin.com/S7gSN4n9

Use shell execute if you dont want it that complicated.

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153(v=vs.85).aspx