Click here to Skip to main content
15,915,336 members
Home / Discussions / System Admin
   

System Admin

 
GeneralRe: Virus/Hack threat while not logged in Pin
Dan Neely26-Jul-07 2:30
Dan Neely26-Jul-07 2:30 
GeneralRe: Virus/Hack threat while not logged in Pin
Craster26-Jul-07 5:16
Craster26-Jul-07 5:16 
GeneralRe: Virus/Hack threat while not logged in Pin
tonymathewt9-Aug-07 0:03
professionaltonymathewt9-Aug-07 0:03 
GeneralRe: Virus/Hack threat while not logged in Pin
Cfer8313-Sep-07 6:40
Cfer8313-Sep-07 6:40 
QuestionFor process started by Windows... Pin
chervu24-Jul-07 12:01
chervu24-Jul-07 12:01 
AnswerRe: For process started by Windows... Pin
Luc Pattyn24-Jul-07 12:26
sitebuilderLuc Pattyn24-Jul-07 12:26 
AnswerRe: For process started by Windows... [modified] Pin
Mike Dimmick25-Jul-07 0:28
Mike Dimmick25-Jul-07 0:28 
AnswerRe: For process started by Windows... Pin
Jonathan [Darka]25-Jul-07 8:13
professionalJonathan [Darka]25-Jul-07 8:13 
You can do this by calling ShowWindow() on the console apps main window, to do this you need to get a handle to the window.

Use this function to get a handle to the window (Use this for Windows 9x only as it does not have a GetConsoleWindow() function), see the second code sample on how to show/hide the console window on all versions of windows.

	// Obtain the Handle to this applications Console Window
	// As we don't have the lovely GetConsoleWindow() function under Win9X
	// We make a copy of the Console Windows title, then change it to something unique, ( a GUID value )
	// We then use this GUID to perform a FindWindow() ensuring we only locate the console for 'this' application
HWND Console::GetConsoleWindow9X() const
{
	HWND hWndConsole = NULL; // The console window handle

	TCHAR szTempTitle[_MAX_PATH] = {'\0'};
	TCHAR szTempOldTitle[_MAX_PATH] = {'\0'}; // This is used to store the Console Window's title temporarily

		// Get the title of the console window - this may not be unique
	if(GetConsoleTitle(szTempOldTitle, _MAX_PATH) > 0)
	{
			// Lets make the title 'unique', so that we can perform FindWindow()...
			// Created as a UNICODE string
		WCHAR szBuff[_MAX_PATH] = {'\0'};

		GUID obGuid;
		CoCreateGuid(&obGuid);

		StringFromGUID2(obGuid, szBuff, _MAX_PATH);
		wsprintf(szTempTitle, "%ws", szBuff);

		SetConsoleTitle(szTempTitle);

		Sleep(50); // This gives enough time to ensure the console title is updated, else the FindWindow may fail

			// Ok, try to Find the window using a variety of class names as we don't really know what OS we are running on
		if((hWndConsole = FindWindow(_T("tty"), szTempTitle)) == NULL)
			if((hWndConsole = FindWindow(_T("ConsoleWindowClass"), szTempTitle)) == NULL) // Windows 2000 
				hWndConsole = FindWindow(NULL, szTempTitle); // Catch all

		SetConsoleTitle(szTempOldTitle); // Set the title back to it's original value
	}

	return hWndConsole;
}


This second example can be used to show/hide the console window on all OS's, on Windows 9x it will call the function in the first example to get the handle to hide.

void Console::ShowConsoleWindow(bool bHide /* = false */)
{
	HWND hWndConsole = NULL;

#if(_WIN32_WINNT >= 0x0500) // Windows 2000 and later only
	hWndConsole = GetConsoleWindow();
#else
	hWndConsole = GetConsoleWindow9X();
#endif

	ShowWindow(hWndConsole, (bHide) ? SW_SHOW : SW_HIDE);
	
//	dwLastErrorCode_ = ERROR_SUCCESS;
}


regards,


Jonathan Wilkes
Darka[Xanya.net]

GeneralRe: For process started by Windows... Pin
chervu25-Jul-07 10:33
chervu25-Jul-07 10:33 
GeneralRe: For process started by Windows... Pin
Jonathan [Darka]25-Jul-07 21:54
professionalJonathan [Darka]25-Jul-07 21:54 
Questionfree proxy server Pin
vpilu123-Jul-07 20:02
vpilu123-Jul-07 20:02 
AnswerRe: free proxy server Pin
Jonathan [Darka]23-Jul-07 21:24
professionalJonathan [Darka]23-Jul-07 21:24 
AnswerRe: free proxy server Pin
Sebastian Schneider23-Jul-07 21:51
Sebastian Schneider23-Jul-07 21:51 
GeneralRe: free proxy server Pin
Zoltan Balazs24-Jul-07 10:57
Zoltan Balazs24-Jul-07 10:57 
QuestionCPU usage during File Transfer Pin
KKrista22-Jul-07 22:56
KKrista22-Jul-07 22:56 
AnswerRe: CPU usage during File Transfer Pin
Sebastian Schneider22-Jul-07 23:16
Sebastian Schneider22-Jul-07 23:16 
GeneralRe: CPU usage during File Transfer Pin
KKrista23-Jul-07 0:51
KKrista23-Jul-07 0:51 
AnswerRe: CPU usage during File Transfer Pin
Mike Dimmick23-Jul-07 0:33
Mike Dimmick23-Jul-07 0:33 
AnswerRe: CPU usage during File Transfer Pin
Craster23-Jul-07 5:37
Craster23-Jul-07 5:37 
QuestionSuggestions for slow internet Pin
Kevnar22-Jul-07 6:37
Kevnar22-Jul-07 6:37 
AnswerRe: Suggestions for slow internet Pin
Paul Conrad22-Jul-07 6:52
professionalPaul Conrad22-Jul-07 6:52 
GeneralRe: Suggestions for slow internet Pin
Kevnar22-Jul-07 7:37
Kevnar22-Jul-07 7:37 
GeneralRe: Suggestions for slow internet Pin
Paul Conrad22-Jul-07 7:39
professionalPaul Conrad22-Jul-07 7:39 
GeneralRe: Suggestions for slow internet Pin
Kevnar22-Jul-07 9:08
Kevnar22-Jul-07 9:08 
GeneralRe: Suggestions for slow internet Pin
Paul Conrad22-Jul-07 9:27
professionalPaul Conrad22-Jul-07 9:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.