何かを貼り付けるたびに検出したい。これは、一部のデータ入力を簡単にするためのものです。グローバルフックを設定してから、wm_pasteを「待機」します。これは私が持っているコードの一部です:
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)//Do not process the message
return CallNextHookEx(msg_hook,nCode,wParam,lParam);
LPMSG m=(LPMSG)lParam;
if(m->message == WM_PASTE)
{
OutputString("Paste detected!\n");
}
if(m->message == WM_PASTE)
{
OutputString("Paste detected!\n");
}
return CallNextHookEx(msg_hook,nCode,wParam,lParam);
}
//DLL_ATTACH:
...
if(strstr(ProcName, LOADERNAME))
{
InitCommonControls();
if(!(msg_hook=SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, hinstDLL, 0)))
{
ErrorExit(TEXT("SetWindowsHookEx"));
//MessageBox(0, "WH_GETMESSAGE", 0, 0);
//return -1;
}
}
WM_PASTEデバッグ文字列が出力されることはありません。すべてのアプリケーションがWM_PASTEを使用しているわけではないことを認識しています。しかし、少なくともメモ帳は機能するはずです。
助言がありますか?ありがとう!