将shlwapi.h链接到StrCmpLogicalW函数

use*_*234 1 c++ winapi

知道如何将此代码从C#移植到C++?

[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
private static extern int StrCmpLogicalW(string psz1, string psz2);
Run Code Online (Sandbox Code Playgroud)

如果我在C++的头文件中尝试了这一行,编译器会产生一堆错误.

#include <Shlwapi.h>
Run Code Online (Sandbox Code Playgroud)

Dav*_*nan 7

错误是链接器错误,因为您没有包含相应的.lib文件Shlwapi.lib.

您可以在项目设置中包含.lib文件,也可以添加它

#pragma comment(lib, "Shlwapi.lib")
Run Code Online (Sandbox Code Playgroud)

例如,StdAfx.h.