c++ - 启动 VirtualBoxSDK 测试应用程序返回错误 "Error creating virtual box instance"

标签 c++ c com virtualbox

我正在尝试在 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 是“类未注册”。

  1. 尝试使用 regsvr32 注册组件
  2. 如果您尝试实例化的组件是 64 位,则构建 64 位项目

关于c++ - 启动 VirtualBoxSDK 测试应用程序返回错误 "Error creating virtual box instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19572184/

相关文章:

c++ - 为什么 boost locale 不提供字符级规则类型?

C 程序 : when I use malloc function, 我发现字节数总是多于数组的大小

php - 生成 Crystal Reports 报告的代码在 CLI 中运行良好,但从浏览器访问时为 "Data source name not found"

c++ - 在 CoCreateInstance 之前调用 QueryInterface?

c++ - 为什么在此处添加临时变量会使此编译器错误消失?种类都一样

c++ - << , >> 运算符在循环中的作用是什么

c - 关于哈希函数

c - 清零内存

c++ - 如何构建指向 VARIANT 的指针的 SAFEARRAY?

c++ - 由于没有运算符的 CString 连接(?)导致的 MemoryException