469,900 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,900 developers. It's quick & easy.

Command Prompt or Windows

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
Oct 13 '06 #1
3 1218
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
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

Oct 13 '06 #2
GhostInAK wrote:
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.

--

(O)enone
Oct 13 '06 #3
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
GhostInAK wrote:
>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.

Oct 16 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by EAS | last post: by
2 posts views Thread by msuk | last post: by
3 posts views Thread by Rog | last post: by
4 posts views Thread by glenn | last post: by
9 posts views Thread by Endless Story | last post: by
4 posts views Thread by bkamrani | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.