#include "stdafx.h"
#include <Windows.h>
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
POINT curpos; //在内存中,具体的说应该是在栈中而不是堆中申请了一个内存,内存大小不知道.
while (1) //无限循环
{
GetCursorPos(&curpos); //函数GetCursorPos把获得的鼠标位置数据放在&curpos首地址的地方.用的是取地址符号.因为curpos不是指针变量.
printf("x=%d,y=%d,", curpos.x, curpos.y);
Sleep(300); //每300毫秒取一次鼠标的地址.
}
return 0;
}
BOOL GetCursorPos( LPPOINT lpPoint );
Parameters
lpPoint
[out] Long pointer to a POINT structure that receives the screen coordinates of the cursor.
//lpPoint 为长指针,这个指针是指向POINT 的结构体的.
//这个机构体接收屏幕坐标系的鼠标/光标位置数据的
Return Value
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
//返回值类型为BOOL型
//返回非零的数表示获取屏幕光标位置成功.如果返回的是0,表示获取屏幕光标位置失败.
typedef struct tagPOINT { LONG x; LONG y; } POINT;//POINT 为机构体,里面有两个参数,屏幕光标X坐标和y坐标.
This structure defines the x- and y-coordinates of a point.//这个机构体定义一个点的x/y的坐标.