本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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()
示例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();
}
示例7: GetConsoleTitle
const std::string Console::GetTitle() {
TCHAR title[MAX_PATH];
GetConsoleTitle( title, MAX_PATH );
return title;
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}
示例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 */
示例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;
}
示例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;
}
示例15: GetTitle
TCHAR* GetTitle()
{
//
// Retrieves the title of console.
//
static TCHAR szWindowTitle[256] = _T("");
GetConsoleTitle(szWindowTitle, sizeof(szWindowTitle));
return szWindowTitle;
}