Thread: SetConsoleCtrlHandler

  1. #31
    Registered User
    Join Date
    Jan 2016
    Posts
    12
    This is a nice piece of work; I don't hope your teeth ache too much! What I do not understand, is where the names are stored that were input.

  2. #32
    Registered User
    Join Date
    Dec 2010
    Location
    Trinidad, CO (log cabin in middle of nowhere)
    Posts
    148
    I didn't bother storing them at all. That's basically another endeavor completely unrelated to the idea of attempting to create with C or C++ a console mode program that the user can't close with CTRL_C or Ctrl Break. As an aside, I tried a reverse "Hello, World!" program using C++'s iostream cin, and that terminates immediately, i.e., it exits the function, terminates the app, closes the console too, just like fgets() from C Std. Lib., which I'd ordinarily use. I don't know much about iostream, cin, cout, etc., since I don't use them. Maybe there is some easy way to alter that behavior. Wouldn't know.

    For myself, I never worried if a user ended a program incorrectly because the loss of data would be his/her fault, the way I see it. The way I look at it, if the user lost a pile of data through doing that, maybe it would teach him/her a lesson.

    I'll say this though, attempting to create a bullet proof end user application using the console instead of a GUI is much, much, harder, for reasons such as we've been working on here. I expect the reasons a lot of us old timers put some effort into it though is that when we left DOS for Windows back in the 90s we had all this knowledge built up for creating from raw DOS really fancy apps with menus, mouse capabilities, etc. I know for myself I had taught myself assembler, and was calling all the DOS interrupts to do things bnot directly supported by C or basic. In other words, we had become such masters of that old environment we wanted to carry those application designs over into the 32 bit Windows world, and these console mode functions within Windows gave us a method for doing that. But when we all finally taught ourselves to create GUI applications, which is what Windows was create for, we all saw it was much easier than the console mode for creating applications, and one didn't have to deal with these arcane and bizarre console mode functions such as SetConsoleMode(), ReadConsoleInput(), WaitForSingleObject(), etc., etc..

    But getting back to your question, to save (persist) the names, you would just have to write them to a file.

    Oh! By the way, I added back space functionality to that, and removed the x / y coordinates from Input(). What I did was create a Locate() function like in basic.

    Usually at some time or other I find uses in my work for code such as I developed here in attempting to help you. A long time ago I sunk like a week into helping someone here in the C/C++ world reading/writing Excel spreadsheets. But here about two years ago, when it became clear that PowerBASIC was done for with the death of Bob Zale, I started to convert all my mission critical code from PowerBASIC to C++, and had dire need of that COM automation code I had developed for someone.
    Last edited by freddie; 01-12-2016 at 07:38 AM.

Popular pages Recent additions subscribe to a feed