From 7199eca4895b8ba0da40857275094220170b25a5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 22 Feb 2018 23:16:49 +0300 Subject: fixes #1160 (MimCmd: cannot locate runtime library) --- plugins/MimCmd/MimCmd.vcxproj | 3 +-- plugins/MimCmd/src/MimCmd.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/plugins/MimCmd/MimCmd.vcxproj b/plugins/MimCmd/MimCmd.vcxproj index a567479d8f..00a6f44102 100644 --- a/plugins/MimCmd/MimCmd.vcxproj +++ b/plugins/MimCmd/MimCmd.vcxproj @@ -31,8 +31,7 @@ Console - mir_core.mir - delayimp.lib;comctl32.lib;ws2_32.lib;UxTheme.lib;Iphlpapi.lib;%(AdditionalDependencies) + api-ms-win-crt-heap-l1-1-0.dll;api-ms-win-crt-locale-l1-1-0.dll;api-ms-win-crt-math-l1-1-0.dll;api-ms-win-crt-runtime-l1-1-0.dll;api-ms-win-crt-stdio-l1-1-0.dll;api-ms-win-crt-string-l1-1-0.dll;mir_core.mir Sync diff --git a/plugins/MimCmd/src/MimCmd.cpp b/plugins/MimCmd/src/MimCmd.cpp index fea2335465..b077a9d434 100644 --- a/plugins/MimCmd/src/MimCmd.cpp +++ b/plugins/MimCmd/src/MimCmd.cpp @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +#pragma comment(lib, "delayimp.lib") + int hLangpack = 0; wchar_t* GetProgramName(wchar_t *programName, size_t size) @@ -55,6 +57,29 @@ void ShowVersion() int wmain(int argc, wchar_t *argv[]) { + wchar_t wszPath[MAX_PATH]; + wcsncpy_s(wszPath, argv[0], _TRUNCATE); + + // if current dir isn't set + for (int i = lstrlenW(wszPath); i >= 0; i--) + if (wszPath[i] == '\\') { + wszPath[i] = 0; + break; + } + + SetCurrentDirectoryW(wszPath); + + lstrcatW(wszPath, L"\\libs"); + SetDllDirectoryW(wszPath); + +#ifdef _DEBUG + lstrcatW(wszPath, L"\\ucrtbased.dll"); +#else + lstrcatW(wszPath, L"\\ucrtbase.dll"); +#endif + LoadLibraryW(wszPath); + + //////////////////////////////////////////////////////////////////////////////////////// _setmode(_fileno(stdout), _O_U16TEXT); if (argc == 2 && !wcscmp(argv[1], L"-v")) { ShowVersion(); -- cgit v1.2.3