I would like to pass a COM method as a function argument but I get this error (Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80×86):
error C3867: ‘IDispatch::GetTypeInfoCount’: function call missing argument list; use ‘&IDispatch::GetTypeInfoCount’ to create a pointer to member
What am I missing?
Thank you very much.
#include <atlbase.h> void update( HRESULT(*com_uint_getter)(UINT*), UINT& u ) { UINT tmp; if ( S_OK == com_uint_getter( &tmp ) ) { u = tmp; } } // only for compile purpose, it will not work at runtime int main(int, char*[]) { // I choose IDispatch::GetTypeInfoCount just for the sake of exemplification CComPtr< IDispatch > ptr; UINT u; update( ptr->GetTypeInfoCount, u ); return 0; }
As morechilli pointed out this is a C++ issue. Here it is the solution, thanks to my colleague Daniele: