From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Catching closing of stdio window in CVI7.0

I am using a 3rd party DLL which writes some debug messages to the stdio
window. Now if the user closes the stdio window (using the x button on
the stdio window), my CVI 7.0 application gets killed.

In my CVI application, I am handling the Main panel's closing but is
there any way to handle stdio window's events?

Any help is much appreciated.


vishi
0 Kudos
Message 1 of 3
(2,686 Views)
It's not quite what you were after, but it may solve your problem.

I had a similar problem with stdio, so I redirected it to a file.

I hope the following helps.
Richard.

------
/* Declare a pointer to store the 'real' stdout /*
FILE * stdout_old;

/* Save the 'real' stdout so we can put it back later */
stdout_old = stdout;

/* Open a debug file, and point stdout to it */
stdout = fopen("c:\debug.txt", "w");

/* run some code */
printf("This should appear in the debug file \n");

/* Close our debug file */
fclose(stdout);

/* Return stdout to the 'real' stdout */
stdout = stdout_old;
0 Kudos
Message 2 of 3
(2,686 Views)
If you're thinking about catching console events, try using the SetConsoleCtrlHandler to catch the console close event. make sure to include windows.h at the very top. You would need to have the Windows SDK for CVI installed for this.
Check out link for more information on the function.

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 3 of 3
(2,686 Views)