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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Trouble w/ ReadConsoleInput

Trouble w/ ReadConsoleInput

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++visual-studiographicsdata-structures
2 Posts 2 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.
  • C Offline
    C Offline
    CoffeeAddict19
    wrote on last edited by
    #1

    The error I'm getting: 1>c:\users\john\documents\visual studio 2008\projects\torch\torch\main.cpp(18) : error C2065: 'lpBuffer' : undeclared identifier I've seen plenty of examples where ReadConsoleInput is setup to read only 1 INPUT_RECORD and then return, but I'm trying to set it up so that if multiple events occur at once, so they will be placed into a vector array instead. The trouble is that everything stops once ReadConsoleInput starts and I have no easy way of referencing the variable to be stored. Here is my code:

    #include "includeall.h"

    using namespace std;

    int main(int argc, char **argv)
    {
    HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD NumRead;
    BOOL eventloop = FALSE;
    vector<INPUT_RECORD>InputRecs;

    printf("Welcome to Bloodhound 1.0a (torch).\\n");
    printf("Press the ESC key at any time to exit.\\n");
    
    do
    {
    	 X| if(ReadConsoleInput(hIn, InputRecs.push\_back(lpBuffer), (DWORD)InputRecs.capacity(), &NumRead) != 0)
    	{
    		//sort through events
    	}
    	else //error is present
    	{
    		printf("Unable to read from console error number (%d)", GetLastError());
    		printf(".\\n");
    		eventloop = FALSE;
    	}
    	InputRecs.clear();
    }while(eventloop == TRUE);
    
    
    
    return 0;
    

    }

    Ideas?

    D 1 Reply Last reply
    0
    • C CoffeeAddict19

      The error I'm getting: 1>c:\users\john\documents\visual studio 2008\projects\torch\torch\main.cpp(18) : error C2065: 'lpBuffer' : undeclared identifier I've seen plenty of examples where ReadConsoleInput is setup to read only 1 INPUT_RECORD and then return, but I'm trying to set it up so that if multiple events occur at once, so they will be placed into a vector array instead. The trouble is that everything stops once ReadConsoleInput starts and I have no easy way of referencing the variable to be stored. Here is my code:

      #include "includeall.h"

      using namespace std;

      int main(int argc, char **argv)
      {
      HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
      HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
      DWORD NumRead;
      BOOL eventloop = FALSE;
      vector<INPUT_RECORD>InputRecs;

      printf("Welcome to Bloodhound 1.0a (torch).\\n");
      printf("Press the ESC key at any time to exit.\\n");
      
      do
      {
      	 X| if(ReadConsoleInput(hIn, InputRecs.push\_back(lpBuffer), (DWORD)InputRecs.capacity(), &NumRead) != 0)
      	{
      		//sort through events
      	}
      	else //error is present
      	{
      		printf("Unable to read from console error number (%d)", GetLastError());
      		printf(".\\n");
      		eventloop = FALSE;
      	}
      	InputRecs.clear();
      }while(eventloop == TRUE);
      
      
      
      return 0;
      

      }

      Ideas?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      CoffeeAddict19 wrote:

      Ideas?

      Yes. You need to declare lpBuffer.

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      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