95 Differences

This is a discussion on 95 Differences within the C++ Programming forums, part of the General Programming Boards category; I wrote this program to invoke some systems commands to check my internet connection at work. Code: #include<iostream.h> #include<fstream.h> // ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    64

    95 Differences

    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.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    This is a pretty hackish and unefficient means of discovering if the internet works. Try learning sockets.

    google or beej's guide.

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    64
    I know its inefficient, thats not what i asked.

    Great thoughts though. be proud.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    3
    Here's a website with some code that does exactly what you are looking for (I hope). The code will terminate a process given the process name on win95/98/me/2k and xp according to the author. Check it out http://www.physiology.wisc.edu/ravi/software/killproc/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stdio differences windows vs linux
    By keira in forum C Programming
    Replies: 6
    Last Post: 09-14-2008, 05:42 PM
  2. Replies: 3
    Last Post: 08-12-2008, 11:18 PM
  3. differences between images
    By ^DJ_Link^ in forum C Programming
    Replies: 2
    Last Post: 02-21-2005, 08:03 AM
  4. Replies: 5
    Last Post: 11-24-2002, 11:33 PM
  5. I have figured out the differences between 95 and XP...
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 04-03-2002, 03:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21