OSDN Git Service

invoke yamy{64,32} and yamyd32 from same directory of yamy.exe instead of current...
[yamy/yamy.git] / yamy.cpp
index b05d808..6d15f84 100644 (file)
--- a/yamy.cpp
+++ b/yamy.cpp
@@ -3,6 +3,7 @@
 \r
 #include <windows.h>\r
 #include <tchar.h>\r
+#include "stringtool.h"\r
 #include "mayurc.h"\r
 \r
 /// main\r
@@ -15,7 +16,15 @@ int WINAPI _tWinMain(HINSTANCE i_hInstance, HINSTANCE /* i_hPrevInstance */,
        STARTUPINFO si;\r
        PROCESS_INFORMATION pi;\r
        BOOL result;\r
-       TCHAR *yamyPath = _T("yamy32");\r
+       tstring yamyPath;\r
+       _TCHAR exePath[GANA_MAX_PATH];\r
+       _TCHAR exeDrive[GANA_MAX_PATH];\r
+       _TCHAR exeDir[GANA_MAX_PATH];\r
+\r
+       GetModuleFileName(NULL, exePath, GANA_MAX_PATH);\r
+       _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);\r
+       yamyPath = exeDrive;\r
+       yamyPath += exeDir;\r
 \r
        pIsWow64Process =\r
                (ISWOW64PROCESS)::GetProcAddress(::GetModuleHandle(_T("kernel32.dll")),\r
@@ -27,11 +36,15 @@ int WINAPI _tWinMain(HINSTANCE i_hInstance, HINSTANCE /* i_hPrevInstance */,
        if (pIsWow64Process) {\r
                result = pIsWow64Process(::GetCurrentProcess(), &isWow64);\r
                if (result != FALSE && isWow64 == TRUE) {\r
-                       yamyPath = _T("yamy64");\r
+                       yamyPath += _T("yamy64");\r
+               } else {\r
+                       yamyPath += _T("yamy32");\r
                }\r
+       } else {\r
+               yamyPath += _T("yamy32");\r
        }\r
 \r
-       result = CreateProcess(yamyPath, yamyPath, NULL, NULL, FALSE,\r
+       result = CreateProcess(yamyPath.c_str(), NULL, NULL, NULL, FALSE,\r
                                                   NORMAL_PRIORITY_CLASS, 0, NULL, &si, &pi);\r
 \r
        if (result == FALSE) {\r