Author Topic: Can I run a PE file that was attach into a project?  (Read 2459 times)

Offline Cloud_Strife_Han

  • Single posting newcomer
  • *
  • Posts: 8
Can I run a PE file that was attach into a project?
« on: March 18, 2018, 09:07:33 am »
Hi all,

I have a PE and I attached it into my project. How can I run this file by code?

I tried:
Code
system('filename.exe');

But it false.

I'm using CB 17.12. Windows7.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Can I run a PE file that was attach into a project?
« Reply #1 on: March 18, 2018, 10:22:12 am »
Your program does not know anything about the cb project. So adding the PE to the project makes no difference for your application.
Code
system('filename.exe');
i don't think that this compiles

If you do not use any path then your program is searching in the same directory as it runs for other files. So if you put the executable "filename.exe" near your application it should be found by your program.
If you are running your program from codeblocks there is something special:
Your program does not search in the same folder as your application, but in the folder specified by Project->Settings->Build targets->Execution working dir
By default this is the same folder where the project file is located.

TL:DR:
If you run your application by double clicking, all relative paths start from the same directory as your exe is in.
If you run your application from within codeblocks, all relative paths start from the directory of the project file