1 // xkeymacs.cpp : Defines the class behaviors for the application.
\r
5 #include "xkeymacs.h"
\r
10 #define new DEBUG_NEW
\r
12 static char THIS_FILE[] = __FILE__;
\r
15 /////////////////////////////////////////////////////////////////////////////
\r
18 BEGIN_MESSAGE_MAP(CXkeymacsApp, CWinApp)
\r
19 //{{AFX_MSG_MAP(CXkeymacsApp)
\r
20 // NOTE - the ClassWizard will add and remove mapping macros here.
\r
21 // DO NOT EDIT what you see in these blocks of generated code!
\r
25 /////////////////////////////////////////////////////////////////////////////
\r
26 // CXkeymacsApp construction
\r
28 CXkeymacsApp::CXkeymacsApp()
\r
34 /////////////////////////////////////////////////////////////////////////////
\r
35 // The one and only CXkeymacsApp object
\r
37 CXkeymacsApp theApp;
\r
39 /////////////////////////////////////////////////////////////////////////////
\r
40 // CXkeymacsApp initialization
\r
42 BOOL CXkeymacsApp::InitInstance()
\r
44 // AfxEnableControlContainer();
\r
46 // Standard initialization
\r
47 // If you are not using these features and wish to reduce the size
\r
48 // of your final executable, you should remove from the following
\r
49 // the specific initialization routines you do not need.
\r
50 m_hMutex = CreateMutex(FALSE, 0, CString(MAKEINTRESOURCE(AFX_IDS_APP_TITLE)));
\r
51 if (GetLastError() == ERROR_ALREADY_EXISTS) {
\r
52 CloseHandle(m_hMutex);
\r
58 Enable3dControls(); // Call this when using MFC in a shared DLL
\r
60 Enable3dControlsStatic(); // Call this when linking to MFC statically
\r
63 // Change the registry key under which our settings are stored.
\r
64 SetRegistryKey(IDS_REGISTRY_KEY);
\r
66 // LoadStdProfileSettings(); // Load standard INI file options (including MRU)
\r
68 // Parse command line for standard shell commands, DDE, file open
\r
69 // CCommandLineInfo cmdInfo;
\r
70 // ParseCommandLine(cmdInfo);
\r
72 // Dispatch commands specified on the command line
\r
73 // if (!ProcessShellCommand(cmdInfo))
\r
76 // The one and only window has been initialized, so show and update it.
\r
77 m_pMainWnd = new CMainFrame;
\r
78 m_pMainWnd->ShowWindow(SW_HIDE);
\r
79 m_pMainWnd->UpdateWindow();
\r
80 SetClassLongPtr(m_pMainWnd->m_hWnd, GCLP_HICON, (LONG_PTR)LoadIcon(IDR_MAINFRAME));
\r
83 CUtils::InitCUtils();
\r
84 if (!Create64bitProcess())
\r
86 CProfile::InitDllData();
\r
91 BOOL CXkeymacsApp::IsWow64()
\r
96 BOOL CXkeymacsApp::Create64bitProcess()
\r
98 typedef BOOL (WINAPI *PFIsWow64Process)(HANDLE, PBOOL);
\r
99 PFIsWow64Process func = (PFIsWow64Process)GetProcAddress(GetModuleHandle(_T("kernel32")), _T("IsWow64Process"));
\r
101 return TRUE; // IsWow64Process not exists
\r
102 if (!func(GetCurrentProcess(), &m_bIsWow64))
\r
103 return FALSE; // error
\r
105 return TRUE; // do nothing
\r
107 TCHAR szFileName[MAX_PATH];
\r
108 if (!GetModuleFileName(NULL, szFileName, sizeof(szFileName)))
\r
110 TCHAR szDrive[_MAX_DRIVE], szDir[_MAX_DIR], szFile[_MAX_FNAME], szExt[_MAX_EXT];
\r
111 if (_tsplitpath_s(szFileName, szDrive, szDir, szFile, szExt) ||
\r
112 _tcscat_s(szFile, _T("64")) ||
\r
113 _tmakepath_s(szFileName, szDrive, szDir, szFile, szExt))
\r
117 ZeroMemory(&si, sizeof(si));
\r
118 si.cb = sizeof(si);
\r
119 PROCESS_INFORMATION pi;
\r
120 ZeroMemory(&pi, sizeof(pi));
\r
121 if (!CreateProcess(szFileName, NULL, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
\r
123 // close unused handles
\r
124 CloseHandle(pi.hProcess);
\r
125 CloseHandle(pi.hThread);
\r
129 BOOL CXkeymacsApp::SendIPCMessage(DWORD msg)
\r
134 return CallNamedPipe(IPC_PIPE, &msg, sizeof(msg), &ack, sizeof(DWORD), &read, 10000);
\r
137 int CXkeymacsApp::ExitInstance()
\r
140 ReleaseMutex(m_hMutex);
\r
141 CloseHandle(m_hMutex);
\r
143 m_pMainWnd->DestroyWindow();
\r
148 return CWinApp::ExitInstance();
\r