Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Wednesday, January 06, 2016

Caps Lock State check before Password in C++

Caps Lock State check before Password in C++


Structure of the Problem Requirements  

The Program will generate a warning that Caps Lock is ON before entering the Password. GetkeyState function which is part of Windows API is used to detect the state of Caps Lock key. GetkeyState function retrieve the state of different keys.There have virtual key codes corresponding to each key in the keyboard.

Source Code

#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{ 
  string name;
  string password;
  cout<<" \t \t \t LEP Tutorials \n \n \n ";
  cout<<" Enter Your Name : ";
  
  cin>>name;
  if ((GetKeyState(VK_CAPITAL) & 0x0001)!=0)
      {
      
   cout<<(" \t \n  WARNING! Caps Lock ON \n \n ");
  cout<<" Enter Password  : ";
  
}
  cin>>password;
}

Output of the Program

Caps Lock State check before Password in C++
Share:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List