CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: How to check thread with MFC ?

  1. #1
    Join Date
    Feb 2013

    How to check thread with MFC ?

    I use MFC Find console window and send key to console like this.

    HWND w;
    	w = FindWindow(NULL, L"c:\\users\\pkru\\documents\\visual studio 2010\\Projects\\CleanVirus\\Debug\\CleanVirus.exe");
    				MessageBox(NULL,_T("Not Found"), _T("OK"), MB_OK);
    				DWORD dwProcessId = 0;
    GetWindowThreadProcessId( ::GetDesktopWindow(),
                              &dwProcessId );
    		//MessageBox(NULL,_T("Found"), _T("OK"), MB_OK);
    	ir[0].EventType = KEY_EVENT;
        ir[0].Event.KeyEvent.bKeyDown = TRUE;
        ir[0].Event.KeyEvent.dwControlKeyState = 0;
        ir[0].Event.KeyEvent.uChar.UnicodeChar = 'y';
        ir[0].Event.KeyEvent.wRepeatCount = 1;
        ir[0].Event.KeyEvent.wVirtualKeyCode = 'Y';
        ir[0].Event.KeyEvent.wVirtualScanCode = MapVirtualKey('Y', MAPVK_VK_TO_VSC);
        ir[1].EventType = KEY_EVENT;
        ir[1].Event.KeyEvent.bKeyDown = TRUE;
        ir[1].Event.KeyEvent.dwControlKeyState = 0;
        ir[1].Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
        ir[1].Event.KeyEvent.wRepeatCount = 1;
        ir[1].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
        ir[1].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC);
        ir[2].EventType = KEY_EVENT;
        ir[2].Event.KeyEvent.bKeyDown = FALSE;
        ir[2].Event.KeyEvent.dwControlKeyState = 0;
        ir[2].Event.KeyEvent.uChar.UnicodeChar = VK_RETURN;
        ir[2].Event.KeyEvent.wRepeatCount = 1;
        ir[2].Event.KeyEvent.wVirtualKeyCode = VK_RETURN;
        ir[2].Event.KeyEvent.wVirtualScanCode = MapVirtualKey(VK_RETURN, MAPVK_VK_TO_VSC);
    	 dwTmp = 0;
        WriteConsoleInput(hConIn, ir, 3, &dwTmp);
    	 Sleep( 1000 );
    After program process success in console it not close console windows but it show like this in Output
    The thread 'Win32 Thread' (0x1300) has exited with code 0 (0x0).
    I think if I can check when VC will show this line, then I can use FreeConsole(); for close console windows.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004

    Re: How to check thread with MFC ?

    What app launches CleanVirus.exe? If your process is launching it, try to launch it with the /c switch.

    C:\>"c:\users\pkru\documents\visual studio 2010\Projects\CleanVirus\Debug\CleanVirus.exe" /c

  3. #3
    Join Date
    Feb 2013

    Re: How to check thread with MFC ?

    C:\>"c:\users\pkru\documents\visual studio 2010\Projects\CleanVirus\Debug\CleanVirus.exe"

    is my project name in VC which FindWindow() read title from
    DWORD WINAPI unhidden(LPVOID lp)

    return 0;

    And the code unhidden.bat is

    @echo off
    I try to use Unhidden.exe /c but it not close console window

    when process success it show like this in console. it not close console windows.
    Process complete !
    Press any key to continue . . .

  4. #4
    Join Date
    Nov 2000
    Voronezh, Russia

    Re: How to check thread with MFC ?

    Quote Originally Posted by mmc01 View Post
    I try to use Unhidden.exe /c but it not close console window

    when process success it show like this in console. it not close console windows.
    If you run your program from VS with F5, you are not able to avoid being given with "Press any key to continue..." This is how VS works, and this has nothing to do with your code.
    Best regards,

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)