当前位置: 首页>>代码示例>>C++>>正文


C++ GetConsoleTitle函数代码示例

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


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


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