static HRESULT WINAPI ActiveIMMApp_DisableIME(IActiveIMMApp* This, DWORD idThread) { BOOL rc; rc = ImmDisableIME(idThread); if (rc) return S_OK; else return E_FAIL; }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { // 防止服务进程开启输入法 ImmDisableIME(-1); HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. //HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); RimeSetupLogging("rime.weasel"); // command line option /q stops the running server bool quit = !wcscmp(L"/q", lpstrCmdLine) || !wcscmp(L"/quit", lpstrCmdLine); //bool restart = !wcscmp(L"/restart", lpstrCmdLine); //if (quit || restart) { weasel::Client client; if (client.Connect()) client.ShutdownServer(); if (quit) return 0; } int nRet = 0; try { WeaselServerApp app; nRet = app.Run(); } catch (...) { // bad luck... nRet = -1; } _Module.Term(); ::CoUninitialize(); return nRet; }
CRotateDispWnd::CRotateDispWnd(CWnd* pParent /*=NULL*/) { //{{AFX_DATA_INIT(CRotateDispWnd) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT msg_tray=RegisterWindowMessage("WM_APP_WM_USER_TRAY_RotateDisp"); msg_bar=RegisterWindowMessage("TaskbarCreated"); m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); hDlgWnd=NULL; ImmDisableIME(-1); IsAboutDlgShow=false; IsMouseDllOk=false; if(PathFileExists("RotateMouse.dll")) IsMouseDllOk=true; }
int main(int argc, char**argv) { Q_INIT_RESOURCE(xsys); Q_INIT_RESOURCE(dwidget); QApplication app(argc, argv); ImmDisableIME(GetCurrentThreadId()); InstallLogHandler(); LoadFonts(); LoadTranslate(app); MainWindow w; w.setWindowTitle (DeepinInstaller::AppTitle()); w.setWindowIcon(QIcon(":/data/deepin-system-installer.png")); w.show(); int ret = app.exec(); qDebug()<<"app.exec() return with"<<ret; return 0; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); ImmDisableIME(-1); // 检查单例,并通知旧程序 HANDLE mutex = ::CreateMutex(NULL, TRUE, repeat_run); if (::GetLastError() == ERROR_ALREADY_EXISTS) { UINT WM_REPEAT_RUN = ::RegisterWindowMessage(repeat_run); ::PostMessage(HWND_BROADCAST, WM_REPEAT_RUN, 0, 0); ::CloseHandle(mutex); return 0; } InitializeVirtualDesktopManagerInternal(); // 加载lua引擎 lua_engine = new LuaEngine(); // 加载配置 Config::Init(); // 启动程序 Window wnd; if (!wnd.Create(NULL, CRect(0, 0, 400, 400), app_name, WS_CAPTION)) { return 0; } // wnd.ShowWindow(nCmdShow); // 消息循环 WTL::CMessageLoop msgLoop; int ret = msgLoop.Run(); delete lua_engine; return ret; }
int RetRotMainLoop() { isStarted = true; HWND hWnd; WNDCLASSEXA winc; MSG msg; HINSTANCE hInstance = GetModuleHandle(NULL); g_pixSz = Settings.initialPixelSize; g_fullScr = Settings.initialFullScrMode; ImmDisableIME((DWORD)-1); winc.cbSize = sizeof(WNDCLASSEX); winc.style = CS_HREDRAW | CS_VREDRAW; winc.lpfnWndProc = WndProc; winc.cbClsExtra = 0; winc.cbWndExtra = 0; winc.hInstance = hInstance; winc.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(Settings.icon), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED); winc.hIconSm = NULL; winc.hCursor = (HCURSOR)LoadImage(NULL, IDC_ARROW, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED); winc.hbrBackground = CreateSolidBrush(GetSysColor(COLOR_MENU)); winc.lpszMenuName = NULL; winc.lpszClassName = "MAIN"; if (!RegisterClassExA(&winc)) { return 0; } SIZE sz = GetWindowSize(); if (Settings.WndMenu != NULL) { hWndMenu = Settings.WndMenu; } else { hWndMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(Settings.WndMenuID)); } hWnd = CreateWindowA( "MAIN", Settings.title, g_fullScr ? WS_FULLSCRMODE : (Settings.ScreenOnly ? WS_WINDOWMODE_NOFRAME : WS_WINDOWMODE), g_fullScr ? 0 : CW_USEDEFAULT, g_fullScr ? 0 : CW_USEDEFAULT, sz.cx, sz.cy, NULL, hWndMenu != NULL ? hWndMenu : NULL, hInstance, NULL ); if (hWnd == NULL) { return 0; } FpsControl fc; do { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { BOOL ret = GetMessage(&msg, NULL, 0, 0); if (ret == 0 || ret == -1) { break; } DispatchMessage(&msg); } else { Sleep(1); } } while (msg.message != WM_QUIT); isStarted = false; return (int)msg.wParam; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); MSG msg; //HACCEL hAccelTable; int bnum; RECT screen; TCHAR ini_fname[256]; // グローバル文字列を初期化しています。 LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_CONEMU_WIN, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // 表示領域の定義 // 必要以外の再書き換えを防止する screen.left = 0; screen.right = 650; screen.top = 0; screen.bottom = 399; // ini ファイルから設定を読む if (MakeIniFileName(_T("CONEMU.ini"), ini_fname)) { int value; value = GetPrivateProfileInt(_T("FRAMERATE"), _T("FPS"), 7, ini_fname); switch (value) { case 60: FPSmode = FPS60; break; case 30: FPSmode = FPS30; break; case 15: FPSmode = FPS15; break; default: FPSmode = FPS07; break; } Offset_X2 = GetPrivateProfileInt(_T("200LINES"), _T("OFFSET_X"), 20, ini_fname); Offset_Y2 = GetPrivateProfileInt(_T("200LINES"), _T("OFFSET_Y"), 34, ini_fname); Offset_X4 = GetPrivateProfileInt(_T("400LINES"), _T("OFFSET_X"), 20, ini_fname); Offset_Y4 = GetPrivateProfileInt(_T("400LINES"), _T("OFFSET_Y"), 34, ini_fname); } // USB 初期化 if (InitUSB()) { MessageBox(NULL, _T("初期化に失敗しました。\r\nケーブルの接続を確認してください。"), _T("エラー"), MB_OK); return 1; } reallocDIB(); ImmDisableIME(-1); // アプリケーションの初期化を実行します: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } // 画面描画ポジションテーブル for (size_t i = 0; i < 400; i++) { ppos[i] = g_lppxDIB + RowBytes * ((Lines - 1) - i); } // メイン メッセージ ループ: while (true) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!(GetMessage(&msg, NULL, 0, 0))) { // USB 解放 TrashUSB(); // ini ファイルに設定を書き込み if (MakeIniFileName(_T("CONEMU.ini"), ini_fname)) { TCHAR cstr[10]; switch (FPSmode) { case FPS60: wsprintf(cstr, _T("60")); break; case FPS30: wsprintf(cstr, _T("30")); break; case FPS15: wsprintf(cstr, _T("15")); break; case FPS07: wsprintf(cstr, _T("07")); break; default: break; } WritePrivateProfileString(_T("FRAMERATE"), _T("FPS"), cstr, ini_fname); wsprintf(cstr, _T("%d"), Offset_X2); WritePrivateProfileString(_T("200LINES"), _T("OFFSET_X"), cstr, ini_fname); wsprintf(cstr, _T("%d"), Offset_Y2); WritePrivateProfileString(_T("200LINES"), _T("OFFSET_Y"), cstr, ini_fname); wsprintf(cstr, _T("%d"), Offset_X4); WritePrivateProfileString(_T("400LINES"), _T("OFFSET_X"), cstr, ini_fname); wsprintf(cstr, _T("%d"), Offset_Y4); WritePrivateProfileString(_T("400LINES"), _T("OFFSET_Y"), cstr, ini_fname); } return (int)msg.wParam; } TranslateMessage(&msg); DispatchMessage(&msg); } else { bnum = ConvPixel(); switch (bnum) { case 0: // まだ1ライン分のデータが揃ってない break; case 399: // 最下行のデータを受信 InvalidateRect(hWnd, &screen, FALSE); break; default: break; } } } }
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { // 防止服务进程开启输入法 ImmDisableIME(-1); { WCHAR user_name[20] = {0}; DWORD size = _countof(user_name); GetUserName(user_name, &size); if (!_wcsicmp(user_name, L"SYSTEM")) { return 1; } } HRESULT hRes = ::CoInitialize(NULL); // If you are running on NT 4.0 or higher you can use the following call instead to // make the EXE free threaded. This means that calls come in on a random RPC thread. //HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); ATLASSERT(SUCCEEDED(hRes)); // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used ::DefWindowProc(NULL, 0, 0, 0L); AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls hRes = _Module.Init(NULL, hInstance); ATLASSERT(SUCCEEDED(hRes)); if (!wcscmp(L"/userdir", lpstrCmdLine)) { CreateDirectory(WeaselUserDataPath().c_str(), NULL); WeaselServerApp::explore(WeaselUserDataPath()); return 0; } if (!wcscmp(L"/weaseldir", lpstrCmdLine)) { WeaselServerApp::explore(WeaselServerApp::install_dir()); return 0; } // command line option /q stops the running server bool quit = !wcscmp(L"/q", lpstrCmdLine) || !wcscmp(L"/quit", lpstrCmdLine); // restart if already running { weasel::Client client; if (client.Connect()) // try to connect to running server { client.ShutdownServer(); } if (quit) return 0; } bool check_updates = !wcscmp(L"/update", lpstrCmdLine); if (check_updates) { WeaselServerApp::check_update(); } CreateDirectory(WeaselUserDataPath().c_str(), NULL); int nRet = 0; try { WeaselServerApp app; nRet = app.Run(); } catch (...) { // bad luck... nRet = -1; } _Module.Term(); ::CoUninitialize(); return nRet; }