我正在尝试在 Windows 7 上使用 VirtualBox sdk。 为此,我使用 VirtualBoxSDK\bindings\mscom\samples\中提供的示例代码作为启动。该示例包含以下代码:
/* Instantiate the VirtualBox root object. */
rc = CoCreateInstance(CLSID_VirtualBox, /* the VirtualBox base object */
NULL, /* no aggregation */
CLSCTX_LOCAL_SERVER, /* the object lives in a server process on this machine */
IID_IVirtualBox, /* IID of the interface */
(void**)&virtualBox);
if (!SUCCEEDED(rc))
{
printf("Error creating VirtualBox instance! rc = 0x%x\n", rc);
break;
}
代码构建正常,链接正常,但是当我运行它时,我得到:创建 VirtualBox 实例时出错! rc = 0x80040154(无法加载文件或程序集错误)。 我假设没有服务器端(可能)提供我尝试使用 CoCreateInstance() 创建的 COM 对象。我只是启动提供的示例,但我假设应该有一些服务器也在运行?! 提供的文档没有提及有关某些服务器的任何内容,但这就是我的想法。 谢谢
最佳答案
0x80040154 是“类未注册”。
- 尝试使用 regsvr32 注册组件
- 如果您尝试实例化的组件是 64 位,则构建 64 位项目
关于c++ - 启动 VirtualBoxSDK 测试应用程序返回错误 "Error creating virtual box instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19572184/