CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2007
    Posts
    19

    Want to hide IE window using CreateProcess()

    I want to execute a HTML page using CreateProcess API but i dont want to show the Internet Explorer, this is the code but it shows the windows. I have given the code. Can anyone one help me ?

    TCHAR cmd[ MAX_PATH ] = TEXT("");
    SearchPath( NULL, TEXT("explorer.exe"), NULL, MAX_PATH - 1, cmd, NULL );

    const char* pszFileName = "C:\\test.html";
    char name[400];
    sprintf(name,pszFileName);
    _stprintf( cmd + _tcslen( cmd ), TEXT(" \"%s\",/e,/idlist"), name);


    PROCESS_INFORMATION pi;
    ZeroMemory (&pi, sizeof (pi));


    STARTUPINFO si;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);

    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;

    CreateProcess (NULL, cmd, 0, 0, 0, DETACHED_PROCESS, 0, 0, &si, &pi);

    if( pi.hThread != INVALID_HANDLE_VALUE )
    CloseHandle( pi.hThread );
    if( pi.hProcess != INVALID_HANDLE_VALUE )
    CloseHandle( pi.hProcess );

  2. #2
    Join Date
    Feb 2008
    Location
    India
    Posts
    28

    Re: Want to hide IE window using CreateProcess()

    Quote Originally Posted by rajprabhu2k
    SearchPath( NULL, TEXT("explorer.exe"), NULL, MAX_PATH - 1, cmd, NULL );
    you have used "explorer.exe"
    but I think you should use "iexplore.exe"
    please recheck your code

  3. #3
    Join Date
    Aug 2007
    Posts
    19

    Re: Want to hide IE window using CreateProcess()

    hi this code is working, but it shows the Internet explorer window , I want to hide the internet explorer window, everything should be done in background.

  4. #4
    Join Date
    Feb 2008
    Location
    India
    Posts
    28

    Re: Want to hide IE window using CreateProcess()

    oh sorry!!!
    by mistake i read ShellExecute instead of SearchPath.

    I wanted to say like this....

    Code:
    ShellExecute(NULL,L"Open",L"C:\\test.html",NULL,NULL,SW_HIDE);
    you can modify cmd and put instead of L"C:\\test.html"

  5. #5
    Join Date
    Aug 2007
    Posts
    19

    Re: Want to hide IE window using CreateProcess()

    It works but , this also shows the browser i want to hide the browser window

  6. #6
    Join Date
    Dec 2003
    Location
    Northern Ireland
    Posts
    1,362

    Re: Want to hide IE window using CreateProcess()

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook


    0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010

  7. #7
    Join Date
    Aug 2007
    Posts
    19

    Re: Want to hide IE window using CreateProcess()

    CreateProcess (NULL, cmd, 0, 0, 0, CREATE_NO_WINDOW, 0, 0, &si, &pi);
    ShowWindow((HWND)pi.dwProcessId,SW_HIDE);

    thanks but its not working

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Want to hide IE window using CreateProcess()

    Quote Originally Posted by rajprabhu2k
    ShowWindow((HWND)pi.dwProcessId,SW_HIDE);
    dwProcessID isn't the hWnd to the main window so this won't work. You need to grab the main window for IExplore.exe. You can use FindWindow() or EnumWindows( ). I would use EnumWindows and restrict the enum to toplevel windows matching the dwProcessID of the explorer instance you launched.

    Another way to approach this is to use the Web Browser control within your application.

  9. #9
    Join Date
    Aug 2007
    Posts
    19

    Re: Want to hide IE window using CreateProcess()

    How to add WebBrowser control into the application?

  10. #10
    Join Date
    Jan 2008
    Posts
    178

    Re: Want to hide IE window using CreateProcess()

    Quote Originally Posted by rajprabhu2k
    How to add WebBrowser control into the application?
    Just search on Google Groups : hundreds of samples in 0.15 seconds..

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured