Click here to Skip to main content
15,923,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using jeffrey richters's example 22 LastMsgBoxInfoLib, modified to hook User32.dll's SetClipboardData and GetClipboardData functions. But the hooking process fails. My idea is that the following call is not correct.
g_hhook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc,
ModuleFromAddress(LastMsgBoxInfo_HookAllApps), dwThreadId);
What should be first two parameters, that I pass to the above mentioned SetWindowsHookEx, so that I can capture clipboard events and copy paste commands?
Thanks
Bikram...
Posted
Comments
Sergey Alexandrovich Kryukov 3-Jul-11 19:11pm    
Any link to the example you refer to?
--SA

It is clear from http://msdn.microsoft.com/en-us/library/ms644990(v=vs.85).aspx[^]. Your first to parameters are correct, the last two parameter depend on where you want to handle the message, please see explanation of these parameters and remarks. Both parameters of NULL is the most usual use.

You capture WH_GETMESSAGE, and the messages will be filtered by the message IDs in your message hook procedure you're installing.

—SA
 
Share this answer
 
Comments
bikramthapa 4-Jul-11 15:18pm    
Hi SAKryukov,
Here is the link to the project example I used.
http://www.wintellect.com/Downloads/Windows%20via%20C++%20Code%20(December%201,%202007).zip
The project are 22-LastMsgBoxInfo and 22-LastMsgBoxInfoLib. The sample code works, so, I simply modified the code example to replace MessageBox with SetClipboardData and GetClipboardData.
I put Messagebox("Replacement Function Called") in the SetClipboardData and GetClipboardData replacement functions, so that I know my code is getting called when clipboard content is changed or accessed.
My idea is that the two clip board functions are not getting hooked. So what ever copy paste I do after I load the dll in my app, the two replacement functions never get called.
I am using VS 2005 pro sp1 with latest Platform SDK on Windows XP SP3 machine. The purpose of my task is to make sure that when my app runs; The clipboard content can only be copied to list of app I have. Also I dont want to use SetClipboardViewer or similar technique as it does not fulfill my need.

I would really appreciate if you can provide any help.

Thanks
Bikram...
Sergey Alexandrovich Kryukov 5-Jul-11 1:58am    
Thank you for the links; I'll try to look but cannot tell when I can get time for that, sorry.

Now, did you try to use my answer, MSDN help page and write the Windows Hook by yourself? Is it a global hook or application-wide? Writing and debugging hooks is not easy at all, so no wonder you can face problems...
--SA
Hi SAKryukov,

I was able to get it working, it was a silly mistake at my end,
I declared the hooking function with wrong parameters,
(HANDLE hMem, UINT uFormat) instead of
(UINT uFormat ,HANDLE hMem).

Regards
Bikram...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900