News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

error in windows sdk 7.1 IOleCommandTarget::QueryStatus DocObj.h

Started by TouEnMasm, August 26, 2014, 05:14:36 AM

Previous topic - Next topic

TouEnMasm

The QueryStatus had a bad prototype
Quote
        /* [input_sync] */ HRESULT ( STDMETHODCALLTYPE *QueryStatus )(
            __RPC__in IOleCommandTarget * This,
            /* [unique][in] */ __RPC__in_opt const GUID *pguidCmdGroup,
            /* [in] */ ULONG cCmds,
            /* [out][in][size_is] */ __RPC__inout_ecount_full(cCmds) OLECMD prgCmds[  ],
            /* [unique][out][in] */ __RPC__inout_opt OLECMDTEXT *pCmdText);
must be change in
Quote
        /* [input_sync] */ HRESULT ( STDMETHODCALLTYPE *QueryStatus )(
            __RPC__in IOleCommandTarget * This,
            /* [unique][in] */ __RPC__in_opt const GUID *pguidCmdGroup,
            /* [in] */ ULONG cCmds,
            /* [out][in][size_is] */ __RPC__inout_ecount_full(cCmds) OLECMD * prgCmds[  ],
            /* [unique][out][in] */ __RPC__inout_opt OLECMDTEXT *pCmdText);

prgCmds is apointer on a OLECMD structure and not a OLECMD structure (8 bytes)
correct usage is shown in this page.

http://msdn.microsoft.com/en-us/library/5d4becy5(VS.80).aspx

Quote
void CContainerCntrItem::DoOleCmd()
{
   IOleCommandTarget *pCmd = NULL;
   HRESULT hr = E_FAIL;
   OLECMD ocm={OLECMDID_PRINT, 0};

   hr = m_lpObject->QueryInterface(IID_IOleCommandTarget,reinterpret_cast<void**>(&pCmd));
   if(FAILED(hr))
      return;
//*****************************************************
   hr = pCmd->QueryStatus(NULL, 1, &ocm, NULL);
//*****************************************************

   if(SUCCEEDED(hr) && (ocm.cmdf & OLECMDF_ENABLED))
   {
      //Command is available and enabled so call it
      COleVariant vIn;
      COleVariant vOut;
      hr = pCmd->Exec(NULL, OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT, &vIn, &vOut);
      ASSERT(SUCCEEDED(hr));
   }
   pCmd->Release();
}


http://msdn.microsoft.com/en-us/library/5d4becy5(VS.80).aspx
Fa is a musical note to play with CL

qWord

Quote from: ToutEnMasm on August 26, 2014, 05:14:36 AM
The QueryStatus had a bad prototype
Quote
        /* [input_sync] */ HRESULT ( STDMETHODCALLTYPE *QueryStatus )(
            __RPC__in IOleCommandTarget * This,
            /* [unique][in] */ __RPC__in_opt const GUID *pguidCmdGroup,
            /* [in] */ ULONG cCmds,
            /* [out][in][size_is] */ __RPC__inout_ecount_full(cCmds) OLECMD prgCmds[  ],
            /* [unique][out][in] */ __RPC__inout_opt OLECMDTEXT *pCmdText);
MREAL macros - when you need floating point arithmetic while assembling!

TouEnMasm


The related matter of this post had been corrected in the new version of the translator (headinc.exe)
http://masm32.com/board/index.php?topic=576.msg4665#msg4665
Fa is a musical note to play with CL