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?