CreateProcess

This is a discussion on CreateProcess within the Windows Programming forums, part of the Platform Specific Boards category; I would like to use CreateProcess to start an app minimised but I just can't get it to work. As ...

  1. #1
    Unregistered
    Guest

    Question CreateProcess

    I would like to use CreateProcess to start an app minimised but I just can't get it to work.
    As a test, I set up the CreateProcess parameters and STARTUPINFO structure with the following lines;

    STARTUPINFO suInfo;
    PROCESS_INFORMATION procInfo;
    CString m_Process = "C:\\WINDOWS\\NOTEPAD.EXE";
    char *vip = "C:\\WINDOWS\\NOTEPAD.EXE";
    memset(&suInfo, 0, sizeof(suInfo));
    suInfo.cb = sizeof(suInfo);
    suInfo.dwFlags = STARTF_USESHOWWINDOW;
    suInfo.wShowWindow = SW_MINIMIZE;

    And then on the press of a key, I called the CreateProcess thus;
    CreateProcess(m_Process,vip,NULL,NULL,FALSE,NORMAL
    _PRIORITY_CLASS,NULL,NULL,&suInfo,&procInfo);

    I thought this code would start notepad minimised but it starts as a normal window... any ideas on what is wrong?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,786
    Personally, if I have to do this sort of thing I will go for ShellExecute....its easier and is more than sufficient for this sort of deal;


    Code:
     ShellExecute(HWND_DESKTOP,"OPEN","NOTEPAD",NULL,
    			  NULL,SW_SHOWMINIMIZED);
    Nothing easier!!!!

    CreateProcess is much more complicated and allows greater power (IE....security and how the process is created - such as with a console....), but for this stuff......no need to get complex

  3. #3
    Unregistered
    Guest
    I considered ShellExecute but as you say, CreateProcess is more powerful. I am trying to use CreateProcess so that I then get the information required to kill the process whenever I want.
    All I need is a hint on what I am doing wrong in setting up the call.

  4. #4
    Unregistered
    Guest

    Smile

    Thanks for tryin but looks like I've figured it out now
    The first two arguments of CreateProcess are Application Name and Command Line. By setting the above Command Line value to NULL (ie replacing the 'vip' with NULL), the example now works.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CreateProcess() + Command Line
    By IndioDoido in forum Windows Programming
    Replies: 20
    Last Post: 11-14-2008, 06:35 PM
  2. CreateProcess with arguments
    By Niara in forum Windows Programming
    Replies: 14
    Last Post: 09-08-2007, 05:41 AM
  3. CreateProcess with Resource of executable, not the Filename
    By Ktulu in forum Windows Programming
    Replies: 4
    Last Post: 11-04-2006, 12:07 AM
  4. question on CreateProcess() redirection
    By ac251404 in forum Windows Programming
    Replies: 13
    Last Post: 07-18-2006, 11:06 AM
  5. CreateProcess()
    By Newfie in forum C++ Programming
    Replies: 2
    Last Post: 05-07-2002, 07:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21