Command Prompt or Windows

  • Thread starter Thread starter TBoon
  • Start date Start date
T

TBoon

Hi there,

A console application (.exe) can be executed at Command Prompt or Windows
(double-click).
Is there a way to detect whether if it is executed at CP or Windows?

regards,
Boon
 
Hello TBoon,

I believe your assumption is wrong. I'm fairly certain that you can not
operate in both console and GUI mode from a single app.
This effect is usually accomplished by providing a ".com" console app that
is the equivalent of the ".exe" GUI app. You can ask Windows for the launching
process.. search google or MSDN for details.

-Boo
 
GhostInAK said:
I believe your assumption is wrong. I'm fairly certain that you can
not operate in both console and GUI mode from a single app.

My guess was that he's only ever operating in console mode, but he wants to
tell whether his application was launched by someone opening a command
window and typing in "myapp.exe" in order to run in the existing window, or
by double-clicking the .exe in Windows so that it automatically opened a
console window to run the application.

The only way I could think to do this would be to see what the name of the
process that launched the application is (presumably it would be either
explorer.exe or cmd.exe) but I've no idea how one would find that
information.
 
Hello Oenone,

Unfortunately not everyone uses the Explorer shell or the cmd console. Some
people change their GUI shells (to somethink like Elightenment for Windows
or whatever) and some people use MSH instead of CMD.

Unless you can guarantee your target audience will always and forever use
explorer and cmd, you need to find another way. I don't have a way off the
top of my head.

-Boo
 
Back
Top