Author Topic: Is there a simple way to determine if compiled program is run from IDE  (Read 3729 times)

Offline Ken_SF

  • Single posting newcomer
  • *
  • Posts: 3
Hi,

I am using Code::Blocks 17.12 with C++ for Win32 programming.

Is there an easy way to determine if a compiled program was launched from the IDE or manually by clicking on the compiled program in its directory?

The best I have been able to come up with is to use Window's  GetCurrentDirectory function and see if the program was launched from my project directory or the Debug/Release directories that are created for me by Code::Blocks when I build a project from within the IDE.

Suggestions?


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
I would use arguments...

If you start the program in codeblocks, you add the argument -CB or similar in Project->Set programs argument and then in your program you check if the argument is present....
If you run it from the explorer you do not have the argument...

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Why do you need to know that?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]