C++ を使用してマウスの画像を取得したかったのです。
How to get mouse cursor icon VS c++ questionから得たコードを使用しました。Visual Studio 2010 IDE を使用しました。C++ win32 プロジェクトを作成し、そのコード スニペットを _tmain メソッドに入力し、欠落している構造 (CURSORINFO および ICONINFO) も追加しました。プロジェクトをビルドした後、エラーコンソールが表示されます
error C2664: 'GetCursorInfo' : cannot convert parameter 1 from 'CURSORINFO *' to 'PCURSORINFO'
このビルド エラーの理由は何ですか。説明できますか?これは私が構築したコードです。
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
typedef struct _ICONINFO {
BOOL fIcon;
DWORD xHotspot;
DWORD yHotspot;
HBITMAP hbmMask;
HBITMAP hbmColor;
} ICONINFO, *PICONINFO;
typedef struct {
DWORD cbSize;
DWORD flags;
HCURSOR hCursor;
POINT ptScreenPos;
} CURSORINFO, *PCURSORINFO, *LPCURSORINFO;
HDC hdcScreen = GetDC(NULL);
HDC hdcMem = CreateCompatibleDC(hdcScreen);
CURSORINFO cursorInfo = { 0 };
cursorInfo.cbSize = sizeof(cursorInfo);
if (::GetCursorInfo(&cursorInfo))
{
ICONINFO ii = {0};
GetIconInfo(cursorInfo.hCursor, &ii);
DeleteObject(ii.hbmColor);
DeleteObject(ii.hbmMask);
::DrawIcon(hdcMem, cursorInfo.ptScreenPos.x - ii.xHotspot, cursorInfo.ptScreenPos.y - ii.yHotspot, cursorInfo.hCursor);
}
return 0;
}