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. Casting a function pointer

Casting a function pointer

Scheduled Pinned Locked Moved Managed C++/CLI
c++question
2 Posts 2 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.
  • A Offline
    A Offline
    alleyes 0
    wrote on last edited by
    #1

    I have a function pointer with the following signature: typedef bool (__stdcall *CB_CheckStatus)(unsigned); When used as follows in a native app. bool __stdcall UpdateStatus(unsigned pctCompl) { printf("\r%d%%...", pctCompl); return false; } And as an parameter in a native function which uses it: DLLAPI HRESULT __stdcall ReadFile(size_t Size, BYTE* Buff, CB_CheckStatus UpdateStatus) Can I change the parameter as a void parameter? I want to map a delegate to this function pointer so I can utilize a BackgroundWorker for a mixed-mode wrapper How would you do that? Thanks

    N 1 Reply Last reply
    0
    • A alleyes 0

      I have a function pointer with the following signature: typedef bool (__stdcall *CB_CheckStatus)(unsigned); When used as follows in a native app. bool __stdcall UpdateStatus(unsigned pctCompl) { printf("\r%d%%...", pctCompl); return false; } And as an parameter in a native function which uses it: DLLAPI HRESULT __stdcall ReadFile(size_t Size, BYTE* Buff, CB_CheckStatus UpdateStatus) Can I change the parameter as a void parameter? I want to map a delegate to this function pointer so I can utilize a BackgroundWorker for a mixed-mode wrapper How would you do that? Thanks

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      Wrote this over 5 years ago, but it should be what you are looking for: Function pointers and Delegates - Closing the gap![^]

      Regards, Nish


      My technology blog: voidnish.wordpress.com Code Project Forums : New Posts Monitor This application monitors for new posts in the Code Project forums.

      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