Windows.h can not be included in plugin: C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um\Windows.h(1,10): fatal error: 'winapifamily.h' file not found

Hello,

I’m struggling to get my plugin working. I am using windows.h functionality to check if a program is still running in the background. It works like a charm in the editor! But as soon as I try to package to a Plugin it all falls apart, because it somehow can’t find Windows.h. I looked at the internet for answers but all provided don’t work.

How do I include Windows.h when I want to package it as a Plugin?

// Fill out your copyright notice in the Description page of Project Settings.

pragma once
//#include “CoreMinimal.h”
include “Engine.h”

include “Kismet/BlueprintFunctionLibrary.h”
include “iostream”
include “fstream”
include “stdlib.h”
include “Misc/FileHelper.h”
include “Misc/Paths.h”
include

ifdef _WIN32
include “Windows/AllowWindowsPlatformTypes.h”
include “Windows/PreWindowsApi.h”
endif

//#define WIN32_LEAN_AND_MEAN
//#include “Windows.h”
//#include “Windows/WindowsSystemIncludes.h”

//#include “AllowWindowsPlatformTypes.h”
//#include “Windows.h”
//#include “HideWindowsPlatformTypes.h”

//#include “Windows/MinWindows.h”

include “Windows/WindowsHWrapper.h”

//#include “AllowWindowsPlatformTypes.h”
//#include “Windows/WindowsSystemIncludes.h”
//#include “HideWindowsPlatformTypes.h”

include
include
include
include “tlhelp32.h”

ifdef _WIN32
include “Windows/PostWindowsApi.h”
include “Windows/HideWindowsPlatformTypes.h”
endif

include “BatchBuilderFunctionLibrary.generated.h”

/**
*
*/
UCLASS()
class BATCHBUILDER_API UBatchBuilderFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()

public:

UFUNCTION(BlueprintCallable)  
	static void WriteBuildFile(FString QualityInput, FString Level);  

UFUNCTION(BlueprintCallable)  
	static void ExecuteBatchBuilderBat();  

UFUNCTION(BlueprintCallable)  
	static void PrintTestINT(int& OutInt);  

UFUNCTION(BlueprintCallable)  
	static void PrintTestString(FString& OutString, bool& DebugBool);  

UFUNCTION(BlueprintCallable)  
	static void IsRunningB(bool& Boolean);  

UFUNCTION(BlueprintPure, Category = "FPS Game CPP Nodes", meta = (Keywords = "Load Text File"))  
	static bool LoadTxt(FString FileName, FString& SaveText);  

UFUNCTION(BlueprintCallable, Category = "FPS Game CPP Nodes", meta = (Keywords = "Save Text File"))  
	static bool SaveTxt(FString SaveText, FString FileName);  

};

It succesfully compiles, but when packaging it gives the following error:

C:/Program Files (x86)/Windows Kits/10/Include/10.0.19041.0/um\Windows.h(1,10): fatal error: ‘winapifamily.h’ file not found

At first this was Windows.h which was missing, but after modifying it with multiple different sollutions from the internet it just moves the problem to the next include in line untill it gets so many errors from all the includes that it fails to show the errors.