locked
What is the significance of declaring a method STDMETHODIMP? RRS feed

  • Question

  • significance of declaring a method STDMETHODIMP....?!
    Monday, March 21, 2011 4:55 AM

Answers

  • This ensures that your calling convention is the one used by COM. When you are writing a COM server, you normally use STDMETHOD to declare methods exposed to COM and STDMETHODIMP to implement them.

    E.g

    *.idl
    
    interface IWhatever
    {
    HRESULT Method(params);
    };
    
    *.h
    
    class IWhateverImpl : ...
    {
     ...
     STDMETHOD(Method)(params);
     ...
    };
    
    *.cpp
    
    STDMETHODIMP IWhateverImpl::Method(params)
    {
     ...
    }
    

    Goran.

    Monday, March 21, 2011 8:11 AM

All replies

  • This ensures that your calling convention is the one used by COM. When you are writing a COM server, you normally use STDMETHOD to declare methods exposed to COM and STDMETHODIMP to implement them.

    E.g

    *.idl
    
    interface IWhatever
    {
    HRESULT Method(params);
    };
    
    *.h
    
    class IWhateverImpl : ...
    {
     ...
     STDMETHOD(Method)(params);
     ...
    };
    
    *.cpp
    
    STDMETHODIMP IWhateverImpl::Method(params)
    {
     ...
    }
    

    Goran.

    Monday, March 21, 2011 8:11 AM
  • This ensures that your calling convention is the one used by COM. When you are writing a COM server, you normally use STDMETHOD to declare methods exposed to COM and STDMETHODIMP to implement them.

    E.g

     

    *.idl
    
    
    
    interface IWhatever
    
    {
    
    HRESULT Method(params);
    
    };
    
    
    
    *.h
    
    
    
    class IWhateverImpl : ...
    
    {
    
     ...
    
     STDMETHOD(Method)(params);
    
     ...
    
    };
    
    
    
    *.cpp
    
    
    
    STDMETHODIMP IWhateverImpl::Method(params)
    
    {
    
     ...
    
    }
    
    

     

    Goran.


    Thanks ...
    Friday, March 25, 2011 4:56 AM