tags:

views:

149

answers:

1

OK, getting this to work properly was a nightmare, so I decided to put this up for others.

Hosting the flash activex requires that you call OleCreate with an IStorage that implements SetClass (can be no-op), and a IOleClientSite that implements:

IOleInPlaceSiteEx:
    OnInPlaceActivateEx() (no-op)
    GetWindow()
    GetWindowContext()
IOleClientSite:
    ShowObject() (no-op)

However, any external resources the loaded swf accesses must be fully qualified, or it will fail with errors like:

Error #2032: Stream Error. URL: file://<relative path>

I'm posting what I figured out as an answer, tell me if this is not propper Stackettique.

A: 

To fix this, your IOleClientSite must also implement IServiceProvider::QueryService() to return an IBindHost that implements CreateMoniker():

return CreateURLMonikerEx(pmkBase, szName, ppmk, URL_MK_UNIFORM);

Where pmkBase is a URL Moniker that has your base path, eg:

OLECHAR szPath[MAX_PATH];
int cch = ::GetCurrentDirectory(ARRAYSIZE(szPath), szPath);
// GetCurrentDirectory does not finish with \, which causes the top directory to be removed :(
// Also, error checking is for pansies.
szPath[cch++] = L'\\';
szPath[cch++] = 0;
CreateURLMonikerEx(0, szPath, &pmkBase, URL_MK_UNIFORM);
Simon Buchan