- just starting
- Posted by sterling.mckay@gmail.com on January 28th, 2007
Just started to teach myself C C++ programming... I have been very
interested with computers for a while now and have a nac or so I
thought for how they work ... hardware I am ok with ... I can
understand and tear it down and rebuild it ... chips boards I/O etc
etc ... programing is a different beast ...
So I am fooling around with C and compile a small .exe file with
Miracle C ... simple thing that said Hi my name is etc etc ... but I
noticed that it loads in a dos window ... Why doesn't it load in
a .txt file ? My main question is this ... after you run the test.exe
it flashes open the DOS window and closes quickly ... now this I
understand ... I do have my MCE and I am trained in Windows XP tech
support ... I know that a "close on exit" command is "checked" for the
application and I know to just open the default properties and de-
select the check box ...
My question is this ... is there a way in C or C++ to write this into
the test.exe I made that simply shows "my name is .... "
This is where I am a total newb and have no idea where to go ... I
don't see any reference to a switch or execute in any of the library
files ... the stdio.h or stdlib.h ... i don't see where i can say
the directory is C:\windir
the program is C:\windir\default
the program has a properties tab
the properties tab has Misc, etc etc ...
the misc tab has an option for "close on exit"
the "close on exit" should be false
I have no idea really ... i don't even know if it possible ... maybe
it's better to just reg hack it and save the batch file ...
Any ideas ? or I am way the hell off base ?
!
- Posted by Matthew Hicks on January 28th, 2007
Some options:
1. Write a batch file that runs the program and then ends with a PAUSE command
2. Read some input (i.e. getchar()) and then call return/exit in your program
code
3. Open cmd.exe and run the program from there
---Matthew Hicks
- Posted by Joe Wright on January 28th, 2007
sterling.mckay@gmail.com wrote:
further that default is a directory and your program is..
C:\windir\default\test.exe
I assume test.exe is a Console App which actually runs under cmd.exe,
the console command processor. When you double-click test.exe in
Explorer, Windows executes a pseudo command "cmd /c test.exe". As a
result cmd opens a 'DOS Box', executes test.exe and closes the DOS Box
as it exits. Note that test.exe does not have Windows properties.
While I am developing and testing Console Apps for Windows I do it at
the DOS Prompt. On your desktop, create a shortcut to (in my case)
c:\windows\system32\cmd.exe and name it DOS Prompt. Now edit the
shortcut properties to taste, e.g. tell it to stay open. Close the DOS
Prompt with the 'exit' command.
--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
- Posted by gw7rib@aol.com on January 28th, 2007
On 28 Jan, 04:24, sterling.mc...@gmail.com wrote:
Unfortunately, writing "proper" Windows programs is extremely
complicated. The book I am using, "Programming Windows" by Charles
Petzold, doesn't cover actually showing text until chapter three,
spending the first two chapters covering simpler stuff. What could
possibly be simpler, you are no doubt thinking - well, just creating a
window is not easy.
So you need to decide whether you are prepared to put in all this
effort, or whether you are happy to write what are in effect DOS
programs and have the system treat them as such.
Best of luck!
Paul.
- Posted by Jim Langston on January 31st, 2007
<sterling.mckay@gmail.com> wrote in message
news:1169958279.800511.264380@v33g2000cwv.googlegr oups.com...
Basically it sounds like you want to wait for a key to be pressed before the
DOS window closes. In C I would write:
while ( !kbhit() )
in C++ I would write:
std::cin.getch();
although the C++ method requires a carraige return.
- Posted by Alf P. Steinbach on January 31st, 2007
* Jim Langston:
'kbhit' is not a standard C function.
If it is available with your C compiler, it should also be available
with your C++ compiler from the same vendor.
There is no difference between C and C++ in this respect except that
/more/ (e.g. 'std::cin') is available in the C++ standard library.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?