Fatal error 0x8000FFFF when using a COM server

Our application needs to talk to quite a few other applications. Recently I replaced the existing DDE based interface with a COM based one. The vendor of the other application provides a COM server that controls their application and passes data back and forth. My first attempt in Visual FoxPro looked like this


loClient = CREATEOBJECT("Acme.Client")
loClient.acmeConnect("App")

Set o = CreateObject("Acme.Client")
msgbox o.acmeConnect("App")

Same error here. But who uses VB Script, anyway? Next in C:


var x = new Acme3Client.Client();
var n = x.acmeConnect("App");

Surprisingly, I got the same error. The control ships with a sample application written in C++ in which the COM server works. Unfortunately, the sample application is just a compiled EXE. So, next I tried this in C++ with ATL:


int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
using namespace Acme3Client;
IClientPtr px("Acme.Client");
px->acmeConnect("App");
return 0;
}

I wasn't willing to see yet another 0x8000FFFF exception, but my computer didn't ask me. As a last attempt I tried to use the COM server in an MFC application:


CAcmeClient *p = new CAcmeClient();
p->acmeConnect(CString("App"));

Finally, I got a different error message. MFC fired an assertion because a window handle was NULL. This lead to the solution: Contrary to what the documentation states, this COM server can only be used by adding it as an ActiveX control to the form. A better error message would have pointed me in the right direction much earlier.