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