/* If you modify this program at all please note what you changed This was written in Borland Turbo C++ 3.0 If you want do download the executable go to http://home.comcast.net/~sessions9/RAM-Drive.html */ #include #include #include #include #include void Title() { cout << "RAM-Drive version 1.0" << endl; cout << "Written by Robbie Sessions and Stephen Sessions" << endl; cout << "For full source code and required libraries go to" << endl; cout << "http://home.comcast.net/~sessions9/ramdrive.html" << endl; cout << "If you have any questions feel free to e-mail us at" << endl; cout << "dicepackage@hotmail.com with RamDrive as the subject" << endl; cout << "Press any key to go to the main menu" << endl; getch(); clrscr(); // system("cls"); } void Disclaimer() { cout << "This program can and will destroy your computer" << endl; cout << "if you use it wrong. Only use this program if you" << endl; cout << "know what you are doing. There is no guarantee that" << endl; cout << "this program will work. Be cautious, everything on" << endl; cout << "the RAM drive will get deleted if the computer reboots" << endl; cout << "Press any key to return to the main menu" << endl; getch(); clrscr(); // system("cls"); } void Instructions() { cout << "This is used to make a RAM drive on your computer." << endl; cout << "A RAM drive is a drive that runs off of the computers" << endl; cout << "RAM (Random Access Memory). The purpose of the drive" << endl; cout << "is to have a place to store files that works fast." << endl; cout << "The contents of the RAM drive get deleted after every" << endl; cout << "reboot. This makes it a good place to store temporary" << endl; cout << "files such as the internet cache and the Windows temp." << endl; cout << "The program will ask how large you want the RAM drive" << endl; cout << "to be. Do not use all of your RAM. It is recommended" << endl; cout << "that you use around 25% of your RAM. Windows 95 and" << endl; cout << "higher require at least 16 megabytes for a RAM drive." << endl; cout << "Press any key to return to the main menu" << endl; getch(); clrscr(); // system("cls"); } void View() { String Line; cout << endl; fstream File("C:\\config.sys", ios::nocreate | ios::in); if (File.fail()) // config.sys does not exist in the C drive { cout << "RamDrive was unable to open config.sys" << endl; cout << "Please check your C folder for config.sys" << endl; getch(); exit(0); } while (!File.eof() && getline(File,Line)) { cout << Line << endl; // Display the line } File.close(); cout << "Press any key to return to the main menu" << endl; getch(); clrscr(); // system("cls"); } int AddRamDrive() { long Megabytes; String File_Line; String RLine = "DEVICE=C:\\WINDOWS\\RAMDRIVE.SYS "; String HLine = "DEVICE=C:\\WINDOWS\\HIMEM.SYS"; fstream File("C:\\config.sys", ios::nocreate | ios::in | ios::out); if (File.fail()) // Creates config.sys if it doesn't exist { File.close(); fstream File2("C:\\config.sys",ios::out); File2 << ""; File2.close(); return(1); } cout << "Enter the number of Megabytes: "; cin >> Megabytes; Megabytes = Megabytes * 1024; vector Lines;//Create an array that stores each line in config.sys while (!File.eof()) { if (File.eof()) // if at the end of the file, break from loop break; Lines.resize(Lines.length()+1); getline(File, File_Line); //If the line does not contain RLine and is not HLine and is not blank if (File_Line.find(RLine) == npos && File_Line != HLine && File_Line !="") Lines[Lines.length()-1] = File_Line; // Add the line to the array } File.close(); fstream File2("C:\\config.sys",ios::out); // Makes the file empty File2 << HLine << endl << RLine << Megabytes << " /E" << endl; // Write the first lines to the file for (int i=0; i Lines; // Creates an array to store each line in the file int Himem = 1; // Boolean variable 1 is false 0 is true char choice; cout << "It is recommended that you keep your existing Himem.sys." << endl; cout << "If you don't know what Himem.sys is leave it in." << endl; cout << "Do you want to remove Himem.sys from config.sys (y/n)?: "; choice = getch(); cout << endl; if (choice == 'y' || choice == 'Y') Himem = 0; // Removes himem.sys from config.sys while (!File.eof()) { if (File.eof()) break; getline(File, File_Line); if (File_Line.find(RLine) == npos) { Lines.resize(Lines.length()+1); Lines[Lines.length()-1] = File_Line; } } File.close(); fstream File2("C:\\config.sys", ios::out); for (int i=0; i