Hello,
I hope you are having a good day and thank you for taking the time to help me.
I am trying to write a program that opens a command prompt, waits for a number and ENTER then displays a picture then the command prompt closes, waits 5 seconds and then reopens the command prompt and repeats.
The problem is that I can't get the command prompt to close even though I have
system("exit"); in my program.
The reason why I need the command prompt to reopen is because I don't have the ability to select it (clink on it) before I enter the number and ENTER. ( a microcontroller is sending the number and ENTER and I can't select on the command prompt for the microcontroller).
Here is my program:
Code:#include "stdafx.h" #include <iostream> #include <windows.h> using namespace std; int main(void) { while(true) { int i; cout << "READY FOR INPUT: \n"; cin >> i; if(i==0) { system("exit"); HINSTANCE hInst = ShellExecute(NULL,"open","explorer","C:\\one.png",0,SW_SHOWMAXIMIZED); Sleep(5); } if(i==1) { system("exit"); HINSTANCE hInst = ShellExecute(NULL,"open","explorer","C:\\two.png",0,SW_SHOWMAXIMIZED); Sleep(5); } if(i==2) { system("exit"); HINSTANCE hInst = ShellExecute(NULL,"open","explorer","C:\\three.png",0,SW_SHOWMAXIMIZED); Sleep(5); } if(i==3) { system("exit"); HINSTANCE hInst = ShellExecute(NULL,"open","explorer","C:\\four.png",0,SW_SHOWMAXIMIZED); Sleep(5); } } }
My computer info:
64-bit Dell running Windows 7 OS.
Eventually, I am thinking of making an array when the number entered is the offset of the ShellExecute() command but that will come later.



2Likes
LinkBack URL
About LinkBacks



