Win32判断当前进程是否激活(失去焦点)

DWORD GetCurrentActiveWindowsProcessId()  
{  
  HWND hWnd = GetActiveWindow();  
  DWORD processId = 0;  
  GetWindowThreadProcessId(hWnd, &processId);  
  return processId;  
}  

BOOL HasFocus() {
  DWORD active_process = GetCurrentActiveWindowsProcessId();
  DWORD current_process = ::GetCurrentProcessId();
  return current_process ==  active_process ;
}

你可能感兴趣的:(C/C++)