3

This is my COM interface:

[id(2)] boolean Init(BSTR User, BSTR Password);
[id(3)] boolean SetBitmap(BSTR szObjectType, IPictureDisp* szBitmap);

The following Init() function works if the COM interface is registered, or else with the application's manifests using Side-by-side Assemblies (sxs).

Init(LPCTSTR User, LPCTSTR Password)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR VTS_BSTR;
    InvokeHelper(0x2, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
         User, Password);
    return result;
}

However the following SetBitmap() function works only if the COM interface is registred!

BOOL SetBitmap(LPCTSTR szObjectType, LPPICTUREDISP szBitmap)
{
    BOOL result;
    static BYTE parms[] =
        VTS_BSTR VTS_DISPATCH;
    InvokeHelper(0x3, DISPATCH_METHOD, VT_BOOL, (void*)&result, parms,
        szObjectType, szBitmap);
    return result;
}
  • If I use the COM interface configured with the application manifests, the function call fails with error E_UNEXPECTED

  • If I replace VTS_DISPATCH with VTS_BSTR, the function call is successful and works. In this case it looks like the dispatcher can't dispatch the object.

Any idea about what is going on?

Mangesh
  • 5,491
  • 5
  • 48
  • 71
kain64b
  • 2,258
  • 2
  • 15
  • 27
  • What is the manifest contents? – Roman R. Dec 14 '17 at 16:58
  • manifests without guids: https://gist.github.com/kain64/bc79e53a11fe4f5459117a8de12b2bcf all functions wors exept 1 with Dispatch object ( – kain64b Dec 17 '17 at 08:56
  • 1
    There is a *lot* wrong here. The bigger ones are that the functions cannot be called with InvokeHelper since they don't have the correct signature. And the Init() wrapper incorrectly specifying 3 arguments when it has 2. The manifest missing the progid and the file element being in the wrong manifest makes it likely that this code is using the completely wrong server. Hard to guess how this went so wrong, this code is normally auto-generated by a wizard. Which are not that helpful if the code is still changing, do favor using the #import directive instead. – Hans Passant Dec 18 '17 at 13:42

2 Answers2

4

IPictureDisp parameter is not a problem for registration free COM.

What seems to be wrong here is the way you create the manifest XML. If your IDL is defined for the ActiveX DLL, and the library has the actual TLB then your client binary manifest should have the reference and not the DLL's manifest:

<dependentAssembly>
  <assemblyIdentity name='dlgd' type='win32' version='6.0.0.0'
    processorArchitecture='amd64' />
  <file name="dlgd.ocx" hashalg="SHA1">
    <comClass clsid="{guiD}" tlbid="{guiD}" description="sDlg Control"/>
    <typelib tlbid="{guiD}" version="1.0" helpdir=""/>
  </file>
</dependentAssembly>

Also, boolean IDL method result types should normally be HRESULTs instead. There are also other problems (as pointed by others) as well as your real unposted code might have even additional problems. Still, the case as you explained it can work out just fine if you fix the manifest, you can use RegFreeComPictureDisp solution with your code snippets (client, server, IDL, manifest excerpt) as a reference to fix your project (Trac, Subversion).

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Hello Roman, Thank you for example. but it not relevant to my question :( I made additional tests with my com. I did small client code(extracted from big app). and it works. but in big app , it does not. it really magic for me. same code/manifest different results. I found strange thing: m_lpDispatch in big App is null, and created via queryintarface(IDISPATCHER), but in small app it not null. any way I will mark this question as answer, if I did not receive another right example. – kain64b Dec 21 '17 at 17:04
0

finally it was crazy bug: we have CEF(chromiumembedded) component. and it was initialized without CEfApp object. and here is really crazy problem: ActiveX with registration works normally. without it Dispatch problem. after normal CEF initialization (or with disabled CEF initialization)it works in both cases!

kain64b
  • 2,258
  • 2
  • 15
  • 27