1、获取屏幕分辨率
Windows API 获取屏幕分辨率 GetSystemMetrics ( )
int cxScreen = GetSystemMetrics (SM_CXSCREEN) ; // wide
int cyScreen = GetSystemMetrics (SM_CYSCREEN) ; // high
2、获取鼠标位置
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
VOID CALLBACK Timer(HWND, UINT, UINT_PTR, DWORD)
{
POINT p;
GetCursorPos(&p);
cout<<p.x <<" "<<p.y<<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
SetTimer(NULL, 1, 1000, Timer);
MessageBox(NULL, NULL, NULL, 0);
return 0;
}
Windows API获取屏幕分辨率与鼠标位置

这篇博客介绍了如何利用Windows API函数GetSystemMetrics获取屏幕的宽度和高度,以及通过SetTimer和GetCursorPos实现定时获取鼠标的位置。示例代码展示了在C++中如何实现这两个功能。
3241

被折叠的 条评论
为什么被折叠?



