string bind = "Hello"; for (int i = 0; i < bind.length(); i++) { short ch = VkKeyScanA(bind[i]); if (((ch & 0xff00) >> 8) & 0x1) { std::cout<<" This is uppercase"<<std::endl; } else { std::cout<<" This is lowercase"<<std::endl; } }
先通过VkKeyScanA将字母转换位相应的虚拟键码的字符,再通过&和移位来判断。
补充: ' H ' -> 0x148 ' h ' -> 0x48
(ch & 0xff00) >> 8 -> (0x0148 & 0xff00) >> 8 -> 0x0100 >> 8 -> 0x01
再 & 0x1 判断是否为1