这篇教程C++ GetConsoleTitle函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetConsoleTitle函数的典型用法代码示例。如果您正苦于以下问题:C++ GetConsoleTitle函数的具体用法?C++ GetConsoleTitle怎么用?C++ GetConsoleTitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetConsoleTitle函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: open_consolevoid open_console(){ char title[MAX_PATH]={0}; HWND hcon; FILE *hf; static BYTE consolecreated=FALSE; static int hcrt=0; if(consolecreated==TRUE) { GetConsoleTitle(title,sizeof(title)); if(title[0]!=0){ hcon=FindWindow(NULL,title); ShowWindow(hcon,SW_SHOW); } hcon=(HWND)GetStdHandle(STD_INPUT_HANDLE); FlushConsoleInputBuffer(hcon); return; } AllocConsole(); hcrt=_open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE),_O_TEXT); fflush(stdin); hf=_fdopen(hcrt,"w"); *stdout=*hf; setvbuf(stdout,NULL,_IONBF,0); GetConsoleTitle(title,sizeof(title)); if(title[0]!=0){ hcon=FindWindow(NULL,title); ShowWindow(hcon,SW_SHOW); SetForegroundWindow(hcon); } consolecreated=TRUE;}
开发者ID:pinchyCZN,项目名称:ucommander,代码行数:34,
示例2: GetConsoleHwndHWND GetConsoleHwnd() { HWND hwndFound; TCHAR pszNewWindowTitle[kTitleBufSize]; TCHAR pszOldWindowTitle[kTitleBufSize]; GetConsoleTitle(pszOldWindowTitle, kTitleBufSize); // Format a "unique" NewWindowTitle. wsprintf(pszNewWindowTitle,TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId()); SetConsoleTitle(pszNewWindowTitle); // Ensure window title has been updated. Sleep(40); hwndFound=FindWindow(NULL, pszNewWindowTitle); // Restore original window title. SetConsoleTitle(pszOldWindowTitle); return hwndFound;}
开发者ID:hoeysoft,项目名称:batclip,代码行数:25,
示例3: GetConsoleTitleHWND CSystem::GetConsoleHwnd(){ const int32_t bufsize = 1024; //This is what is returned to the caller. HWND hwndFound; // Contains fabricated char pszNewWindowTitle[bufsize]; // WindowTitle. // Contains original char pszOldWindowTitle[bufsize]; // WindowTitle. // Fetch current window title. GetConsoleTitle(pszOldWindowTitle, bufsize); // Format a "unique" NewWindowTitle. wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId()); // Change current window title. SetConsoleTitle(pszNewWindowTitle); // Ensure window title has been updated. Sleep(40); // Look for NewWindowTitle. hwndFound = FindWindow(NULL, pszNewWindowTitle); // Restore original window title. SetConsoleTitle(pszOldWindowTitle); return(hwndFound);}
开发者ID:xylsxyls,项目名称:xueyelingshuang,代码行数:25,
示例4: GetConsoleHwnd// GetConsoleHwnd() helper function from MSDN Knowledge Base Article Q124103// needed, because HWND GetConsoleWindow(VOID) is not avaliable under Win95/98/MEHWND GetConsoleHwnd(){ HWND hwndFound; // This is what is returned to the caller. char pszNewWindowTitle[1024]; // Contains fabricated WindowTitle char pszOldWindowTitle[1024]; // Contains original WindowTitle // Fetch current window title. GetConsoleTitle(pszOldWindowTitle, sizeof(pszOldWindowTitle)); // Format a "unique" NewWindowTitle. wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId()); // Change current window title. SetConsoleTitle(pszNewWindowTitle); // Ensure window title has been updated. Sleep(40); // Look for NewWindowTitle. hwndFound = FindWindow(nullptr, pszNewWindowTitle); // Restore original window title. SetConsoleTitle(pszOldWindowTitle); return hwndFound;}
开发者ID:theAsmodai,项目名称:rehlds,代码行数:28,
示例5: GetDebugWindowHandlestatic HWND GetDebugWindowHandle(void){ #define MY_BUFSIZE 1024 // Buffer size for console window titles. HWND hwndFound; // This is what is returned to the caller.#ifdef _UNICODE wchar_t pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated // WindowTitle. wchar_t pszOldWindowTitle[MY_BUFSIZE]; // Contains original // WindowTitle.#else char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated // WindowTitle. char pszOldWindowTitle[MY_BUFSIZE]; // Contains original // WindowTitle.#endif // Fetch current window title GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); // Format a "unique" NewWindowTitle. wsprintf(pszNewWindowTitle, _T("%d/%d"), GetTickCount(), GetCurrentProcessId()); // Change current window title. SetConsoleTitle(pszNewWindowTitle); // Ensure window title has been updated. Sleep(40); // Look for NewWindowTitle. hwndFound=FindWindow(NULL, pszNewWindowTitle); // Restore original window title. SetConsoleTitle(pszOldWindowTitle); return(hwndFound);} // end GetDebugWindowHandle()
开发者ID:Nhuongld,项目名称:nsj,代码行数:31,
示例6: rb_GetConsoleTitlestatic VALUE rb_GetConsoleTitle(VALUE self){ char title[1024]; if (GetConsoleTitle((char*)&title,1024)) return rb_str_new2( title ); return rb_getWin32Error();}
开发者ID:L2G,项目名称:win32console,代码行数:7,
示例7: GetConsoleTitle const std::string Console::GetTitle() { TCHAR title[MAX_PATH]; GetConsoleTitle( title, MAX_PATH ); return title; }
开发者ID:gallexme,项目名称:Captain-Hook,代码行数:7,
示例8: GetConsoleHwnd/* Direct from the horse's mouth: Microsoft KB article Q124103 */static HWNDGetConsoleHwnd (void){ HWND hwndFound; /* this is what is returned to the caller */ char pszNewWindowTitle[KLUDGE_BUFSIZE]; /* contains fabricated WindowTitle */ char pszOldWindowTitle[KLUDGE_BUFSIZE]; /* contains original WindowTitle */ /* fetch current window title */ GetConsoleTitle(pszOldWindowTitle, KLUDGE_BUFSIZE); /* format a "unique" NewWindowTitle */ wsprintf(pszNewWindowTitle,"%d/%d", GetTickCount(), GetCurrentProcessId()); /* change current window title */ SetConsoleTitle(pszNewWindowTitle); /* ensure window title has been updated */ Sleep(40); /* look for NewWindowTitle */ hwndFound=FindWindow(NULL, pszNewWindowTitle); /* restore original window title */ SetConsoleTitle(pszOldWindowTitle); return(hwndFound);}
开发者ID:boukeversteegh,项目名称:chise,代码行数:36,
示例9: GetConsoleHwnd//// Utility function to obtain a Console Window Handle (HWND), as explained in:// http://support.microsoft.com/kb/124103//HWND GetConsoleHwnd(void){#define MY_BUFSIZE 1024 // Buffer size for console window titles. HWND hwndFound; // This is what is returned to the caller. TCHAR pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated // WindowTitle. TCHAR pszOldWindowTitle[MY_BUFSIZE]; // Contains original // WindowTitle. // Fetch current window title. GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); // Format a "unique" NewWindowTitle. wsprintf(pszNewWindowTitle,TEXT("%d/%d"), GetTickCount(), GetCurrentProcessId()); // Change current window title. SetConsoleTitle(pszNewWindowTitle); // Ensure window title has been updated. Sleep(40); // Look for NewWindowTitle. hwndFound=FindWindow(NULL, pszNewWindowTitle); // Restore original window title. SetConsoleTitle(pszOldWindowTitle); return(hwndFound);}
开发者ID:evig-vandrar,项目名称:KITO,代码行数:35,
示例10: GetConsoleTitle// Need this to setup DirectXHWND Audio_DirectX::GetConsoleHwnd (){ // Taken from Microsoft Knowledge Base // Article ID: Q124103 #define MY_bufSize 1024 // buffer size for console window totles HWND hwndFound; // this is whta is returned to the caller char pszNewWindowTitle[MY_bufSize]; // contains fabricated WindowTitle char pszOldWindowTitle[MY_bufSize]; // contains original WindowTitle // fetch curent window title GetConsoleTitle (pszOldWindowTitle, MY_bufSize); // format a "unique" NewWindowTitle wsprintf (pszNewWindowTitle, "%d/%d", GetTickCount (), GetCurrentProcessId ()); // change the window title SetConsoleTitle (pszNewWindowTitle); // ensure window title has been updated Sleep (40); // look for NewWindowTitle hwndFound = FindWindow (NULL, pszNewWindowTitle); // restore original window title SetConsoleTitle (pszOldWindowTitle); return (hwndFound);}
开发者ID:woytekm,项目名称:QSID,代码行数:29,
示例11: mainint main(void){ HANDLE proc = OpenProcess( PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_CREATE_THREAD, FALSE, GetCurrentProcessId()); printMyBaseAddresses(proc); // get my PID from window wchar_t myTitle[1024]; GetConsoleTitle(&myTitle[0], 1024); HWND myWindow = FindWindow(NULL, myTitle); auto myPID = getPIDFromWindow(myWindow); printf("My pid is %d/n", myPID); // get explorer PID by process name auto explorerPID = getPIDByName(L"explorer.exe"); printf("Explorer pid is %d/n", explorerPID); // lets do some memory stuff.. to ourself DWORD someValue = 1234; readAndWriteMemoryAPI(proc, &someValue); readAndWriteMemoryMarshall(&someValue); system("pause");}
开发者ID:GameHackingBook,项目名称:GameHackingCode,代码行数:31,
示例12: InitTermcap/* For a few selected terminal types, we'll print in boldface, etc. * This isn't too important, though. */voidInitTermcap(void){#if (defined(WIN32) || defined(_WINDOWS)) && defined(_CONSOLE) gXterm = gXtermTitle = 0; gCurXtermTitleStr[0] = '/0'; tcap_normal = ""; tcap_boldface = ""; tcap_underline = ""; tcap_reverse = ""; gTerm = "MS-DOS Prompt"; ZeroMemory(gSavedConsoleTitle, (DWORD) sizeof(gSavedConsoleTitle)); GetConsoleTitle(gSavedConsoleTitle, (DWORD) sizeof(gSavedConsoleTitle) - 1); SetConsoleTitle("NcFTP"); gXterm = gXtermTitle = 1;#else const char *term; gXterm = gXtermTitle = 0; gCurXtermTitleStr[0] = '/0'; if ((gTerm = getenv("TERM")) == NULL) { tcap_normal = ""; tcap_boldface = ""; tcap_underline = ""; tcap_reverse = ""; return; } term = gTerm; if ( (strstr(term, "xterm") != NULL) || (strstr(term, "rxvt") != NULL) || (strstr(term, "dtterm") != NULL) || (ISTRCMP(term, "scoterm") == 0) ) { gXterm = gXtermTitle = 1; } if ( (gXterm != 0) || (strcmp(term, "vt100") == 0) || (strcmp(term, "linux") == 0) || (strcmp(term, "vt220") == 0) || (strcmp(term, "vt102") == 0) ) { tcap_normal = "/033[0m"; /* Default ANSI escapes */ tcap_boldface = "/033[1m"; tcap_underline = "/033[4m"; tcap_reverse = "/033[7m"; } else { tcap_normal = ""; tcap_boldface = ""; tcap_underline = ""; tcap_reverse = ""; }#endif} /* InitTermcap */
开发者ID:GYGit,项目名称:reactos,代码行数:61,
示例13: GetStdHandleDWORD ConsoleUI::Activate(LPCTSTR pszTitle){ CONSOLE_SCREEN_BUFFER_INFO conInfo; // Console screen buffer info Buffer<TCHAR> strConTitle; // Console title string buffer // Attempt to lock the console handles. The only way this can fail is if // the underlying kernel object(s) were not properly created if(!LockConsole(true)) return ERROR_INVALID_HANDLE; // Check to see if the input/output handles have already been initialized if(m_hin != m_hout) { UnlockConsole(); return ERROR_ALREADY_INITIALIZED; } // Retrieve the STDIN/STDOUT handles for this process. If they are both set // to INVALID_HANDLE_VALUE, this process is not attached to a console m_hin = GetStdHandle(STD_INPUT_HANDLE); m_hout = GetStdHandle(STD_OUTPUT_HANDLE); if(m_hin == m_hout) { UnlockConsole(); return ERROR_INVALID_HANDLE; } // There are some assumptions made about the width of the console, // so ensure that the screen buffer is at least CONSOLE_MIN_WIDTH wide if(GetConsoleScreenBufferInfo(m_hout, &conInfo)) { if(conInfo.dwSize.X < CONSOLE_MIN_WIDTH) { m_uSavedWidth = conInfo.dwSize.X; conInfo.dwSize.X = CONSOLE_MIN_WIDTH; SetConsoleScreenBufferSize(m_hout, conInfo.dwSize); } } // Change the console window title to reflect the application name if((pszTitle) && (strConTitle.Allocate(1025))) { if(GetConsoleTitle(strConTitle, 1024) > 0) { m_strSavedTitle = strConTitle; // Save the original title SetConsoleTitle(pszTitle); // Set the new title } } // Attempt to create the CTRL+C handler event object, and register the control // handler function to be used for this process s_hevtCtrlC = CreateEvent(NULL, FALSE, FALSE, NULL); SetConsoleCtrlHandler(ConsoleControlHandler, TRUE); BlankLines(); // Start out with a blank line UnlockConsole(); // Release the console lock return ERROR_SUCCESS;}
开发者ID:zukisoft,项目名称:external,代码行数:57,
示例14: move_consoleint move_console(){ BYTE Title[200]; HANDLE hConWnd; GetConsoleTitle(Title,sizeof(Title)); hConWnd=FindWindow(NULL,Title); SetWindowPos(hConWnd,0,650,0,0,0,SWP_NOSIZE|SWP_NOZORDER); return 0;}
开发者ID:pinchyCZN,项目名称:Uninstaller,代码行数:9,
示例15: GetTitleTCHAR* GetTitle(){ // // Retrieves the title of console. // static TCHAR szWindowTitle[256] = _T(""); GetConsoleTitle(szWindowTitle, sizeof(szWindowTitle)); return szWindowTitle;}
开发者ID:fre2003,项目名称:min-toolchain,代码行数:10,
示例16: mainint main(int argc, char* argv[]){ /* char arg[200]={0}; arg[0]='/"'; strcpy(arg+1, argv[0]); int len=int(strlen(arg)); arg[len]='/"'; HWND hWnd=FindWindow(NULL, arg); //找到程序运行窗口的句柄 HDC hDC=GetDC(hWnd);//通过窗口句柄得到该窗口的设备场境句柄 HPEN hPen, hOldPen; //画笔 int j=0; for(; j<500; ++j) SetPixel(hDC, 10+j, 10+j, 0x0000ff);//用画点的办法画一根线,最后一个参数是颜色(32位) hPen=CreatePen(PS_SOLID, 2, 0x00ff00);//生成绿色画笔 hOldPen=(HPEN)SelectObject(hDC, hPen);//把画笔引入设备场境 MoveToEx(hDC, 20, 50, NULL); //设置画线起点 LineTo(hDC, 520, 550); //画到终点 Arc(hDC, 100, 100, 300, 300, 350, 500, 350, 500);//画圆 SelectObject(hDC, hOldPen); //下面是对比,表明它确实是控制台程序 printf("hello console"); system("pause");*/ HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); // 获取标准输出设备句柄 CONSOLE_SCREEN_BUFFER_INFO bInfo; // 窗口缓冲区信息 GetConsoleScreenBufferInfo(hOut, &bInfo ); // 获取窗口缓冲区信息 SetConsoleTextAttribute(hOut, FOREGROUND_GREEN); char strTitle[255]; GetConsoleTitle(strTitle, 255); // 获取窗口标题 printf("当前窗口标题是:%s/n", strTitle); _getch(); SetConsoleTitle("控制台窗口操作"); // 获取窗口标题 _getch(); COORD size = {80, 25}; SetConsoleScreenBufferSize(hOut,size); // 重新设置缓冲区大小 _getch(); SMALL_RECT rc = {0,0, 80-1, 25-1}; // 重置窗口位置和大小 SetConsoleWindowInfo(hOut,true ,&rc); CloseHandle(hOut); // 关闭标准输出设备句柄 }
开发者ID:liguyu,项目名称:cppexample,代码行数:55,
示例17: WinMain/*------------------------------------------------------------------------Procedure: WinMain ID:1Purpose: Entry point for windows programs.Input:Output:Errors:------------------------------------------------------------------------*/int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow){ MSG msg; HANDLE hAccelTable; char consoleTitle[512]; HWND hwndConsole; CurrentEditBuffer = (EditBuffer*)SafeMalloc(sizeof(EditBuffer)); CurrentEditBuffer->LineCount = 0; CurrentEditBuffer->Lines = NULL; //setup the history index pointer historyEntry = NULL; // Setup the hInst global hInst = hInstance; // Do the setup if (!Setup(&hAccelTable)) return 0; // Need to set up a console so that we can send ctrl-break signal // to inferior Caml AllocConsole(); GetConsoleTitle(consoleTitle,sizeof(consoleTitle)); hwndConsole = FindWindow(NULL,consoleTitle); ShowWindow(hwndConsole,SW_HIDE); // Create main window and exit if this fails if ((hwndMain = CreateinriaWndClassWnd()) == (HWND)0) return 0; // Create the status bar CreateSBar(hwndMain,"Ready",2); // Show the window ShowWindow(hwndMain,SW_SHOW); // Create the session window hwndSession = MDICmdFileNew("Session transcript",0); // Get the path to ocaml.exe GetOcamlPath(); // Start the interpreter StartOcaml(); // Show the session window ShowWindow(hwndSession, SW_SHOW); // Maximize it SendMessage(hwndMDIClient, WM_MDIMAXIMIZE, (WPARAM) hwndSession, 0); PostMessage(hwndMain,WM_USER+1000,0,0); while (GetMessage(&msg,NULL,0,0)) { if (!TranslateMDISysAccel(hwndMDIClient, &msg)) if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); // Translates virtual key codes DispatchMessage(&msg); // Dispatches message to window } } WriteToPipe("#quit;;/r/n/032"); KillTimer((HWND) 0, TimerId); return msg.wParam;}
开发者ID:OCamlPro,项目名称:OCamlPro-OCaml-Branch,代码行数:62,
示例18: move_consoleint move_console(int x,int y,int w,int h){ char title[MAX_PATH]={0}; HWND hcon; GetConsoleTitle(title,sizeof(title)); if(title[0]!=0){ hcon=FindWindow(NULL,title); SetWindowPos(hcon,0,x,y,w,h,SWP_NOZORDER); } return 0;}
开发者ID:pinchyCZN,项目名称:blitter,代码行数:11,
示例19: Title Title(const std::string& new_title) : old_title_defined(false) { char title[256]; if (GetConsoleTitle(title, sizeof(title))) { old_title = title; old_title_defined = true; } SetConsoleTitle(new_title.c_str()); }
开发者ID:akoshelnik,项目名称:openvpn3,代码行数:11,
示例20: titlestd::tstring Console::getTitle(void) const { std::vector<tchar_t> title(_MAX_PATH); // Get the attach console's title string size_t length = GetConsoleTitle(title.data(), static_cast<DWORD>(title.size())); if(length == 0) throw Win32Exception(); // Use either the returned length or the buffer length return std::tstring(title.data(), std::min(length, title.size()));}
开发者ID:zukisoft,项目名称:vm,代码行数:11,
示例21: hide_consolevoid hide_console(){ char title[MAX_PATH]={0}; HANDLE hcon; GetConsoleTitle(title,sizeof(title)); if(title[0]!=0){ hcon=FindWindow(NULL,title); ShowWindow(hcon,SW_HIDE); SetForegroundWindow(hcon); }}
开发者ID:pinchyCZN,项目名称:Uninstaller,代码行数:12,
示例22: printMyPidvoid printMyPid(){ wchar_t myTitle[1024]; GetConsoleTitle(&myTitle[0], 1024); HWND myWindow = FindWindow(NULL, myTitle); DWORD pid; GetWindowThreadProcessId(myWindow, &pid); printf("My pid is %d/n", pid);}
开发者ID:buildingwatsize,项目名称:GameHackingExamples,代码行数:12,
示例23: FindConsoleHandlestatic HWND FindConsoleHandle(){ HWND hWnd; if (!GetConsoleTitle( g_szSaveTitle, _countof( g_szSaveTitle ))) return NULL; if (!SetConsoleTitle( g_pszTempTitle )) return NULL; Sleep(20); hWnd = FindWindow( NULL, g_pszTempTitle ); SetConsoleTitle( g_szSaveTitle ); return hWnd;}
开发者ID:2kranki,项目名称:hercules-390,代码行数:12,
示例24: hide_windowstatic voidhide_window (void){ char title [255]; HWND win; GetConsoleTitle (title, 254); win = FindWindow (NULL,title); if (win) SetWindowPos (win, NULL, 0, 0, 0, 0, SWP_HIDEWINDOW);}
开发者ID:cookrn,项目名称:openamq,代码行数:12,
示例25: GetConsoleHwndHWND GetConsoleHwnd() {#define MY_BUFSIZE 1024 HWND hwndFound; char pszNewWindowTitle[MY_BUFSIZE]; char pszOldWindowTitle[MY_BUFSIZE]; GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); wsprintf(pszNewWindowTitle, "%d/%d", GetTickCount(), GetCurrentProcessId()); SetConsoleTitle(pszNewWindowTitle); Sleep(40); hwndFound = FindWindow(NULL, pszNewWindowTitle); SetConsoleTitle(pszOldWindowTitle); return(hwndFound);}
开发者ID:adstep,项目名称:HackBaseFix2,代码行数:13,
示例26: getConsoleHandleHWND getConsoleHandle(void) { char oldTitle[1000]; char newTitle[1000]; HWND handle; GetConsoleTitle(oldTitle, 1000); wsprintf(newTitle, "Arun console%d-%d", GetTickCount(), GetCurrentProcessId()); SetConsoleTitle(newTitle); Sleep(50); handle = FindWindow(NULL, newTitle); SetConsoleTitle(oldTitle); return handle;}
开发者ID:cspiegel,项目名称:garglk,代码行数:14,
注:本文中的GetConsoleTitle函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetContactProto函数代码示例 C++ GetConsoleOutputCP函数代码示例 |