summaryrefslogtreecommitdiff
path: root/plugins/MimCmd/src/MimCmd.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-02-22 23:16:49 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-02-22 23:16:49 +0300
commit7199eca4895b8ba0da40857275094220170b25a5 (patch)
tree595a3ad367aaf992d38a5201632cc1913cd21e56 /plugins/MimCmd/src/MimCmd.cpp
parent1163cd367fc081b85e4ec56b0299775453395702 (diff)
fixes #1160 (MimCmd: cannot locate runtime library)
Diffstat (limited to 'plugins/MimCmd/src/MimCmd.cpp')
-rw-r--r--plugins/MimCmd/src/MimCmd.cpp25
1 files changed, 25 insertions, 0 deletions
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();