1

I am working on development of simple application launcher program which is supposed to launch from its main window several applications. One of the applications to launch is an Internet Explorer and it is supposed to be started minimized. The problem - my code works as intended only if there is no other Internet Explorer instance already running. If there is one, my application launcher starts its Internet Explorer instance in normal (not minimized) window. I am observing this behaviour only with Internet Explorer. If I modify my code to start Notepad instead of the Internet Explorer, then everyting works as intended no matter how many instances of the Notepad are already running - all new Notepad instances start minimized. Here is the relevant part of my code which in fact is very basic:

case IDC_MAIN_BUTTON5:
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    memset(&si, 0, sizeof(si));
    memset(&pi, 0, sizeof(pi));
    si.cb = sizeof(si);
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_SHOWMINIMIZED;

    CreateProcess(L"C:\\Program Files\\Internet Explorer\\iexplore.exe",
    L"",
    NULL,
    NULL,
    FALSE,
    0,
    NULL,
    NULL,
    &si,
    &pi);

    WaitForInputIdle(pi.hProcess, 1000);

    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}
break;

Any ideas or suggestions how to solve this strange problem would be very much appreciated.

antanas
  • 11
  • 1
  • 2
    Why are you, in 2020, writing code that depends on IE?? Also, the application you launch can have its own opinion about whether it should be minimized or not. You cannot necessarily control that. – Jesper Juhl May 16 '20 at 16:55
  • 2
    Please, let Internet Explorer go. It's done enough. It deserves a break. – tadman May 16 '20 at 17:01
  • Instead of forcing open Internet Explorer, just [open the link](https://stackoverflow.com/questions/17347950/how-do-i-open-a-url-from-c) in the default browser using `ShellExecute`. – tadman May 16 '20 at 17:02
  • @Jesper Juhl It really does not matter whether it is Internet Explorer or Microsoft Edge. The behaviour is the same. – antanas May 16 '20 at 17:53
  • @tadman It really does not matter whether it is createprocess() or shellexecute(). The behaviour is the same. – antanas May 16 '20 at 17:54
  • @antanas I think you are trying to control something here which you just cannot. The target application has its own idea about what should happen and you cannot overrule it. – Jesper Juhl May 16 '20 at 17:58

0 Answers0