HWND FindConsoleHandle() { const char alphabet[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; char title[33]; char old_title[512]; size_t size = sizeof(title); size_t i; for (i = 0; i < size - 1; ++i) { title[i] = alphabet[rand() % (int)(sizeof(alphabet) - 1)]; } title[i] = '\0'; if (GetConsoleTitleA(old_title, sizeof(old_title) / sizeof(old_title[0])) == 0) { return NULL; } SetConsoleTitleA(title); Sleep(40); HWND wnd = FindWindowA(NULL, title); SetConsoleTitleA(old_title); if (wnd == NULL) { wnd = GetConsoleWindow(); if (wnd == NULL) { dbg_printf("Didn't find wnd (tried FindWindowA and GetConsoleWindow)\n"); } } return wnd; }
// from http://support.microsoft.com/kb/124103/ HWND GetConsoleHwnd(void) { HWND hwndFound; char pszNewWindowTitle[128]; char pszOldWindowTitle[128]; GetConsoleTitleA(pszOldWindowTitle, 128); wsprintfA(pszNewWindowTitle,"%d/%d", GetTickCount(), GetCurrentProcessId()); SetConsoleTitleA(pszNewWindowTitle); Sleep(40); hwndFound = FindWindowA(NULL, pszNewWindowTitle); SetConsoleTitleA(pszOldWindowTitle); return hwndFound; }
void SDLStub::init(const char *title) { putenv((char *)"SDL_VIDEO_WINDOW_POS"); putenv((char *)"SDL_VIDEO_CENTERED=1"); #ifdef _WIN32 SetConsoleTitleA(title); #endif SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption(title, NULL); int x, y; SDL_GetMouseState( &x,&y ); SDL_ShowCursor( SDL_ENABLE ); SDL_WarpMouse( x, y ); memset(&input, 0, sizeof(input)); _offscreen = (uint8_t *)malloc(SCREEN_W * SCREEN_H * 2); if (!_offscreen) { error("Unable to allocate offscreen buffer"); } _fullscreen = false; _scaler = 1; prepareGfxMode(); }
/*********************************************************************** * pif_cmd * * execute a pif file. */ static VOID pif_cmd( char *filename, char *cmdline) { HANDLE hFile; char progpath[MAX_PATH]; char buf[128]; char progname[64]; char title[31]; char optparams[65]; char startdir[65]; char *p; int closeonexit; int textmode; if( (hFile = CreateFileA( filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE) { WINE_ERR("open file %s failed\n", wine_dbgstr_a(filename)); return; } if( !read_pif_file( hFile, progname, title, optparams, startdir, &closeonexit, &textmode)) { WINE_ERR( "failed to read %s\n", wine_dbgstr_a(filename)); CloseHandle( hFile); sprintf( buf, "%s\nInvalid file format. Check your pif file.", filename); MessageBoxA( NULL, buf, "16 bit DOS subsystem", MB_OK|MB_ICONWARNING); SetLastError( ERROR_BAD_FORMAT); return; } CloseHandle( hFile); if( (p = strrchr( progname, '.')) && !strcasecmp( p, ".bat")) WINE_FIXME(".bat programs in pif files are not supported.\n"); /* first change dir, so the search below can start from there */ if( startdir[0] && !SetCurrentDirectoryA( startdir)) { WINE_ERR("Cannot change directory %s\n", wine_dbgstr_a( startdir)); sprintf( buf, "%s\nInvalid startup directory. Check your pif file.", filename); MessageBoxA( NULL, buf, "16 bit DOS subsystem", MB_OK|MB_ICONWARNING); } /* search for the program */ if( !SearchPathA( NULL, progname, NULL, MAX_PATH, progpath, NULL )) { sprintf( buf, "%s\nInvalid program file name. Check your pif file.", filename); MessageBoxA( NULL, buf, "16 bit DOS subsystem", MB_OK|MB_ICONERROR); SetLastError( ERROR_FILE_NOT_FOUND); return; } if( textmode) if( AllocConsole()) SetConsoleTitleA( title) ; /* if no arguments on the commandline, use them from the pif file */ if( !cmdline[0] && optparams[0]) cmdline = optparams; /* FIXME: do something with: * - close on exit * - graphic modes * - hot key's * - etc. */ start_dos_exe( progpath, cmdline ); }
int main(int argc, char *argv[]) { #ifndef _WIN32 signal(SIGINT, SignalHandleFunction); signal(SIGTERM, SignalHandleFunction); #ifdef SIGBREAK signal(SIGBREAK, SignalHandleFunction); #endif #else SetConsoleCtrlHandler(ConsoleHandlerRoutine, 1); EnableScrollBar(GetConsoleWindow(), SB_BOTH, ESB_DISABLE_BOTH); HANDLE l_handle = GetStdHandle(STD_INPUT_HANDLE); DWORD l_handleMode; GetConsoleMode(l_handle, &l_handleMode); SetConsoleMode(l_handle, l_handleMode & ~ENABLE_QUICK_EDIT_MODE); l_handle = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO l_sbInfo; GetConsoleScreenBufferInfo(l_handle, &l_sbInfo); l_sbInfo.dwSize.Y = l_sbInfo.srWindow.Bottom + 1; SetConsoleWindowInfo(l_handle, TRUE, &l_sbInfo.srWindow); SetConsoleScreenBufferSize(l_handle, l_sbInfo.dwSize); SetConsoleTitleA("RunOnCoal Server"); #endif ROC::Core *l_core = ROC::Core::Init(); while(!g_quitSetter) l_core->DoPulse(); ROC::Core::Terminate(); return EXIT_SUCCESS; }
void CreateConsole() { AllocConsole(); HANDLE lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); int hConHandle = _open_osfhandle(PtrToUlong((ULONG)lStdHandle), _O_TEXT); FILE* fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); lStdHandle = GetStdHandle(STD_INPUT_HANDLE); hConHandle = _open_osfhandle(PtrToUlong((ULONG)lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "r"); *stdin = *fp; setvbuf(stdin, NULL, _IONBF, 0); lStdHandle = GetStdHandle(STD_ERROR_HANDLE); hConHandle = _open_osfhandle(PtrToUlong((ULONG)lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "w"); *stderr = *fp; setvbuf(stderr, NULL, _IONBF, 0); ::SetConsoleMode( lStdHandle, ENABLE_ECHO_INPUT ); char szStr[64] = {0}; sprintf_s( szStr, "vIrtuaL W0rLd - Build: %s %s", __DATE__, __TIME__ ); SetConsoleTitleA( szStr ); }
static void play() { if (!player) return; player->Unload(); if (sound_playing) fmodwrap::DestroySound(sound_playing); recored_list_log(current_sound); sound_playing = fmodwrap::CreateSound(sounds[current_sound]); if (!sound_playing) { next(true); return; } player->Load(sound_playing); player->Play(false); while (list_start + MAX_LIST_INDEX < current_sound) uplist(); while (list_start > current_sound) downlist(); need_next = false; char title[256]; sprintf_s(title, sizeof(title), "%-0.60s - %s", sounds[current_sound] + 2, "CONSOLE PLAYER"); SetConsoleTitleA(title); }
void Log::CreateConsole(LPCSTR caption) { AllocConsole(); AttachConsole(GetCurrentProcessId()); freopen("CON", "w", stdout); //-V530 SetConsoleTitleA(caption); }
void InitConsole() { AllocConsole(); SetConsoleTitleA("Filesystem tests"); int hConHandle; FILE *fp; // redirect unbuffered STDOUT to the console HANDLE __hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle((long)__hStdOut, _O_TEXT); fp = _fdopen( hConHandle, "w" ); *stdout = *fp; setvbuf( stdout, NULL, _IONBF, 0 ); std::cout.clear(); // redirect unbuffered STDERR to the console HANDLE __hStdError = GetStdHandle(STD_ERROR_HANDLE); hConHandle = _open_osfhandle((long)__hStdError, _O_TEXT); fp = _fdopen( hConHandle, "w" ); *stderr = *fp; setvbuf( stderr, NULL, _IONBF, 0 ); std::cerr.clear(); //DebugBreak(); }
int main() { SetConsoleTitleA("Zadanie 3"); cout << "Jeden algorytm, obliczanie sumy,sumy kwadratow i srednia arytmetyczna\n\n"; system("pause"); system("cls"); int a,b; bool typ=false; while (typ==false) { system("cls"); cout << "Podaj wartoœæ liczby a: "; cin >> a; cout << "Podaj wartoœæ liczby b: "; cin >> b; if (!cin) { cin.clear(); cin.sync(); } else { typ=true; } } cout<<"Suma="<<a+b<<endl; cout<<"Suma kwadratu="<<a*a+2*(a*b)+b*b<<endl; cout<<"Œrednia="<<sredniasumyliczb(a,b)<<endl; system("pause"); return 0; }
int main() { char filename[MAX_PATH]={0}; SetConsoleTitleA("Simple PE64 Viewer"); bgn: printf("Simple PE64 Viewer\n====================\nAuthor: Tesla.Angela\nVersion: 0.01\nSupport: PE32+ file\n\n\n"); printf("输入文件名(支持文件拖拽,直接按回车则默认打开ntoskrnl.exe,输入exit退出):"); gets(filename); if (FileLen(filename)==0) { if( stricmp(filename,"exit") ) { CopyFileA("c:\\windows\\system32\\ntoskrnl.exe","c:\\ntoskrnl.exe",0); strcpy(filename,"c:\\ntoskrnl.exe"); printf("c:\\ntoskrnl.exe\n"); } else goto end; } ShowPE64Info(filename); clrscr(); goto bgn; end: DeleteFileA("c:\\ntoskrnl.exe"); return 0; }
void createWindowsConsole() { if(consoleWindow !=0) return; //create a console on Windows so users can see messages //find an available name for our window int console_suffix = 0; char consoleTitle[512]; sprintf(consoleTitle, "%s", "Gource Console"); while(FindWindowA(0, consoleTitle)) { sprintf(consoleTitle, "Gource Console %d", ++console_suffix); } AllocConsole(); SetConsoleTitleA(consoleTitle); //redirect streams to console freopen("conin$", "r", stdin); freopen("conout$","w", stdout); freopen("conout$","w", stderr); consoleWindow = 0; //wait for our console window while(consoleWindow==0) { consoleWindow = FindWindowA(0, consoleTitle); SDL_Delay(100); } //disable the close button so the user cant crash gource HMENU hm = GetSystemMenu(consoleWindow, false); DeleteMenu(hm, SC_CLOSE, MF_BYCOMMAND); }
void CreateConsole(const char *winTitle) { //http://www.gamedev.net/community/forums/viewreply.asp?ID=1958358 int hConHandle = 0; HANDLE lStdHandle = 0; FILE *fp = 0 ; AllocConsole(); if(winTitle) SetConsoleTitleA(winTitle); // redirect unbuffered STDOUT to the console lStdHandle = GetStdHandle(STD_OUTPUT_HANDLE); hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "w"); *stdout = *fp; setvbuf(stdout, NULL, _IONBF, 0); // redirect unbuffered STDIN to the console lStdHandle = GetStdHandle(STD_INPUT_HANDLE); hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "r"); *stdin = *fp; setvbuf(stdin, NULL, _IONBF, 0); // redirect unbuffered STDERR to the console lStdHandle = GetStdHandle(STD_ERROR_HANDLE); hConHandle = _open_osfhandle(PtrToUlong(lStdHandle), _O_TEXT); fp = _fdopen(hConHandle, "w"); *stderr = *fp; setvbuf(stderr, NULL, _IONBF, 0); }
void Sys_CreateConsole() { FreeConsole(); AllocConsole(); SetConsoleTitleA("IW3 Console - Uber Alpha test version 0.1"); freopen("CON", "w", stdout); // Reset stdout to console output Com_Printf(0, "Running in console mode!\n"); }
// edit line initalise EditLine * el_init (const char *, FILE *, FILE *, FILE *) { // SetConsoleTitleA( "lldb" ); // return dummy handle return (EditLine*) -1; }
scCore::scCore(string const& cfgFilePath, bool useConsole/*= false*/) : mUseConsole(useConsole), mRenderer(0), mGameWorldManager(0), mTimeLineManager(0), mEventRouter(0) { if (mUseConsole) { // 创建控制台窗口,并将标准输入流,标准输出流和标准错误流重定向至控制台 if( !AllocConsole() ) MessageBoxA(NULL, "控制台生成失败。", NULL, 0); SetConsoleTitleA("Debug Window"); freopen_s(&fpDebugOut, "CONOUT$","w", stdout); freopen_s(&fpDebugIn, "CONIN$", "r", stdin); freopen_s(&fpDebugErr, "CONOUT$","w", stderr); setlocale(LC_ALL, "chs"); std::cout << "控制台已创建!" << std::endl; } // 初始化渲染子系统 mRenderer = new scRenderer("resources_d.cfg", "plugins_d.cfg"); // 初始化输入子系统 u32 windowHnd = 0; mRenderer->getOgreRoot()->getAutoCreatedWindow()->getCustomAttribute("WINDOW", &windowHnd); u32 winWidth, winHeight, colDepth; i32 winLeft, winTop; mRenderer->getOgreRoot()->getAutoCreatedWindow()->getMetrics(winWidth, winHeight, colDepth, winLeft, winTop); mInputManager = new scInputManager(windowHnd, winWidth, winHeight); // 初始化事件路由器 mEventRouter = new scEventRouter(); // 初始化游戏世界管理类 mGameWorldManager = new scGameWorldManager(); // 初始化动画管理类 mAnimationManager = new scAnimationManager(); // 创建时间轴管理类 mTimeLineManager = new scTimeLineManager(); // 创建渲染和输入时间轴,60hz scTimeLinePtr tl = mTimeLineManager->createTimeLine("Render", 60); tl->addRunCallBack("Render", [&](u32 dtms)->bool{return mRenderer->_run(dtms);}); tl->addRunCallBack("Input", [&](u32 dtms)->bool{mInputManager->_run(); return true;}); // 创建动画时间轴,60hz tl = mTimeLineManager->createAnimationTimeLine("Animation", 60); // 创建事件路由时间轴, 无时间间隔(新线程) tl = mTimeLineManager->createTimeLine("Event", 1000, 0, true); tl->addRunCallBack("Event", [&](u32 dtms)->bool{mEventRouter->_run(); return true;}); // 创建游戏世界时间轴, 60Hz tl = mTimeLineManager->createTimeLine("GameWorld", 60); tl->addRunCallBack("GameWorld", [&](u32 dtms)->bool{return mGameWorldManager->_run(dtms);}); // 创建背景加载时间轴,10Hz(新线程) //tl = mTimeLineManager->createTimeLine("BackgroundLoading", 10, 0, true); // 测试一下 scGameWorldPtr gw(new scGameWorld("test", "testini.lua", "iniScene")); mGameWorldManager->addGameWorld(gw->getName(), gw); mGameWorldManager->initializeGameWorld("test"); }
void __stdcall LoggerCore(PVOID pVoid) { while (true) { AllocConsole(); SetConsoleTitleA(Log.LoggerTittle()); Sleep(1000); } _endthread(); }
int main(int argc, char *argv[]) { CConsole console; QApplication a(argc, argv); QApplication::setStyle(QStyleFactory::create("fusion")); ClientMain w; w.showMaximized(); SetConsoleTitleA("IStrategizer BWAPI Client"); return a.exec(); }
//------------------------------------------------------ //- Start //------------------------------------------------------ void __stdcall LoggerCore(PVOID pVoid) { char title[100]; sprintf(title,CONSOLETITLE,SERVER_VERSION,SERVER_SEASON); AllocConsole(); system("color f0"); SetConsoleTitleA(title); while(true) Sleep(10); }
void Utils::AllocateConsole(LPCSTR pTitle) { AllocConsole() ; AttachConsole(GetCurrentProcessId()); freopen("CON", "w", stdout) ; SetConsoleTitleA(pTitle); COORD cordinates = {80, 32766}; HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleScreenBufferSize(handle, cordinates); }
void UI::PrintMainScreen(){ SetConsoleTitleA("SolMe"); PrintLogo(); cout<<"\t\t\t\t START (1)\n\n"; cout<<"\t\t\t\tStatisztika (2)\n"; cout<<"\t\t\t\tBeallitasok (3)\n\n\n\n\n\n"; cout<<"\t\tSugo (4)\n"; cout<<"\t\tNevjegy (5)"; cout<<"\t\t\t Kilepes (0)\n"; }
JNIEXPORT void JNICALL Java_JoshNative__1SetJavaConsoleTitle (JNIEnv* env, jclass, jstring title) { const char *nativeString = (*env).GetStringUTFChars(title, 0); #ifdef _WIN32 SetConsoleTitleA(nativeString); // I don't like LPCWSTR. Yuck! #elif __APPLE__ char str[256]; strcat(str, "sh title.sh "); strcat(str, nativeString); #endif }
static HWND beeFindMainWindow() { HWND hWnd = 0; char title[1024]; char title_tmp[8 + 8 + 2]; // ищем обычное окно EnumWindows(beeEnumWindowsProc, (LPARAM)&hWnd); if (hWnd != 0) return hWnd; // ищем консольное окно (http://support.microsoft.com/kb/124103) if (GetConsoleTitleA(title, sizeof(title)) == 0) return 0; sprintf(title_tmp, "%08X/%08X", GetTickCount(), GetCurrentProcessId()); if (!SetConsoleTitleA(title_tmp)) return 0; Sleep(40); hWnd = FindWindowA(NULL, title_tmp); SetConsoleTitleA(title); return hWnd; }
void dbg_init_console(void) { /* set the output handle */ dbg_houtput = GetStdHandle(STD_OUTPUT_HANDLE); /* set our control-C handler */ SetConsoleCtrlHandler(ctrl_c_handler, TRUE); /* set our own title */ SetConsoleTitleA("Wine Debugger"); }
application::application() { timeBeginPeriod(1); # if defined(WIN32) // console window typedef HWND (WINAPI *GetConsoleWindowFn)(void); HMODULE l_kernel32_h = GetModuleHandleA("kernel32.dll"); GetConsoleWindowFn GetConsoleWindow = (GetConsoleWindowFn)GetProcAddress(l_kernel32_h, "GetConsoleWindow"); if(GetConsoleWindow != 0) ShowWindow(GetConsoleWindow(), SW_MAXIMIZE); SetConsoleTitleA(" bikini-iii"); # endif }
void UpdateMemoryStatus(){ PROCESS_MEMORY_COUNTERS pmc; if ( GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)) ) { char msg[256]; sprintf(msg, "SocialMe Server / %dKb", pmc.WorkingSetSize / 1024); SetConsoleTitleA(msg); } }
void Console::SetTitle(const char *_title) { CoreAssert(this != NULL); #ifdef TARGET_OS_WINDOWS SetConsoleTitleA(_title); #else #if 0 /* Random bug just cropped up round this. */ char buffer[4096]; sprintf(buffer, "\033]2;%s\007", _title); Write(buffer); #endif #endif }
void PDC_set_title(const char *title) { #ifdef PDC_WIDE wchar_t wtitle[512]; #endif PDC_LOG(("PDC_set_title() - called:<%s>\n", title)); #ifdef PDC_WIDE PDC_mbstowcs(wtitle, title, 511); SetConsoleTitleW(wtitle); #else SetConsoleTitleA(title); #endif }
static void init() { SetConsoleTitleA("CONSOLE PLAYER"); COORD size = {80, 25}; SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), size); SMALL_RECT rect = {0, 0, 80, 25}; SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), false, &rect); fmodwrap::Open(); create_list(); player = fmodwrap::CreatePlayer(); player->set_endcallback(on_play_end); fmodwrap::master_volume(0.5f); current_sound = restore_list_log(); }
void __stdcall LoggerCore(PVOID pVoid) { char Temp[1024]; // ---- AllocConsole(); SetConsoleTitleA(CONSOLETITLE); // ---- while(true) { Sleep(100); g_Console.AddMessageToConsole(Temp); g_Console.LoadConsoleCommands(Temp); } }