Skip to content

Instantly share code, notes, and snippets.

@yuk7
Created October 17, 2017 04:18
Show Gist options
  • Save yuk7/edcd4a468aaacc8438389dc4b4464fab to your computer and use it in GitHub Desktop.
Save yuk7/edcd4a468aaacc8438389dc4b4464fab to your computer and use it in GitHub Desktop.
WSL API Test code for Register Distribution. Windows 10 64bit FCU or later only. I tested with mingw-w64 64bit gcc
#include <stdio.h>
#include <windows.h>
typedef int (WINAPI *FUNC)(PCWSTR,PCWSTR);
int main()
{
HMODULE hmod;
FUNC func;
hmodule = LoadLibrary(TEXT("wslapi.dll"));
if (hmod == NULL) {
printf("ERROR:wslapi.dll load failed");
return 1;
}
func = (FUNC)GetProcAddress(hmod, "WslRegisterDistribution");
if (func == NULL) {
FreeLibrary(hmod);
printf("ERROR:GetProcAddress failed");
return 1;
}
int a = func(L"Test",L"install.tar.gz");
printf("%d",a);
FreeLibrary(hmod);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment