|
|
Can One Make an Executable that Runs Both in a DOS Shell and As a Graphical Program?
I'm a bad Windows programmer (I need to find time to read all the books I
should be reading), but here goes my question ... try not to beat on me too
bad.
I've written small utilities, such as this one:
http://esrg.sourceforge.net/utils_win_up/md5sum/
There is both a command-line version (linked to on the page), and a
graphical version (also linked to on the page).
It is possible they could be combined ...
Is it possible to write a Windows program that will run both as a
console-mode program and as a graphical program?
For example, I might want a program that if one types:
"md5sum filename"
then it will calculate and output the hash information in the DOS shell.
But if I type:
"md5sum /g"
it would open up a window and let you graphically specify the files and
perhaps other options.
Is it possible to write a single executable that will behave both ways?
If so, how?
Thanks for all.
|
|
0
|
|
|
|
Reply
|
Datesfat
|
2/1/2010 3:17:32 PM |
|
Hi,
you already answered your question yourself:
Write a console program and read its parameters.
When you get a /g then create a Dialog and Display
it to the user. You could also write the application
a non console app and when you do "not" get a /g on
the command line, then you could allocate a windows
console and output all stuff there. There are many ways,...
On a console window you could create the dialog from
a DialogResource by using CreateDialog(...) or DialogBox(...)
and then handle all you want in the dialog box procedures.
On a Win32 subsystem app (Window) you could allocate
a console by using AllocConsole() and the GetStdHandle()
then use I/O functuons like Write/ReadFile or the Console
output ones to write your output to that console,...
Do not to cleanup everything used before to avoid leaks!
Reading books (and MSDN!) is highly recommended,...*g*
Regards
Kerem
--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"Datesfat Chicks" <datesfat.chicks@gmail.com> schrieb im Newsbeitrag
news:Vt-dnR-gBdoTbfvWnZ2dnUVZ_vOdnZ2d@giganews.com...
> I'm a bad Windows programmer (I need to find time to read all the books I
> should be reading), but here goes my question ... try not to beat on me
> too bad.
>
> I've written small utilities, such as this one:
>
> http://esrg.sourceforge.net/utils_win_up/md5sum/
>
> There is both a command-line version (linked to on the page), and a
> graphical version (also linked to on the page).
>
> It is possible they could be combined ...
>
> Is it possible to write a Windows program that will run both as a
> console-mode program and as a graphical program?
>
> For example, I might want a program that if one types:
>
> "md5sum filename"
>
> then it will calculate and output the hash information in the DOS shell.
>
> But if I type:
>
> "md5sum /g"
>
> it would open up a window and let you graphically specify the files and
> perhaps other options.
>
> Is it possible to write a single executable that will behave both ways?
>
> If so, how?
>
> Thanks for all.
|
|
0
|
|
|
|
Reply
|
Windows
|
2/1/2010 3:56:18 PM
|
|
Windows console is not a DOS Shell.
--
Q: What do monsters eat?
A: Things.
Q: What do monsters drink?
A: Coke. (Because Things go better with Coke.)
|
|
0
|
|
|
|
Reply
|
Donkey
|
2/1/2010 4:10:46 PM
|
|
"Kerem G�mr�kc�" <kareem114@hotmail.com> wrote in message
news:hk6tj0$g7v$03$1@news.t-online.com...
>
> you already answered your question yourself:
> Write a console program and read its parameters.
> When you get a /g then create a Dialog and Display
> it to the user. You could also write the application
> a non console app and when you do "not" get a /g on
> the command line, then you could allocate a windows
> console and output all stuff there. There are many ways,...
>
> On a console window you could create the dialog from
> a DialogResource by using CreateDialog(...) or DialogBox(...)
> and then handle all you want in the dialog box procedures.
>
> On a Win32 subsystem app (Window) you could allocate
> a console by using AllocConsole() and the GetStdHandle()
> then use I/O functuons like Write/ReadFile or the Console
> output ones to write your output to that console,...
I'll look up the functions you recommended.
The nature of my question is that I've only read a few tutorial books, and
the ones I've read always have one create a Windows GUI application using
Visual Studio. This has the event loop and everything already created for
you ... I'm not sure enough of everything that is happening under the hood
to start with a console app and then have it create all that stuff that is
normally pre-created.
In other words, I've done horses, and I've done donkeys; but this is my
first mule.
Datesfat
|
|
0
|
|
|
|
Reply
|
Datesfat
|
2/1/2010 4:29:09 PM
|
|
> Windows console is not a DOS Shell.
Indeed!
--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"Donkey Hottie" <donkey@fred.pp.fi> schrieb im Newsbeitrag
news:71bj37-0lu.ln1@wellington.fredriksson.dy.fi...
>
> Windows console is not a DOS Shell.
>
>
> --
> Q: What do monsters eat?
> A: Things.
>
> Q: What do monsters drink?
> A: Coke. (Because Things go better with Coke.)
|
|
0
|
|
|
|
Reply
|
Windows
|
2/1/2010 5:36:23 PM
|
|
Hi,
visual studio does a trick, that is: use the same application name, but use
..exe extension for the GUI program and .com for the console program.
If either is started, see if the gui or console is reauired and if wrong,
start the other binary.
--
------------------------------------
Gernot Frisch
http://www.glbasic.com
|
|
0
|
|
|
|
Reply
|
Gernot
|
2/4/2010 11:01:59 AM
|
|
|
5 Replies
261 Views
(page loaded in 0.078 seconds)
|
|
|
|
|
|
|
|
|