From ff1830fb4a33718abe1280ee7b835cedffd54aac Mon Sep 17 00:00:00 2001 From: "U-i7\\gimy" Date: Sat, 29 Aug 2009 19:57:27 +0900 Subject: [PATCH] invoke yamy{64,32} and yamyd32 from same directory of yamy.exe instead of current working directory --- mayu.cpp | 13 ++++++++++++- yamy.cpp | 19 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/mayu.cpp b/mayu.cpp index 0380688..f83f19e 100644 --- a/mayu.cpp +++ b/mayu.cpp @@ -1134,7 +1134,18 @@ public: // create mutex to block yamyd m_hMutexYamyd = CreateMutex((SECURITY_ATTRIBUTES *)NULL, TRUE, MUTEX_YAMYD_BLOCKER); - BOOL result = CreateProcess(_T("yamyd32"), _T("yamyd32"), NULL, NULL, FALSE, + tstring yamydPath; + _TCHAR exePath[GANA_MAX_PATH]; + _TCHAR exeDrive[GANA_MAX_PATH]; + _TCHAR exeDir[GANA_MAX_PATH]; + + GetModuleFileName(NULL, exePath, GANA_MAX_PATH); + _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0); + yamydPath = exeDrive; + yamydPath += exeDir; + yamydPath += _T("yamyd32"); + + BOOL result = CreateProcess(yamydPath.c_str(), NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, 0, NULL, &m_si, &m_pi); if (result == FALSE) { TCHAR buf[1024]; diff --git a/yamy.cpp b/yamy.cpp index b05d808..6d15f84 100644 --- a/yamy.cpp +++ b/yamy.cpp @@ -3,6 +3,7 @@ #include #include +#include "stringtool.h" #include "mayurc.h" /// main @@ -15,7 +16,15 @@ int WINAPI _tWinMain(HINSTANCE i_hInstance, HINSTANCE /* i_hPrevInstance */, STARTUPINFO si; PROCESS_INFORMATION pi; BOOL result; - TCHAR *yamyPath = _T("yamy32"); + tstring yamyPath; + _TCHAR exePath[GANA_MAX_PATH]; + _TCHAR exeDrive[GANA_MAX_PATH]; + _TCHAR exeDir[GANA_MAX_PATH]; + + GetModuleFileName(NULL, exePath, GANA_MAX_PATH); + _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0); + yamyPath = exeDrive; + yamyPath += exeDir; pIsWow64Process = (ISWOW64PROCESS)::GetProcAddress(::GetModuleHandle(_T("kernel32.dll")), @@ -27,11 +36,15 @@ int WINAPI _tWinMain(HINSTANCE i_hInstance, HINSTANCE /* i_hPrevInstance */, if (pIsWow64Process) { result = pIsWow64Process(::GetCurrentProcess(), &isWow64); if (result != FALSE && isWow64 == TRUE) { - yamyPath = _T("yamy64"); + yamyPath += _T("yamy64"); + } else { + yamyPath += _T("yamy32"); } + } else { + yamyPath += _T("yamy32"); } - result = CreateProcess(yamyPath, yamyPath, NULL, NULL, FALSE, + result = CreateProcess(yamyPath.c_str(), NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, 0, NULL, &si, &pi); if (result == FALSE) { -- 2.11.0