1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\r
6 #include "stringtool.h"
\r
10 int WINAPI _tWinMain(HINSTANCE i_hInstance, HINSTANCE /* i_hPrevInstance */,
\r
11 LPTSTR /* i_lpszCmdLine */, int /* i_nCmdShow */)
\r
13 typedef BOOL (WINAPI* ISWOW64PROCESS)(HANDLE hProcess, PBOOL Wow64Process);
\r
15 ISWOW64PROCESS pIsWow64Process;
\r
17 PROCESS_INFORMATION pi;
\r
20 _TCHAR exePath[GANA_MAX_PATH];
\r
21 _TCHAR exeDrive[GANA_MAX_PATH];
\r
22 _TCHAR exeDir[GANA_MAX_PATH];
\r
24 GetModuleFileName(NULL, exePath, GANA_MAX_PATH);
\r
25 _tsplitpath_s(exePath, exeDrive, GANA_MAX_PATH, exeDir, GANA_MAX_PATH, NULL, 0, NULL, 0);
\r
26 yamyPath = exeDrive;
\r
30 (ISWOW64PROCESS)::GetProcAddress(::GetModuleHandle(_T("kernel32.dll")),
\r
32 ZeroMemory(&pi,sizeof(pi));
\r
33 ZeroMemory(&si,sizeof(si));
\r
36 if (pIsWow64Process) {
\r
37 result = pIsWow64Process(::GetCurrentProcess(), &isWow64);
\r
38 if (result != FALSE && isWow64 == TRUE) {
\r
39 yamyPath += _T("yamy64");
\r
41 yamyPath += _T("yamy32");
\r
44 yamyPath += _T("yamy32");
\r
47 result = CreateProcess(yamyPath.c_str(), NULL, NULL, NULL, FALSE,
\r
48 NORMAL_PRIORITY_CLASS, 0, NULL, &si, &pi);
\r
50 if (result == FALSE) {
\r
55 LoadString(i_hInstance, IDS_cannotInvoke,
\r
56 text, sizeof(text)/sizeof(text[0]));
\r
57 LoadString(i_hInstance, IDS_mayu,
\r
58 title, sizeof(title)/sizeof(title[0]));
\r
59 _stprintf_s(buf, sizeof(buf)/sizeof(buf[0]),
\r
60 text, yamyPath, GetLastError());
\r
61 MessageBox((HWND)NULL, buf, title, MB_OK | MB_ICONSTOP);
\r
63 CloseHandle(pi.hThread);
\r
64 CloseHandle(pi.hProcess);
\r