I wrote this program to invoke some systems commands to check my internet connection at work.
Code:
#include<iostream.h>
#include<fstream.h> // for file io
#include<windows.h> // For system commands
int main()
{
// declare a variable for opening a file
ofstream OpenFile;
// issue a system command to invoke the SGET program
system("SGET http://www.sophos.com/downloads/ide/ides.zip") ;
// find and open the file ides.zip
OpenFile.open("ides.zip", ios::nocreate);
// if the file is not present
if (!OpenFile)
{
// invoke the drop.HAW program
cout << "Internet disabled. Attempting to reconnect." << endl ;
system("drop.HAW") ;
return 0 ;
}
// file is present
else
{
// connection is good do nothing return success
cout << "Internet connection detected." << endl ;
return 0 ;
}
return 0 ;
} // main
This program works fine. The problem is that the program drop.HAW, which is a HyperACCESS program is left open. Since the program won't finish until the Hyper access window closes my program never finishes.
To counter this, i wrote another program that issues a close command to the window.
Code:
#include <windows.h> // library for windows specific calls
int main()
{
// find window name and close it
HWND hHyper = FindWindow(NULL, "drop.HAW - HyperACCESS");
SendMessage(hHyper, WM_CLOSE, 0, 0);
// find window name and close it
HWND hDos = FindWindow(NULL, "Finished - Checknet");
SendMessage(hDos, WM_CLOSE, 0, 0);
// return success
return 0 ;
}
This worked fine on my test computer which has windows 2000 installed. but when i run it on the intended computer which has windows 95 it doesn't close my open windows. It's all done with scheduling.
So, anyway, what i want to know is why this doesn't work on windows 95 and how can i fix this?
Another thing is that i really don't want to have to schedule two programs to accomplish one task, is there another way in which i can modify the first program to close the windows itself.
Cheers guys.