How to call Win32 API functions SetClipBoardViewer, ChangeClipboardChain, etc, from C++ .NET app
-
Hi, I am a "hobby" programmer with a lot of familiarity with pre-.NET C++ programming in Windows, but not too much with .NET. I've written a Form based Windows application and want to set it up so that the app monitors changes to clipboard data. Therefore, I need to call the Win32 functions SetClipBoardViewer, etc. (Or is there another way to do this in .NET that I haven't found)? As far as I can tell, I need to use the PInvoke mechanism with declarations something like: [DllImport("User32")] static int SetClipboardViewer(int hWndNewViewer); (I would think these should be HWND's, but the above is what I found.) My problem is that I don't know the correct declarations for these functions, and I don't know how to set up the calls to them. I found an example for C# that shows how to do the whole process of setting up a clipboard monitoring application, but I really want to learn how to do this in C++. Any help would be appreciated! Thanks, Tom
-
Hi, I am a "hobby" programmer with a lot of familiarity with pre-.NET C++ programming in Windows, but not too much with .NET. I've written a Form based Windows application and want to set it up so that the app monitors changes to clipboard data. Therefore, I need to call the Win32 functions SetClipBoardViewer, etc. (Or is there another way to do this in .NET that I haven't found)? As far as I can tell, I need to use the PInvoke mechanism with declarations something like: [DllImport("User32")] static int SetClipboardViewer(int hWndNewViewer); (I would think these should be HWND's, but the above is what I found.) My problem is that I don't know the correct declarations for these functions, and I don't know how to set up the calls to them. I found an example for C# that shows how to do the whole process of setting up a clipboard monitoring application, but I really want to learn how to do this in C++. Any help would be appreciated! Thanks, Tom
These links can help you: P/Invoke[^]
#region signature my articles #endregion
-
Hi, I am a "hobby" programmer with a lot of familiarity with pre-.NET C++ programming in Windows, but not too much with .NET. I've written a Form based Windows application and want to set it up so that the app monitors changes to clipboard data. Therefore, I need to call the Win32 functions SetClipBoardViewer, etc. (Or is there another way to do this in .NET that I haven't found)? As far as I can tell, I need to use the PInvoke mechanism with declarations something like: [DllImport("User32")] static int SetClipboardViewer(int hWndNewViewer); (I would think these should be HWND's, but the above is what I found.) My problem is that I don't know the correct declarations for these functions, and I don't know how to set up the calls to them. I found an example for C# that shows how to do the whole process of setting up a clipboard monitoring application, but I really want to learn how to do this in C++. Any help would be appreciated! Thanks, Tom
largenqcd wrote:
As far as I can tell, I need to use the PInvoke mechanism
Not if you are using C++/CLI. You can mix native code with managed code. There are some caveats of course. See the Introductory articles here on CodeProject for C++/CLI developers. They should clear much of your questions up.
led mike