如题:
在代码的入口处加入:
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) { if (try_show_first_windows(NULL, "魔方服务控制台")) { return 0; }
try_show_first_windows的实现为:
BOOL try_show_first_windows(LPCSTR cls, LPCSTR wnd_cap) { HWND hTheWest = FindWindowA(cls, wnd_cap); if (hTheWest) { CWindow cds; cds.Attach(hTheWest); cds.ShowWindow(SW_RESTORE); cds.SetWindowPos(HWND_TOP, NULL, NULL, NULL, NULL, SWP_NOSIZE | SWP_NOREPOSITION); cds.CenterWindow(hTheWest); return TRUE; } else { return FALSE; } }