Hello everybody! Please tell me why UE5 does not define functions from the windows.h library (for UE5 “Windows/WindowsHWrapper.h”. I attach the program code and errors when downloading from Visual Studio 2019.
test.cpp
#include “Windows/WindowsHWrapper.h”
#include “iostream”
#include “string”
using namespace std;
#include “test.h”
void Utest::phone(FString a, FString b, FString& result)
{
WinExec(“…WhatsApp.exe”, SW_SHOWNORMAL);
HWND hwnd = GetForegroundWindow();
RECT rect;
GetWindowRect(hwnd, &rect);
SetWindowPos(hwnd, 0, 0, 0, rect.right, rect.bottom, SWP_NOSIZE);
const char* output = "1234567890";
const size_t len = strlen(output) + 1;
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
memcpy(GlobalLock(hMem), output, len);
GlobalUnlock(hMem);
OpenClipboard(0);
EmptyClipboard();
SetClipboardData(CF_TEXT, hMem);
CloseClipboard();
POINT cp;
cp.x = 537;
cp.y = 742;
GetCursorPos(&cp);
SetCursorPos(537, 742);
mouse_event(MOUSEEVENTF_LEFTDOWN, cp.x, cp.y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, cp.x, cp.y, 0, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(0x56, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(0x56, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
keybd_event(VK_RETURN, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
SetCursorPos(1000, 11);
mouse_event(MOUSEEVENTF_LEFTDOWN, cp.x, cp.y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, cp.x, cp.y, 0, 0);
Sleep(100);
SetCursorPos(cp.x, cp.y);
return;
}
test.h
#pragma once
#include “Windows/WindowsHWrapper.h”
#include “iostream”
#include “string”
using namespace std;
#include “CoreMinimal.h”
#include “Kismet/BlueprintFunctionLibrary.h”
#include “test.generated.h”
/**
*
*/
UCLASS()
class PHONE_API Utest : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable)
void phone(FString a, FString b, FString& result);
};
Errors in UE5:
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_SetWindowPos in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_OpenClipboard in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_CloseClipboard in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_SetClipboardData in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_EmptyClipboard in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_keybd_eventin the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_mouse_event in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_GetForegroundWindow in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_GetWindowRect in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_SetCursorPos in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
test.cpp.obj : error LNK2019: reference to an unresolved external character __imp_GetCursorPos in the function “public: void __cdecl Utest::phone(class FString,class FString,class FString &)” (?phone@Utest@@QEAAXVFString@@0AEAV2@@Z).
D:\Proect\Test\phone\Binaries\Win64\UnrealEditor-phone.patch_5.exe : fatal error LNK1120: unresolved external elements: 11
Failed to link patch (0.000s) (Exit code: 0x460)