• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetConsoleTitle函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetConsoleTitle函数的典型用法代码示例。如果您正苦于以下问题:C++ GetConsoleTitle函数的具体用法?C++ GetConsoleTitle怎么用?C++ GetConsoleTitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetConsoleTitle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: open_console

void 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,代码来源:ucommander.cpp


示例2: GetConsoleHwnd

HWND 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,代码来源:get_console_hwnd.cpp


示例3: GetConsoleTitle

HWND 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,代码来源:CSystem.cpp


示例4: GetConsoleHwnd

// GetConsoleHwnd() helper function from MSDN Knowledge Base Article Q124103
// needed, because HWND GetConsoleWindow(VOID) is not avaliable under Win95/98/ME
HWND 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,代码来源:TextConsoleWin32.cpp


示例5: GetDebugWindowHandle

static 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,代码来源:protoDebug.cpp


示例6: rb_GetConsoleTitle

static 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,代码来源:Console.c


示例7: GetConsoleTitle

	const std::string Console::GetTitle() {

		TCHAR title[MAX_PATH];
		GetConsoleTitle( title, MAX_PATH );

		return title;
	}
开发者ID:gallexme,项目名称:Captain-Hook,代码行数:7,代码来源:Console.cpp


示例8: GetConsoleHwnd

/* Direct from the horse's mouth: Microsoft KB article Q124103 */
static HWND
GetConsoleHwnd (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,代码来源:console-msw.c


示例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,代码来源:main.cpp


示例10: GetConsoleTitle

// Need this to setup DirectX
HWND 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,代码来源:directx.cpp


示例11: main

int 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,代码来源:main-accessingMemory.cpp


示例12: InitTermcap

/* For a few selected terminal types, we'll print in boldface, etc.
 * This isn't too important, though.
 */
void
InitTermcap(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,代码来源:readln.c


示例13: GetStdHandle

DWORD 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,代码来源:svctlcui.cpp


示例14: move_console

int 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,代码来源:UNinstaller.c


示例15: GetTitle

TCHAR* GetTitle()
{
  //
	// Retrieves the title of console.
  //
	static TCHAR szWindowTitle[256] = _T("");
	GetConsoleTitle(szWindowTitle, sizeof(szWindowTitle));
  
	return szWindowTitle;
}
开发者ID:fre2003,项目名称:min-toolchain,代码行数:10,代码来源:window.c


示例16: main

int 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,代码来源:SS7Monitor.cpp


示例17: WinMain

/*------------------------------------------------------------------------
Procedure:     WinMain ID:1
Purpose:       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,代码来源:ocaml.c


示例18: move_console

int 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,代码来源:3dtornado.c


示例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,代码来源:console.hpp


示例20: title

std::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,代码来源:Console.cpp



注:本文中的GetConsoleTitle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetContactProto函数代码示例发布时间:2022-05-30
下一篇:
C++ GetConsoleOutputCP函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap