Search code examples
c++comc++17visual-studio-2019

Converting 32-Bit COM interface to 64-Bit


I am trying to convert/upgrade a 32-Bit COM file to compile as 64-Bit. I have fixed all of the bugs except for one. Here is the code in question:

HRESULT WINAPI QueryIMEDDevice(void *pV, REFIID riid, LPVOID *pPV, DWORD dw)
{
  return DTQueryIMEDDevice(reinterpret_cast<CNIDAQmx *>(pV), riid, pPV, dw);
}

BEGIN_COM_MAP(CNIDAQmx)
  COM_INTERFACE_ENTRY(INIDAQmx)
  COM_INTERFACE_ENTRY(IObjectControl)
  COM_INTERFACE_ENTRY(IObjectConstruct)
  COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  COM_INTERFACE_ENTRY(ISupportErrorInfo)
  COM_INTERFACE_ENTRY_FUNC_BLIND(0, QueryIMEDDevice)
  COM_INTERFACE_ENTRY2(IDispatch, IMEDADC)
  COM_INTERFACE_ENTRY(IMEDADC)
END_COM_MAP()

Here is the error message:

error C2440: 'initializing': cannot convert from 'HRESULT (__cdecl *)(void *,const IID &,LPVOID *,DWORD)' to 'ATL::_ATL_CREATORARGFUNC (__cdecl *)'
message : None of the functions with this name in scope match the target type

I hope that I have provided enough info. Please let me know if there is any other info that would help with solving this.


Solution

  • If iid matches the IID of the interface queried for, then the function specified by func is called. The declaration for the function should be:

    HRESULT WINAPI func(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw);

    For more information, please refer to this official document:

    https://learn.microsoft.com/en-us/cpp/atl/reference/com-interface-entry-macros?view=msvc-170#remarks-10