Forums Gallery Downloads LOGIN |REGISTER

How to launch a external exe inside Cryengine?

Please use this forum for questions on C++, Lua, XML, and any other languages used in CryENGINE development.


 

User avatar
wanggogo
Developer
Developer
 
Posts: 208
Member since: 27.10.2008, 12:02
Location: CHINA
Likes: 2

How to launch a external exe inside Cryengine?

Postby wanggogo » 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
beast
Senior Developer
Senior Developer
 
Posts: 903
Member since: 11.10.2011, 18:41
Location: Germany
Likes: 10

Re: How to launch a external exe inside Cryengine?

Postby beast » 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
wanggogo
Developer
Developer
 
Posts: 208
Member since: 27.10.2008, 12:02
Location: CHINA
Likes: 2

Re: How to launch a external exe inside Cryengine?

Postby wanggogo » 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
hendrik
Producer
Producer
 
Posts: 1326
Member since: 29.05.2010, 11:46
Location: Germany
Likes: 163

Re: How to launch a external exe inside Cryengine?

Postby hendrik » 21.08.2012, 23:58

exit() in C/C++
or "quit" in commandline.
User avatar
wanggogo
Developer
Developer
 
Posts: 208
Member since: 27.10.2008, 12:02
Location: CHINA
Likes: 2

Re: How to launch a external exe inside Cryengine?

Postby wanggogo » 22.08.2012, 07:52

Thanks hendrikp! I will give it a try.
User avatar
wanggogo
Developer
Developer
 
Posts: 208
Member since: 27.10.2008, 12:02
Location: CHINA
Likes: 2

Re: How to launch a external exe inside Cryengine?

Postby wanggogo » 27.11.2012, 17:01

I put these lines into PlayerInput.cpp:
Code: Select all
    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: Select all
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
sunnlok
Senior Developer
Senior Developer
 
Posts: 809
Member since: 19.04.2009, 01:21
Location: Germany
Likes: 123

Re: How to launch a external exe inside Cryengine?

Postby sunnlok » 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


 
Connect and collaborate with CRYENGINE developers in the official Forums.
Visit the Gallery to share what you have created and be inspired by what others are creating with CRYENGINE.
Community