c++mfccomactivexwinsxs

registration free com and Dispatch LPPICTUREDISP


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;
}

Any idea about what is going on?


Solution

  • 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).