Thread: Loging Program issue

  1. #1
    C++ newb in training
    Join Date
    Mar 2005
    Location
    Burlington Wa
    Posts
    14

    Loging Program issue

    Hey everyone. I did the tutorial for the Crude Logging program on Adrian's website and it compiles and runs just fine but the window closes imidiatly and I cant view anything. How could I fix this so I could actualy view the program results?

    Using Dev-C++ on WinXP Pro SP2

    Code:
     #include <windows.h>
    #include <iostream>
    using namespace std;
    int main()
    {
    	HANDLE hFind;
    	WIN32_FIND_DATA FindData;
    	int ErrorCode;
    	BOOL Continue = TRUE;
    	
    	cout << "A decent FindFirst/Next demo." << endl << endl;
    	
    	hFind = FindFirstFile ("C:\\Windows\\*.exe*", &FindData);
    	if (hFind == INVALID_HANDLE_VALUE)
    	{
    			  ErrorCode = GetLastError();
    			  if (ErrorCode == ERROR_FILE_NOT_FOUND)
    			  {
    				 cout<< "There are no files matching that path/mask\n" <<endl;
    			  }
    			  else
    			  {
    				 cout << "FindFirstFile() Returned Error Code " <<ErrorCode <<endl;
    			  }
    			  Continue= FALSE;
    	}
    	else
    	{
    		cout<< FindData.cFileName <<endl;
    }
    if (Continue)
    {
    			 while (FindNextFile (hFind, &FindData) )
    			 {
    				   cout <<FindData.cFileName <<endl;
    				   }
    				   ErrorCode == GetLastError();
    				   
    				   if (ErrorCode == ERROR_NO_MORE_FILES)
    				   {
    				   cout << endl << "All Files Logged." << endl;
    				   }			   
    				   else
    				   {
    				   cout << "FindNextFile() returned error code " << ErrorCode <<endl;
    			 } 
    			 if (!FindClose (hFind) )
    			 {
    				ErrorCode = GetLastError();
    				cout << "FindClose() returned error code " << ErrorCode <<endl;
    				}
    				
    }
    return 0;
    }
    Any idea's why it closes right after it opens?
    Find the loop holes, then fix the errors, after you have found all the useful info

  2. #2

  3. #3
    C++ newb in training
    Join Date
    Mar 2005
    Location
    Burlington Wa
    Posts
    14
    THanks.
    Find the loop holes, then fix the errors, after you have found all the useful info

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. matrix program issue, recursion
    By sweener2001 in forum C Programming
    Replies: 1
    Last Post: 04-28-2005, 04:28 AM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM