Yeah thank you this what i need to do.. i need function to detect when my keyboard is connected or not. for example when my keyboard is disconnect it will show a msg that the keyboard has been unplugged and msg when its disconnect again..thank you very much
This is not the correct way going about this. why lock the screen if there is no input device?
Anyways, if it is a usb mouse and a usb keyboard, you might be able to use the RegisterDeviceNotification API to detect insertion or removal. I have done it with USB drives - and it should work similar.