Ok Thanks all, here is the newly updated code, which one again has the following problems.
Compiling OS
----------------
XP-Runs only under NT based systems, illegal ops in 9x
-Detects files properly on NT based OS's
9X-Runs under all OS's but always says the files dont exist.
-Detects files properly on NT based OS's
Heres the updated code:
Code:
#include <sys/stat>
#include <conio>
#include <process>
#include <iostream>
using namespace std;
bool fileExists (char * fileName);
void Launch(char * FileName);
int askDir(void);
int determineDir(void);
bool LookFiles(void);
int main(void) {
bool Install;
Launch("cls");
Install=LookFiles();
cout << endl << endl;
if (Install)
{
cout << "Files Have Finished Installing. Press Any Key To Continue" << endl;
getch();
}
else
{
cout << "No Files Were Installed, Ending Application" << endl;
}
execl("utilities","utilities",(char *)0);
return (0);
}
bool fileExists (char * fileName)
{
struct stat buf;
int i = stat ( fileName, &buf );
if ( i == 0 )
{
return true;
}
return false;
}
void Launch(char * FileName)
{
system(FileName);
}
int askDir(void)
{
char answer;
answer='0';
while ((answer != '1') && (answer != '2'))
{
cout << "Both WinNT and Windows directory exist!" << endl;
cout << "Please choose which directory Windows is installed in." << endl;
cout << endl;
cout << "1) Windows" << endl;
cout << "2) WinNt" << endl << endl;
answer=(char)getch();
if (answer=='1')
{
return(1);
}
else if (answer=='2')
{
return(2);
}
else
{
Launch("cls");
cout << "Invalid Response" << endl << endl;
}
}
return(0);
}
int determineDir(void){
if (fileExists("C:\\Windows") && fileExists("C:\\Winnt"))
{
//printf("Both WINNT and WINDOWS directory exist");
return(3);
}
else if(fileExists("C:\\Windows"))
{
//printf("Windows Directory Only");
return(1);
}
else if(fileExists("C:\\Winnt"))
{
//printf("Winnt Directory Only");
return(2);
}
return(0);
}
bool LookFiles(void)
{
int i=determineDir();
bool install;
install=false;
if (i==3)
{
i=askDir();
}
if (i==1)
{
if (fileExists("C:\\Windows\\msvbvm60.dll") || fileExists("C:\\Windows\\system32\\msvbvm60.dll"))
{
cout << "Visual Basic Runtimes Found, Skipping Installation" << endl;
}
else
{
Launch("vbrun60sp5.exe");
cout << "Visual Basic Runtimes Installed" << endl;
install=true;
}
if (fileExists("C:\\Windows\\mscomctl.ocx") || fileExists("C:\\Windows\\system32\\mscomctl.ocx"))
{
cout << "Microsoft Common Controls Found, Skipping Installation";
cout << endl;
}
else
{
Launch("missingfilesetup.exe");
cout << "Common Controls Installed" << endl;
install=true;
}
if (fileExists("C:\\Windows\\talctl32.ocx") || fileExists("C:\\Windows\\system32\\tabctl32.ocx"))
{
cout << "Microsoft Tab Control Found, Skipping Installation" << endl;
}
else
{
Launch("tabinstall.exe /silent");
cout << "Tab Control Installed" << endl;
install=true;
}
}
if (i==2)
{
if (fileExists("C:\\WinNT\\msvbvm60.dll") || fileExists("C:\\WinNT\\system32\\msvbvm60.dll"))
{
cout << "Visual Basic Runtimes Found, Skipping Installation" << endl;
}
else
{
Launch("vbrun60sp5.exe");
cout << "Visual Basic Runtimes Installed" << endl;
install=true;
}
if (fileExists("C:\\WinNT\\mscomctl.ocx") || fileExists("C:\\WinNT\\system32\\mscomctl.ocx"))
{
cout << "Microsoft Common Controls Found, Skipping Installation" << endl;
}
else
{
Launch("missingfilesetup.exe");
cout << "Common Controls Installed" << endl;
install=true;
}
if (fileExists("C:\\WinNT\\talctl32.ocx") || fileExists("C:\\WinNT\\system32\\tabctl32.ocx"))
{
cout << "Microsoft Tab Control Found, Skipping Installation" << endl;
}
else
{
Launch("tabinstall.exe /silent");
cout << "Tab Control Installed" << endl;
install=true;
}
}
return(install);
}