summaryrefslogtreecommitdiff
path: root/gmodule/gmodule-win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'gmodule/gmodule-win32.c')
-rw-r--r--gmodule/gmodule-win32.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gmodule/gmodule-win32.c b/gmodule/gmodule-win32.c
index 20459f372..1c7226a68 100644
--- a/gmodule/gmodule-win32.c
+++ b/gmodule/gmodule-win32.c
@@ -39,6 +39,12 @@
#include <sys/cygwin.h>
#endif
+/* Default family is DESKTOP_APP which is DESKTOP | APP
+ * We want to know when we're only building for apps */
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#define G_WINAPI_ONLY_APP
+#endif
+
static void
set_error (const gchar *format,
...)
@@ -84,7 +90,15 @@ _g_module_open (const gchar *file_name,
success = SetThreadErrorMode (SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS, &old_mode);
if (!success)
set_error ("");
+
+ /* When building for UWP, load app asset DLLs instead of filesystem DLLs.
+ * Needs MSVC, Windows 8 and newer, and is only usable from apps. */
+#if _WIN32_WINNT >= 0x0602 && defined(G_WINAPI_ONLY_APP)
+ handle = LoadPackagedLibrary (wfilename, 0);
+#else
handle = LoadLibraryW (wfilename);
+#endif
+
if (success)
SetThreadErrorMode (old_mode, NULL);
g_free (wfilename);