DEBUG调试正常,直接运行程序有错误
#include "stdafx.h"
#include "WINDOWS.H"
#include "stdio.h"
int main(int argc, char* argv[])
{
HKL hkl;
HWND h = GetForegroundWindow();
printf("%08x\r\n",h);
DWORD a = GetWindowThreadProcessId(h,0);
printf("%08x\r\n",a);
hkl = GetKeyboardLayout(a);
char* s = new char[16];
_snprintf(s,16,"%08x",hkl);
printf("%s\r\n",s);
return 0;
}
这是我的程序代码,我下断点,单步执行能获取到HKL的值,但是直接运行程序却得到的00000000,莫名其妙的,请高手帮忙调试。