我不知道如何 link msi.lib 我的 Visual Studio C++ 项目

I can't figure out how to link msi.lib to my Visual Studio C++ project

我正在尝试编写一个简单的应用程序来枚举我机器上安装的所有 ProductCodes。

我在 Visual Studio 2013 年开始了一个新项目,但每当我构建时我都会收到错误消息:
"LNK2019: unresolved external symbol _MsiEnumProductsExA@32 referenced in function _main"

我一直在想办法将 msi.lib 添加到我的项目包含路径,但我似乎无法弄清楚。

这是我的代码:

#define _WIN32_MSI 300

#include <Windows.h>
#include <iostream>
#include <string>
#include <Msi.h>
using namespace std;

int main() {
    // Get a list of all installed MSIs
    DWORD index = 0;
    TCHAR currentProductCode[40] = {0};
    unsigned int result = ERROR_SUCCESS;

   // Open an MSI handle
   while (ERROR_SUCCESS == result) {
      result = MsiEnumProductsEx(NULL, "s-1-1-0",
                                 MSIINSTALLCONTEXT_USERMANAGED | MSIINSTALLCONTEXT_USERUNMANAGED | MSIINSTALLCONTEXT_MACHINE,
                                 index, currentProductCode, NULL, NULL, NULL);
      if (result == ERROR_SUCCESS) {
         cout << "current ProductCode: " << currentProductCode;
      }
      index++;
   }

    return 0;
}

我一直在尝试通过将 msi.lib 的路径添加到 "Library Directories" 属性 来更新项目的 属性 页面,但这似乎并没有上班:

这就像Visual Studio101,我错过了什么?!

转到配置属性>链接器>输入

Additional Dependencies 添加msi.lib 就这样!确保您使用的是与构建库相同的调用转换。即 stdcall 或 cdecl.