Is there a way to use Win32 API with Unreal 5?

Hi!

I’m developing a game with Unreal 5.2.1 game with C++.

Is there a way to make calls to Win32 API in an Unreal game?

Maybe, I can create an external library with the Win32 API calls and I use it with Unreal.

RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
SetWindowLong(hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_MINIMIZEBOX);
SetWindowPos(hWnd, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);

I want to make the game full screen and show the taskbar. Yes, it’s strange, but it’s something that I want to check.

Thanks!

Win32 api is for windows desktop dev , why do you want that in unreal, curious.

You want to call the windows main api function from a function in unreal ? because that is maybe the only way you could pull this off.

You would have to use add controls functions
You can have anything here iostream etc, but I don’t think it accepts maybe windows.h header.

#if PLATFORM_WINDOWS
include “Windows/AllowWindowsPlatformTypes.h”
// include Windows headers here…
#endif

That will allow you to compile with windows SDK headers, but be careful.

1 Like

I tried this approach but including it leads to a compile error

Blockquote
comutil.h(767): Error C3861 : ‘InterlockedIncrement’: identifier not found

Which I then resolve by including <winnt.h>. This leads to a

Blockquote
winnt.h(169): Error C1189 : #error: “No Target Architecture”

When I try to resolve this by including <windows.h> I am back at square one with the error

Blockquote
comutil.h(767): Error C3861 : ‘InterlockedIncrement’: identifier not found

Seems I am missing something here.
For my complete quest, see this post: Accessing WMI information in Unreal

Thanks!

#include "AllowWindowsPlatformTypes.h"

#include windows.h

#include "HideWindowsPlatformTypes.h"
1 Like

For InterlockedIncrement (etc.) there are additional allow/hide headers. These exist in UE 5.4 but it looks like they’re also in UE 5.3.

#include "Windows/AllowWindowsPlatformAtomics.h"
...
#include "Windows/HideWindowsPlatformAtomics.h"

(I ran into this issue when including some COM headers.)

–Tom