_getch() implementation

D

Daz

Hi everyone.

I am trying to find out how _getch() works, as I need to use something
similar, but as well as looping for the first keyboard char pressed, I
also need to check to see if any application is still running within
the same loop also.

I have tried to find the code for _getch(), but I can only find:
_CRTIMP __checkReturn int __cdecl _getch_nolock(void);
in the conio.h header file. This is clearly the decleration, but I
can't find the implementation of it.

I would appreciate it if anyone could shed any light on the subject.

Finest regards.

Daz
 
D

Daz

Daz said:
Hi everyone.

I am trying to find out how _getch() works, as I need to use something
similar, but as well as looping for the first keyboard char pressed, I
also need to check to see if any application is still running within
the same loop also.

should read:
I am trying to find out how _getch() works, as I need to use something
similar, but as well as looping for the first keyboard char pressed, I
also need to check to see if AN application is still running within
the same loop also.

Basically, if a particular application is closed manually, my program
should break the loop, and go onto the next stage of the process.
 
A

analizer

Implementation of _getch is defined here:
($VCIntallPart)\Crt\Src\getch.c
Probably you should implement message processing loop to hadle
keystrokes.
 
I

Ian Collins

Daz said:
Hi everyone.

I am trying to find out how _getch() works, as I need to use something
similar, but as well as looping for the first keyboard char pressed, I
also need to check to see if any application is still running within
the same loop also.

I have tried to find the code for _getch(), but I can only find:
_CRTIMP __checkReturn int __cdecl _getch_nolock(void);
in the conio.h header file. This is clearly the decleration, but I
can't find the implementation of it.

I would appreciate it if anyone could shed any light on the subject.
Try a windows group, it isn't standard C++.
 
D

Daz

Implementation of _getch is defined here:
($VCIntallPart)\Crt\Src\getch.c
Probably you should implement message processing loop to hadle
keystrokes.

Excellent! I have found it, and now I just have to understand it. :)

Thanks for your help.
 
D

Daz

Ian said:
Try a windows group, it isn't standard C++.

Thanks Ian! This is quite frustrating for me, as I can never seem to
tell if something is platform specific, or general C++. How do I tell?

Thanks.
 
A

analizer

Excellent! I have found it, and now I just have to understand it. :)

It depends on WinApi console functions. If you have non-console
applications then message processing loop will be better solution, you
just need to implement WM_CHAR message handling.
 
R

red floyd

Daz said:
Thanks Ian! This is quite frustrating for me, as I can never seem to
tell if something is platform specific, or general C++. How do I tell?

1. If it uses CamelCase, it's probably WinAPI or some other platform
specific, but definitely not part of the Standard.
2. If it has a leading underscore, it's implementation specific.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top