PDA

View Full Version : C++ and Passwording Files


intel17
02-22-2006, 03:07 PM
Right this will be my first C++ Programme. I would like to create a programm that will ask the user for a pass number and then if they give the correct pass number, they will be able to se the files (or atleaset Bring up the files) and if they have got the number wrong, then it will write it to a log.

so far I have created an "if" statment, so that when the user enters "23" it says "{cout<<"you got it right, welcome to my Files\n";" and if they get it wrong it writes it to a file but the file only writes it once

What I would Like to know is how do I get it that when the user enters the correct number it will bring up the files in windows, like say "My Documents" or just issue a command into Command Prompt.

here is the Code:



#include <iostream>
#include <fstream>

using namespace std;

int main()
{
int thisisanumber;

cout<<"Please enter pass number: ";
cin>> thisisanumber;
cin.ignore();
if ( thisisanumber == 23 ) {cout<<"you got it right, welcome to my Files\n"; // this is where i would like it to issue a command promt command, if that is possible
}

else if ( thisisanumber != 23 ) {
cout<<"Denied!\n"; {
ofstream myfile ("example.txt");
if (myfile.is_open())
{
myfile << "" << thisisanumber << " is not the Number!\n";
myfile << "Atempt Denied\n";
myfile << "--------------\n";
myfile.close();
}
else cout << "Unable to open file"; }
}
cin.get();
return 0;
}



I am useing Dev-C++ Beta
Thanks for reading,
Pete

SpirtOfGrandeur
02-22-2006, 05:12 PM
You would have to create a hook to all things run through explorer. There are two ways of doing this. One is an API and the other is through the registry. The registry one can be hacked if you can change the registry. The API one would have to be running on a service that was monitoring the pipe to see if there is a call to explorer.

Either way, I am not one to go into details about this because there are a lot of things that can be done with the information that can be used in adware/viruses and I do not feel correct in helping people with this info unless I know their motives are true.