From d6b1e62ffca368d65e2b03657cc66b391728d767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20D=C3=B6singer?= Date: Wed, 27 Dec 2023 12:21:44 +0300 Subject: [PATCH] vkd3d: Add a win32 version of vkd3d_get_program_name. --- libs/vkd3d/utils.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c index 58747342..11029c9f 100644 --- a/libs/vkd3d/utils.c +++ b/libs/vkd3d/utils.c @@ -901,6 +901,30 @@ bool vkd3d_get_program_name(char program_name[PATH_MAX]) return true; } +#elif defined(WIN32) + +bool vkd3d_get_program_name(char program_name[PATH_MAX]) +{ + char buffer[MAX_PATH]; + char *p, *name; + size_t len; + + *program_name = '\0'; + len = GetModuleFileNameA(NULL, buffer, ARRAY_SIZE(buffer)); + if (!(len && len < MAX_PATH)) + return false; + + name = buffer; + if ((p = strrchr(name, '/'))) + name = p + 1; + if ((p = strrchr(name, '\\'))) + name = p + 1; + + len = strlen(name) + 1; + memcpy(program_name, name, len); + return true; +} + #else bool vkd3d_get_program_name(char program_name[PATH_MAX])