我正在创建一个使用Windows子系统Linux库中的Issue for the Chrome Extension File not getting uploaded?的项目。
在我的Windows SDK库中,缺少wslapi.lib
。我已尝试重新下载最新的SDK,但我无法在任何地方找到wslapi.lib
。
我在哪里可以获得wslapi.lib
?
答案 0 :(得分:1)
在Windows SDK中,没有wslapi.lib
个文件静态链接该wslapi.dll
文件。您已使用LoadLibrary()
和GetProcAddress()
拨打WslIsDistributionRegistered()
功能。
#include <windows.h>
#include <stdio.h>
typedef BOOL(__stdcall *pIsDistroRegistered)(PCWSTR distroName);
int wmain(int wargc, wchar_t* wargv[]) {
HMODULE dll = LoadLibraryExW(L"wslapi.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
pIsDistroRegistered IsDistroRegistered = (IsDistroRegistered)GetProcAddress(dll, "WslIsDistributionRegistered");
BOOL result = IsDistroRegistered(wargv[1]);
if (result)
printf("Distribution name '%ls' is registerd\n", wargv[1]);
else
printf("Distribution name '%ls' is not registerd\n", wargv[1]);
}