Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How to call Win32 API functions SetClipBoardViewer, ChangeClipboardChain, etc, from C++ .NET app

How to call Win32 API functions SetClipBoardViewer, ChangeClipboardChain, etc, from C++ .NET app

Scheduled Pinned Locked Moved Managed C++/CLI
csharphelptutorialc++json
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    largenqcd
    wrote on last edited by
    #1

    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

    G L 2 Replies Last reply
    0
    • L largenqcd

      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

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      These links can help you: P/Invoke[^]

      #region signature my articles #endregion

      1 Reply Last reply
      0
      • L largenqcd

        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

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups